@@ -0,0 +1,2406 @@
+import logging%0Alogger = logging.getLogger('edisgo')%0A%0Adef select_cable(network, level, apparent_power):%0A    %22%22%22Selects an appropriate cable type and quantity using given apparent power.%0A%0A    Considers load factor.%0A%0A    Parameters%0A    ----------%0A    network : :class:%60~.grid.network.Network%60%0A        The eDisGo container object%0A    level : :obj:%60str%60%0A        Grid level ('mv' or 'lv')%0A    apparent_power : :obj:%60float%60%0A        Apparent power the cable must carry in kVA%0A%0A    Returns%0A    -------%0A    :pandas:%60pandas.Series%3Cseries%3E%60%0A        Cable type%0A    :obj:%60%C3%ACnt%60%0A        Cable count%0A    %22%22%22%0A%0A    cable_count = 1%0A%0A    if level == 'mv':%0A        load_factor = network.config%5B'grid_expansion'%5D%5B'load_factor_mv_line'%5D%0A%0A        available_cables = network.equipment_data%5B'MV_cables'%5D%5B%0A            network.equipment_data%5B'MV_cables'%5D%5B'U_n'%5D == network.mv_grid.voltage_nom%5D%0A%0A        suitable_cables = available_cables%5B%0A            available_cables%5B'I_max_th'%5D *%0A            network.mv_grid.voltage_nom *%0A            load_factor %3E apparent_power%5D%0A%0A        # increase cable count until appropriate cable type is found%0A        while suitable_cables.empty:%0A            cable_count += 1%0A            suitable_cables = available_cables%5B%0A                available_cables%5B'I_max_th'%5D *%0A                network.mv_grid.voltage_nom *%0A                cable_count *%0A                load_factor %3E apparent_power%5D%0A%0A        cable_type = suitable_cables.ix%5Bsuitable_cables%5B'I_max_th'%5D.idxmin()%5D%0A%0A    elif level == 'lv':%0A        load_factor = network.config%5B'grid_expansion'%5D%5B'load_factor_lv_line'%5D%0A%0A        suitable_cables = network.equipment_data%5B'LV_cables'%5D%5B%0A            network.equipment_data%5B'LV_cables'%5D%5B'I_max_th'%5D *%0A            network.equipment_data%5B'LV_cables'%5D%5B'U_n'%5D *%0A            load_factor %3E apparent_power%5D%0A%0A        # increase cable count until appropriate cable type is found%0A        while suitable_cables.empty:%0A            cable_count += 1%0A            suitable_cables = network.equipment_data%5B'LV_cables'%5D%5B%0A                network.equipment_data%5B'LV_cables'%5D%5B'I_max_th'%5D *%0A                network.equipment_data%5B'LV_cables'%5D%5B'U_n'%5D *%0A                cable_count *%0A                load_factor %3E apparent_power%5D%0A%0A        cable_type = suitable_cables.ix%5Bsuitable_cables%5B'I_max_th'%5D.idxmin()%5D%0A%0A    else:%0A        raise ValueError('Please supply a level (either %5C'mv%5C' or %5C'lv%5C').')%0A%0A    return cable_type, cable_count%0A

add method to select appropriate cable to grid tools