Toolbox
The pandapower toolbox is a collection of helper functions that are implemented for the pandapower framework. It is designed for functions of common application that fit nowhere else. Have a look at the available functions to save yourself the effort of maybe implementing something twice. If you develop some functionality which could be interesting to other users as well and do not fit into one of the specialized packages, feel welcome to add your contribution. To improve overview functions are loosely grouped by functionality, please adhere to this notion when adding your own functions and feel free to open new groups as needed.
Comparison
- pandapower.toolbox.dataframes_equal(df1, df2, ignore_index_order=True, assume_geojson_strings=True, **kwargs)
Returns a boolean whether the given two dataframes are equal or not.
- pandapower.toolbox.compare_arrays(x, y)
Returns an array of bools whether array x is equal to array y. Strings are allowed in x or y. NaN values are assumed as equal.
- pandapower.toolbox.nets_equal(net1, net2, check_only_results=False, check_without_results=False, exclude_elms=None, name_selection=None, assume_geojson_strings=True, **kwargs)
Returns a boolean whether the two given pandapower networks are equal.
pandapower net keys starting with “_” are ignored. Same for the key “et” (elapsed time).
If the element tables contain JSONSerializableClass objects, they will also be compared: attributes are compared but not the addresses of the objects.
- Parameters:
**net1** (pandapowerNet)
**net2** (pandapowerNet)
**check_only_results** (bool, False) - if True, only result tables (starting with
res_)compared (are)
**check_without_results** (bool, False) - if True, result tables (starting with
res_)comparison (are ignored for)
**exclude_elms** (list, None)
comparison
**name_selection** (list, None)
dataframes_equal() (**kwargs** - key word arguments for)
- pandapower.toolbox.nets_equal_keys(net1, net2, check_only_results, check_without_results, exclude_elms, name_selection, assume_geojson_strings, **kwargs)
Returns a lists of keys which are 1) not equal and 2) not checked. Used within nets_equal().
Power Factor
- pandapower.toolbox.signing_system_value(element_type)
Returns a 1 for all bus elements using the consumver viewpoint and a -1 for all bus elements using the generator viewpoint.
- pandapower.toolbox.pq_from_cosphi(s, cosphi, qmode, pmode)
Calculates P/Q values from rated apparent power and cosine(phi) values.
s: rated apparent power
cosphi: cosine phi of the
qmode: “underexcited” (Q absorption, decreases voltage) or “overexcited” (Q injection, increases voltage)
pmode: “load” for load or “gen” for generation
As all other pandapower functions this function is based on the consumer viewpoint. For active power, that means that loads are positive and generation is negative. For reactive power, underexcited behavior (Q absorption, decreases voltage) is modeled with positive values, overexcited behavior (Q injection, increases voltage) with negative values.
- pandapower.toolbox.cosphi_from_pq(p, q)
Analog to pq_from_cosphi, but the other way around. In consumer viewpoint (pandapower): “underexcited” (Q absorption, decreases voltage) and “overexcited” (Q injection, increases voltage)
Result Information
- pandapower.toolbox.lf_info(net, numv=1, numi=2)
Prints some basic information of the results in a net (max/min voltage, max trafo load, max line load).
- Parameters:
**numv** (integer, 1)
**numi** (integer, 2)
- pandapower.toolbox.opf_task(net, delta_pq=1e-3, keep=False, log=True)
Collects some basic inforamtion of the optimal powerflow task und prints them.
- pandapower.toolbox.switch_info(net, sidx)
Prints what buses and elements are connected by a certain switch.
- pandapower.toolbox.overloaded_lines(net, max_load=100)
Returns the results for all lines with loading_percent > max_load or None, if there are none.
- pandapower.toolbox.violated_buses(net, min_vm_pu, max_vm_pu)
Returns all bus indices where vm_pu is not within min_vm_pu and max_vm_pu or returns None, if there are none of those buses.
- pandapower.toolbox.clear_result_tables(net)
Clears all
res_DataFrames in net.
- pandapower.toolbox.res_power_columns(element_type, side=0)
Returns columns names of result tables for active and reactive power
- Parameters:
element_type (str) – name of element table, e.g. “gen”
side (Union[int, str], optional) – Defines for branch elements which branch side is considered, by default 0
- Returns:
columns names of result tables for active and reactive power
- Return type:
list[str]
Examples
>>> res_power_columns("gen") ["p_mw", "q_mvar"] >>> res_power_columns("line", "from") ["p_from_mw", "q_from_mvar"] >>> res_power_columns("line", 0) ["p_from_mw", "q_from_mvar"] >>> res_power_columns("line", "all") ["p_from_mw", "q_from_mvar", "p_to_mw", "q_to_mvar"]
Item/Element Selection
- pandapower.toolbox.get_element_index(net, element_type, name, exact_match=True)
Returns the element(s) identified by a name or regex and its element-table.
- Parameters:
network (**net** - pandapower)
from (**element_type** - Table to get indices)
match. (**name** - Name of the element to)
**exact_match** (boolean, True) – True: Expects exactly one match, raises UserWarning otherwise. False: returns all indices containing the name
- Returns:
index - The index (or indices in case of exact_match=False) of matching element(s).
- pandapower.toolbox.get_element_indices(net, element_type, name, exact_match=True)
Returns a list of element(s) identified by a name or regex and its element-table -> Wrapper function of get_element_index()
- Parameters:
network (**net** - pandapower)
**element_type** (str, string iterable)
("line"
"bus"
etc.). ("trafo")
**name** (str)
**exact_match** (boolean, True) –
True: Expects exactly one match, raises UserWarning otherwise.
False: returns all indices containing the name
- Returns:
index (list) - List of the indices of matching element(s).
Example
>>> from pandapower.networks.create_examples import example_multivoltage >>> from pandapower import get_element_indices >>> net = example_multivoltage() >>> # get indices of only one element type (buses in this example): >>> get_element_indices(net, "bus", ["Bus HV%i" % i for i in range(1, 4)]) [32, 33, 34] >>> # get indices of only two element type (first buses, second lines): >>> get_element_indices(net, ["bus", "line"], "HV", exact_match=False) [Int64Index([32, 33, 34, 35], dtype='int64'), Int64Index([0, 1, 2, 3, 4, 5], dtype='int64')] >>> get_element_indices(net, ["bus", "line"], ["Bus HV3", "MV Line6"]) [34, 11]
- pandapower.toolbox.next_bus(net, bus, element_id, et='line', **kwargs)
Returns the index of the second bus an element is connected to, given a first one. E.g. the from_bus given the to_bus of a line.
- Parameters:
net (pandapowerNet) – pandapower net
bus (int) – index of bus
element_id (int) – index of element
et (str, optional) – which branch element type to consider, by default ‘line’
- Returns:
index of next connected bus
- Return type:
int
- pandapower.toolbox.get_connected_elements(net, element_type, buses, respect_switches=True, respect_in_service=False)
Returns elements connected to a given buses.
- Parameters:
**net** (pandapowerNet)
**element_type** (string, name of the element table)
**buses** (single integer or iterable of ints)
**respect_switches** (boolean, True) –
True: open switches will be respected
False: open switches will be ignored
**respect_in_service** (boolean, False) –
True: in_service status of connected lines will be respected
False: in_service status will be ignored
- Returns:
connected_elements (set) - Returns connected elements.
- pandapower.toolbox.get_connected_elements_dict(net, buses, respect_switches=True, respect_in_service=False, include_empty_lists=False, element_types=None, **kwargs)
Returns a dict of lists of connected elements.
- Parameters:
net (_type_) – _description_
buses (iterable of buses) – buses as origin to search for connected elements
respect_switches (bool, optional) – _description_, by default True
respect_in_service (bool, optional) – _description_, by default False
include_empty_lists (bool, optional) – if True, the output doesn’t have values of empty lists but may lack of element types as keys, by default False
element_types (iterable of strings, optional) – types elements which are analyzed for connection. If not given, all pandapower element types are analyzed. That list of all element types can also be restricted by key word arguments “connected_buses”, “connected_bus_elements”, “connected_branch_elements” and “connected_other_elements”, by default None
- Returns:
elements connected to given buses
- Return type:
dict[str,list]
- pandapower.toolbox.get_connected_buses(net, buses, consider=('l', 's', 't', 't3', 'i'), respect_switches=True, respect_in_service=False)
Returns buses connected to given buses. The source buses will NOT be returned.
- Parameters:
**net** (pandapowerNet)
**buses** (single integer or iterable of ints)
**respect_switches** (boolean, True) –
True: open switches will be respected
False: open switches will be ignored
**respect_in_service** (boolean, False) –
True: in_service status of connected buses will be respected
False: in_service status will be ignored
**consider** (iterable, ("l", "s", "t", "t3", "i"))
considered. (connections will be) –
l: lines
s: switches
t: trafos
t3: trafo3ws
i: impedances
- Returns:
cl (set) - Returns connected buses.
- pandapower.toolbox.get_connected_buses_at_element(net, element_index, element_type, respect_in_service=False)
Returns buses connected to a given branch element. In case of a bus switch, two buses will be returned, else one.
- Parameters:
**net** (pandapowerNet)
**element_index** (integer)
**element_type** (string) –
l, line: line
s, switch: switch
t, trafo: trafo
t3, trafo3w: trafo3w
i, impedance: impedance
**respect_in_service** (boolean, False)
True – in_service status of connected buses will be respected
False – in_service status will be ignored
- Returns:
cl (set) - Returns connected switches.
- pandapower.toolbox.get_connected_switches(net, buses, consider=('b', 'l', 't', 't3', 'i'), status='all', include_element_connections=False)
Returns switches connected to given buses.
- Parameters:
**net** (pandapowerNet)
**buses** (single integer or iterable of ints)
**consider** (iterable, ("l", "s", "t", "t3)) – will be considered. l: lines b: bus-bus-switches t: transformers t3: 3W transformers i: impedance
**status** (string, ("all", "closed", "open")) – be considered
**include_element_connections** (bool, False)
element
ending (e.g. the other line)
included (is)
- Returns:
cl (set) - Returns connected switches.
- pandapower.toolbox.get_connecting_branches(net, buses1, buses2, branch_elements=None)
Gets/Drops branches that connects any bus of buses1 with any bus of buses2.
- pandapower.toolbox.false_elm_links(net, element_type, col, target_element_type)
Returns which indices have links to elements of other element tables which does not exist in the net.
Examples
>>> false_elm_links(net, "line", "to_bus", "bus") # exemplary input 1 >>> false_elm_links(net, "poly_cost", "element", net["poly_cost"]["et"]) # exemplary input 2
- pandapower.toolbox.false_elm_links_loop(net, element_types=None)
Returns a dict of elements which indices have links to elements of other element tables which does not exist in the net. This function is an outer loop for get_false_links() applications.
- pandapower.toolbox.element_bus_tuples(bus_elements=True, branch_elements=True, res_elements=False)
Utility function Provides the tuples of elements and corresponding columns for buses they are connected to :param bus_elements: whether tuples for bus elements e.g. load, sgen, … are included :param branch_elements: whether branch elements e.g. line, trafo, … are included :param res_elements: whether result table names e.g. res_sgen, res_line, … are included :param return_type: which type the output has :return: list of tuples with element names and column names
- pandapower.toolbox.pp_elements(bus=True, bus_elements=True, branch_elements=True, other_elements=True, cost_tables=False, res_elements=False)
Returns a set of pandapower elements.
- pandapower.toolbox.branch_element_bus_dict(include_switch=False, sort=None)
Returns a dict with keys of branch elements and values of bus column names as list.
- pandapower.toolbox.count_elements(net, return_empties=False, **kwargs)
Counts how much elements of which element type exist in the pandapower net
- Parameters:
net (pandapowerNet) – pandapower net
return_empties (bool, optional) – whether element types should be listed if no element exist, by default False
kwargs (dict[str,bool], optional) – arguments (passed to pp_elements()) to narrow considered element types. If nothing is passed, an empty dict is passed to pp_elements(), by default None
- Returns:
number of elements per element type existing in the net
- Return type:
pd.Series
See also
count_group_elementsExamples
>>> from pandapower import count_elements >>> from pandapower.networks.power_system_test_cases import case9 >>> count_elements(case9(), bus_elements=False) bus 9 line 9 dtype: int32
- pandapower.toolbox.get_gc_objects_dict()
This function is based on the code in mem_top module Summarize object types that are tracket by the garbage collector in the moment. Useful to test if there are memoly leaks. :return: dictionary with keys corresponding to types and values to the number of objects of the type
Data Modification
- pandapower.toolbox.add_column_from_node_to_elements(net, column, replace, elements=None, branch_bus=None, verbose=True)
Adds column data to elements, inferring them from the column data of buses they are connected to.
- Parameters:
**net** (pandapowerNet)
**column** (string)
table
**replace** (boolean)
**elements** (list)
**branch_bus** (list)
'to_bus' ('branch_bus' must have the length of 2. One entry must be 'from_bus' or)
the
'lv_bus' (other 'hv_bus' or)
Example
compare to add_zones_to_elements()
- pandapower.toolbox.add_column_from_element_to_elements(net, column, replace, elements=None, continue_on_missing_column=True)
Adds column data to elements, inferring them from the column data of the elements linked by the columns “element” and “element_type” or “et”.
- Parameters:
**net** (pandapowerNet)
**column** (string)
**replace** (boolean)
**elements** (list)
None (element tables. If)
or (all elements with the columns "element" and "element_type")
considered ("et" are)
**continue_on_missing_column** (Boolean, True)
'elements'. (an element table has no column 'column' although this element is refered in)
but (E.g. 'measurement' is in 'elements' and in net.measurement is a trafo measurement)
case (in net.trafo there is no column 'name' although column=='name' - ni this)
acts. ('continue_on_missing_column')
Example
>>> from pandapower.create import create_measurement >>> from pandapower import add_column_from_element_to_elements >>> from pandapower.networks.cigre_networks import create_cigre_network_mv >>> net = create_cigre_network_mv() >>> create_measurement(net, "i", "trafo", 5, 3, 0, side="hv") >>> create_measurement(net, "i", "line", 5, 3, 0, side="to") >>> create_measurement(net, "p", "bus", 5, 3, 2) >>> print(net.measurement.name.values, net.switch.name.values) >>> add_column_from_element_to_elements(net, "name", True) >>> print(net.measurement.name.values, net.switch.name.values)
- pandapower.toolbox.add_zones_to_elements(net, replace=True, elements=None, **kwargs)
Adds zones to elements, inferring them from the zones of buses they are connected to.
- pandapower.toolbox.reindex_buses(net, bus_lookup)
Changes the index of net.bus and considers the new bus indices in all other pandapower element tables.
- Parameters:
network (**net** - pandapower)
**bus_lookup** (dict)
- pandapower.toolbox.create_continuous_bus_index(net, start=0, store_old_index=False)
Creates a continuous bus index starting at ‘start’ and replaces all references of old indices by the new ones.
- Parameters:
network (**net** - pandapower)
"start" (**start** - index begins with)
True (**store_old_index** - if)
net.bus["old_index"] (stores the old index in)
- Returns:
bus_lookup - mapping of old to new index
- pandapower.toolbox.reindex_elements(net, element_type, new_indices=None, old_indices=None, lookup=None)
Changes the index of the DataFrame net[element_type].
- Parameters:
net (pp.pandapowerNet) – net with elements to reindex
element_type (str) – name of element type to rename, e.g. “gen” or “load”
new_indices (Union[list[int], pandas.Index[int]], optional) – new indices to set, by default None
old_indices (Union[list[int], pandas.Index[int]], optional) – old indices to be replaced. If not given, all indices are assumed in case of given new_indices, and all lookup keys are assumed in case of given lookup, by default None
lookup (dict[int,int], optional) – lookup to assign new indices to old indices, by default None
Notes
Either new_indices or lookup must be given. old_indices can be given to limit the indices to be replaced. In case of given new_indices, both must have the same length. If element_type is “group”, be careful to give new_indices without passing old_indices because group indices do not need to be unique.
Examples
>>> net = pp.create_empty_network() >>> idx0 = pp.create_bus(net, 110) >>> idx1 = 4 >>> idx2 = 7 >>> # Reindex using 'new_indices': >>> pp.reindex_elements(net, "bus", [idx1]) # passing old_indices=[idx0] is optional >>> net.bus.index Int64Index([4], dtype='int64') >>> # Reindex using 'lookup': >>> pp.reindex_elements(net, "bus", lookup={idx1: idx2}) Int64Index([7], dtype='int64')
- pandapower.toolbox.create_continuous_elements_index(net, start=0, add_df_to_reindex=set())
Creating a continuous index for all the elements, starting at zero and replaces all references of old indices by the new ones.
- Parameters:
indices (**net** - pandapower network with unodered)
"start" (**start** - index begins with)
be (**add_df_to_reindex** - by default all useful pandapower elements for power flow will)
here. (selected. Customized DataFrames can also be considered)
- Returns:
net - pandapower network with odered and continuous indices
- pandapower.toolbox.set_scaling_by_type(net, scalings, scale_load=True, scale_sgen=True)
Sets scaling of loads and/or sgens according to a dictionary mapping type to a scaling factor. Note that the type-string is case sensitive. E.g. scaling = {“pv”: 0.8, “bhkw”: 0.6}
- Parameters:
net
scalings – A dictionary containing a mapping from element type to
scale_load
scale_sgen
- pandapower.toolbox.set_data_type_of_columns_to_default(net)
Overwrites dtype of DataFrame columns of PandapowerNet elements to default dtypes defined in pandapower. The function “convert_format” does that authomatically for nets saved with pandapower versions below 1.6. If this is required for versions starting with 1.6, it should be done manually with this function.
- Parameters:
indices (**net** - pandapower network with unodered)
- Returns:
No output; the net passed as input has pandapower-default dtypes of columns in element tables.
- pandapower.toolbox.get_inner_branches(net, buses, branch_elements=None)
Returns indices of branches that connects buses within ‘buses’ at all branch sides (e.g. ‘from_bus’ and ‘to_bus’).
Electric Grid Modification
- pandapower.toolbox.select_subnet(net, buses, include_switch_buses=False, include_results=False, keep_everything_else=False)
Selects a subnet by a list of bus indices and returns a net with all elements connected to them.
- pandapower.toolbox.merge_nets(net1, net2, validate=True, merge_results=True, tol=1e-9, **kwargs)
Function to concatenate two nets into one data structure. The elements keep their indices unless both nets have the same indices. In that case, net2 elements get reindexed. The reindex lookup of net2 elements can be retrieved by passing return_net2_reindex_lookup=True.
- Parameters:
net1 (pp.pandapowerNet) – first net to concatenate
net2 (pp.pandapowerNet) – second net to concatenate
validate (bool, optional) – whether power flow results should be compared against the results of the input nets, by default True
merge_results (bool, optional) – whether results tables should be concatenated, by default True
tol (float, optional) – tolerance which is allowed to pass the results validate check (relevant if validate is True), by default 1e-9
std_prio_on_net1 (bool, optional) – whether net1 standard type should be kept if net2 has types with same names, by default True
return_net2_reindex_lookup (bool, optional) – if True, the merged net AND a dict of lookups is returned, by default False
net2_reindex_log_level (str, optional) – logging level of the message which element types of net2 got reindexed elements. Options are, for example “debug”, “info”, “warning”, “error”, or None, by default “info”
- Returns:
net with concatenated element tables
- Return type:
pp.pandapowerNet
- Raises:
UserWarning – if validate is True and power flow results of the merged net deviate from input nets results
- pandapower.toolbox.set_element_status(net, buses, in_service)
Sets buses and all elements connected to them in or out of service.
- pandapower.toolbox.set_isolated_areas_out_of_service(net, respect_switches=True)
Set all isolated buses and all elements connected to isolated buses out of service.
- pandapower.toolbox.repl_to_line(net, idx, std_type, name=None, in_service=False, **kwargs)
creates a power line in parallel to the existing power line based on the values of the new std_type. The new parallel line has an impedance value, which is chosen so that the resulting impedance of the new line and the already existing line is equal to the impedance of the replaced line. Or for electrical engineers:
Z0 = impedance of the existing line
Z1 = impedance of the replaced line
Z2 = impedance of the created line
sketch:
--- Z2 --- ---| |--- = --- Z1 --- --- Z0 ---
- Parameters:
net (net - pandapower)
line (**kwargs - additional line parameters you want to set for the new)
type (std_type (str) - pandapower standard)
(str (name)
line
(bool (in_service)
service (False) - if the new power line is in)
line
- Return type:
new_idx (int) - index of the created power line
- pandapower.toolbox.merge_parallel_line(net, idx)
Changes the impedances of the parallel line so that it equals a single line.
Z0 = impedance of the existing parallel lines
Z1 = impedance of the respective single line
sketch:
--- Z0 --- ---| |--- = --- Z1 --- --- Z0 ---
- Parameters:
net (net - pandapower)
merge (idx (int) - idx of the line to)
- Return type:
net
- pandapower.toolbox.merge_same_bus_generation_plants(net, add_info=True, error=True, gen_elms=('ext_grid', 'gen', 'sgen'))
Merge generation plants connected to the same buses so that a maximum of one generation plants per node remains.
Attention
gen_elms should always be given in order of slack (1.), PV (2.) and PQ (3.) elements.
- Parameters:
net (**net** - pandapower)
**add_info** (bool, True)
a (elements dataframes. This column informs about which element table rows are the result of)
plants. (merge of generation)
**error** (bool, True)
**gen_elms** (list, ["ext_grid", "gen", "sgen"])
slack (buses. Should be in order of)
- pandapower.toolbox.close_switch_at_line_with_two_open_switches(net)
Finds lines that have opened switches at both ends and closes one of them. Function is usually used when optimizing section points to prevent the algorithm from ignoring isolated lines.
- pandapower.toolbox.fuse_buses(net, b1, b2, drop=True, fuse_bus_measurements=True)
Reroutes any connections to buses in b2 to the given bus b1. Additionally drops the buses b2, if drop=True (default).
Dropping Elements
- pandapower.toolbox.drop_elements(net, element_type, element_index, **kwargs)
Drops element, result and group entries, as well as, associated elements from the pandapower net.
- pandapower.toolbox.drop_elements_simple(net, element_type, element_index)
Drops element, result and group entries from the pandapower net.
See also
drop_elementsproviding more generic usage (inter-element connections considered)
- pandapower.toolbox.drop_buses(net, buses, drop_elements=True)
Drops specified buses, their bus_geodata and by default drops all elements connected to them as well.
- pandapower.toolbox.drop_trafos(net, trafos, table='trafo')
Deletes all trafos and in the given list of indices and removes any switches connected to it.
- pandapower.toolbox.drop_lines(net, lines)
Deletes all lines and their geodata in the given list of indices and removes any switches connected to it.
- pandapower.toolbox.drop_elements_at_buses(net, buses, bus_elements=True, branch_elements=True, drop_measurements=True)
drop elements connected to given buses
- pandapower.toolbox.drop_switches_at_buses(net, buses)
- pandapower.toolbox.drop_measurements_at_elements(net, element_type, idx=None, side=None)
Drop measurements of given element_type and (if given) given elements (idx) and side.
- pandapower.toolbox.drop_controllers_at_elements(net, element_type, idx=None)
Drop all the controllers for the given elements (idx).
- pandapower.toolbox.drop_controllers_at_buses(net, buses)
Drop all the controllers for the elements connected to the given buses.
- pandapower.toolbox.drop_duplicated_measurements(net, buses=None, keep='first')
Drops duplicated measurements at given set of buses. If buses is None, all buses are considered.
- pandapower.toolbox.drop_inner_branches(net, buses, branch_elements=None)
Drops branches that connects buses within ‘buses’ at all branch sides (e.g. ‘from_bus’ and ‘to_bus’).
- pandapower.toolbox.drop_out_of_service_elements(net)
Drop all elements (including corresponding dataframes such as switches, measurements, result tables, geodata) with “in_service” is False. Buses that are connected to in-service branches are not deleted.
- pandapower.toolbox.drop_inactive_elements(net, respect_switches=True)
Drops any elements not in service AND any elements connected to inactive buses.
Replacing Elements
- pandapower.toolbox.create_replacement_switch_for_branch(net, element_type, element_index)
Creates a switch parallel to a branch, connecting the same buses as the branch. The switch is closed if the branch is in service and open if the branch is out of service. The in_service status of the original branch is not affected and should be set separately, if needed.
- Parameters:
net – pandapower network
element_type – element_type table e. g. ‘line’, ‘impedance’
element_index – index of the branch e. g. 0
- Returns:
None
- pandapower.toolbox.replace_zero_branches_with_switches(net, elements=('line', 'impedance'), zero_length=True, zero_impedance=True, in_service_only=True, min_length_km=0, min_r_ohm_per_km=0, min_x_ohm_per_km=0, min_c_nf_per_km=0, min_rft_pu=0, min_xft_pu=0, min_rtf_pu=0, min_xtf_pu=0, drop_affected=False)
Creates a replacement switch for branches with zero impedance (line, impedance) and sets them out of service.
- Parameters:
net – pandapower network
elements – a tuple of names of element tables e. g. (‘line’, ‘impedance’) or (line)
zero_length – whether zero length lines will be affected
zero_impedance – whether zero impedance branches will be affected
in_service_only – whether the branches that are not in service will be affected
drop_affected – wheter the affected branch elements are dropped
min_length_km – threshhold for line length for a line to be considered zero line
min_r_ohm_per_km – threshhold for line R’ value for a line to be considered zero line
min_x_ohm_per_km – threshhold for line X’ value for a line to be considered zero line
min_c_nf_per_km – threshhold for line C’ for a line to be considered zero line
min_rft_pu – threshhold for R from-to value for impedance to be considered zero impedance
min_xft_pu – threshhold for X from-to value for impedance to be considered zero impedance
min_rtf_pu – threshhold for R to-from value for impedance to be considered zero impedance
min_xtf_pu – threshhold for X to-from value for impedance to be considered zero impedance
- Returns:
- pandapower.toolbox.replace_impedance_by_line(net, index=None, only_valid_replace=True, max_i_ka=np.nan)
Creates lines by given impedances data, while the impedances are dropped.
- Parameters:
net (**net** - pandapower)
**index** (index, None)
replaced. (will be)
**only_valid_replace** (bool, True)
False (replacement leads to equal power flow results. If)
will (unsymmetric impedances)
lines. (be replaced by symmetric)
**max_i_ka** (value(s), False)
given
considered. (the sn_mva values of the impedances are)
- pandapower.toolbox.replace_line_by_impedance(net, index=None, sn_mva=None, only_valid_replace=True)
Creates impedances by given lines data, while the lines are dropped.
- Parameters:
net (**net** - pandapower)
**index** (index, None)
replaced. (will be)
**sn_kva** (list or array, None)
assumed (the net.sn_kva is)
**only_valid_replace** (bool, True)
False (leads to equal power flow results. If)
will (capacitance and dielectric conductance)
neglected. (be)
- pandapower.toolbox.replace_ext_grid_by_gen(net, ext_grids=None, gen_indices=None, slack=False, cols_to_keep=None, add_cols_to_keep=None)
Replaces external grids by generators.
- Parameters:
net (**net** - pandapower)
**ext_grids** (iterable)
**gen_indices** (iterable)
**slack** (bool, False)
generators
**cols_to_keep** (list, None)
exist (ext_grids. If None these columns are kept if values) – “max_p_mw”, “min_p_mw”,
"max_q_mvar"
given ("min_q_mvar". However cols_to_keep is)
set (these columns are always)
"bus"
"vm_pu"
"p_mw"
"name"
"in_service"
"controllable"
**add_cols_to_keep** (list, None)
ext_grids. ('cols_to_keep' to be kept while replacing)
- pandapower.toolbox.replace_gen_by_ext_grid(net, gens=None, ext_grid_indices=None, cols_to_keep=None, add_cols_to_keep=None)
Replaces generators by external grids.
- Parameters:
net (**net** - pandapower)
**gens** (iterable)
**ext_grid_indices** (iterable)
**cols_to_keep** (list, None)
exist (gens. If None these columns are kept if values) – “max_p_mw”, “min_p_mw”,
"max_q_mvar"
given ("min_q_mvar". However cols_to_keep is)
set (these columns are alway)
"bus"
"vm_pu"
"va_degree"
"name"
"in_service"
**add_cols_to_keep** (list, None)
gens. ('cols_to_keep' to be kept while replacing)
- pandapower.toolbox.replace_gen_by_sgen(net, gens=None, sgen_indices=None, cols_to_keep=None, add_cols_to_keep=None)
Replaces generators by static generators.
- Parameters:
net (**net** - pandapower)
**gens** (iterable)
**sgen_indices** (iterable)
**cols_to_keep** (list, None)
exist (gens. If None these columns are kept if values) – “max_p_mw”, “min_p_mw”,
"max_q_mvar"
given ("min_q_mvar". However cols_to_keep is)
set (these columns are always)
"bus"
"p_mw"
"q_mvar"
"name"
"in_service"
"controllable"
**add_cols_to_keep** (list, None)
gens. ('cols_to_keep' to be kept while replacing)
- pandapower.toolbox.replace_sgen_by_gen(net, sgens=None, gen_indices=None, cols_to_keep=None, add_cols_to_keep=None)
Replaces static generators by generators.
- Parameters:
net (**net** - pandapower)
**sgens** (iterable)
**gen_indices** (iterable)
**cols_to_keep** (list, None)
exist (sgens. If None these columns are kept if values) – “max_p_mw”, “min_p_mw”,
"max_q_mvar"
given ("min_q_mvar". However cols_to_keep is)
set (these columns are always)
"bus"
"vm_pu"
"p_mw"
"name"
"in_service"
"controllable"
**add_cols_to_keep** (list, None)
sgens. ('cols_to_keep' to be kept while replacing)
- pandapower.toolbox.replace_pq_elmtype(net, old_element_type, new_element_type, old_indices=None, new_indices=None, cols_to_keep=None, add_cols_to_keep=None)
Replaces e.g. static generators by loads or loads by storages and so forth.
- Parameters:
net (**net** - pandapower)
**old_element_type** (str) – “sgen”, “load”, “storage”]
**new_element_type** (str) – “sgen”, “load”, “storage”]
**old_indices** (iterable)
**new_indices** (iterable)
**cols_to_keep** (list, None)
exist (If None these columns are kept if values) – “max_p_mw”, “min_p_mw”,
"max_q_mvar"
given ("min_q_mvar". Independent whether cols_to_keep is)
are (these columns)
set (always) – “bus”, “p_mw”, “q_mvar”, “name”, “in_service”, “controllable”
**add_cols_to_keep** (list, None)
replacing. ('cols_to_keep' to be kept while)
- Returns:
new_idx (list) - list of indices of the new elements
- pandapower.toolbox.replace_ward_by_internal_elements(net, wards=None)
Replaces wards by loads and shunts.
- Parameters:
net (**net** - pandapower)
**wards** (iterable)
- Returns:
No output - the given wards in pandapower net are replaced by loads and shunts
- pandapower.toolbox.replace_xward_by_internal_elements(net, xwards=None, set_xward_bus_limits=False)
Replaces xward by loads, shunts, impedance and generators
- Parameters:
net (pandapowerNet) – pandapower net
xwards (iterable, optional) – indices of xwards which should be replaced. If None, all xwards are replaced, by default None
set_xward_bus_limits (bool, optional) – if True, the buses internal in xwards get vm limits from the connected buses
- Returns:
the given xwards in pandapower are replaced by buses, loads, shunts, impadance and generators
- Return type:
None