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.

Note

If you implement a function that might be useful for others, it is mandatory to add a short docstring to make browsing the toolbox practical. Ideally further comments if appropriate and a reference of authorship should be added as well.

Result Information

pandapower.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).

OPTIONAL:

numv (integer, 1) - maximal number of printed maximal respectively minimal voltages

numi (integer, 2) - maximal number of printed maximal loading at trafos or lines

pandapower.opf_task(net)

Prints some basic inforamtion of the optimal powerflow task.

pandapower.switch_info(net, sidx)

Prints what buses and elements are connected by a certain switch.

pandapower.overloaded_lines(net, max_load=100)

Returns the results for all lines with loading_percent > max_load or None, if there are none.

pandapower.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.nets_equal(net1, net2, check_only_results=False, exclude_elms=None, **kwargs)

Compares the DataFrames of two networks. The networks are considered equal if they share the same keys and values, except of the ‘et’ (elapsed time) entry which differs depending on runtime conditions and entries stating with ‘_’.

Simulation Setup and Preparation

pandapower.convert_format(net)

Converts old nets to new format to ensure consistency. The converted net is returned.

pandapower.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.create_continuous_bus_index(net, start=0)

Creates a continuous bus index starting at zero and replaces all references of old indices by the new ones.

pandapower.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

Topology Modification

pandapower.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.drop_inactive_elements(net, respect_switches=True)

Drops any elements not in service AND any elements connected to inactive buses.

pandapower.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.drop_trafos(net, trafos, table='trafo')

Deletes all trafos and in the given list of indices and removes any switches connected to it.

pandapower.drop_lines(net, lines)

Deletes all lines and their geodata in the given list of indices and removes any switches connected to it.

pandapower.fuse_buses(net, b1, b2, drop=True)

Reroutes any connections to buses in b2 to the given bus b1. Additionally drops the buses b2, if drop=True (default).

pandapower.set_element_status(net, buses, in_service)

Sets buses and all elements connected to them in or out of service.

pandapower.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.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.

Item/Element Selection

pandapower.get_element_index(net, element, name, exact_match=True)

Returns the element(s) identified by a name or regex and its element-table.

INPUT:

net - pandapower network

element - Table to get indices from (“line”, “bus”, “trafo” etc.)

name - Name of the element to match.

OPTIONAL:
exact_match (boolean, True) - True: Expects exactly one match, raises
UserWarning otherwise.

False: returns all indices containing the name

OUTPUT:
index - The indices of matching element(s).
pandapower.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.

pandapower.get_connected_elements(net, element, buses, respect_switches=True, respect_in_service=False)

Returns elements connected to a given bus.

INPUT:

net (pandapowerNet)

element (string, name of the element table)

buses (single integer or iterable of ints)

OPTIONAL:
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

OUTPUT:
connected_elements (set) - Returns connected elements.
pandapower.get_connected_buses(net, buses, consider=('l', 's', 't', 't3'), respect_switches=True, respect_in_service=False)

Returns buses connected to given buses. The source buses will NOT be returned.

INPUT:

net (pandapowerNet)

buses (single integer or iterable of ints)

OPTIONAL:
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”)) - Determines, which types of connections will
be will be considered. l: lines s: switches t: trafos
OUTPUT:
cl (set) - Returns connected buses.
pandapower.get_connected_switches(net, buses, consider=('b', 'l', 't'), status='all')

Returns switches connected to given buses.

INPUT:

net (pandapowerNet)

buses (single integer or iterable of ints)

OPTIONAL:
consider (iterable, (“l”, “s”, “t”)) - Determines, which types of connections
will be considered. l: lines b: bus-bus-switches t: trafos
status (string, (“all”, “closed”, “open”)) - Determines, which switches will
be considered
OUTPUT:
cl (set) - Returns connected switches.