Toolbox

The pandapipes toolbox is a collection of helper functions that are implemented for the pandapipes 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.

There are many similarities to the pandapower toolbox functions (c.f. this chapter in the pandapower documentation), but not all functions are transferred to pandapipes. If you want to extend the toolbox, feel free to open a new pull request.

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.

General Issues

Result and Net Information

Simulation Setup and Preparation

Topology Modification

pandapower toolbox functions

Some toolbox functions can be used directly from pandapower, for example:

clear_result_tables(net)

Clears all res_ DataFrames in net.

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.

dataframes_equal(df1, df2, ignore_index_order=True, **kwargs)

Returns a boolean whether the given two dataframes are equal or not.

drop_elements_simple(net, element, idx)

Drop elements and result entries from pandapower net.

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

get_element_indices(net, element, 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()

INPUT:

net - pandapower network

element (str, string iterable) - Element table to get indices from (“line”, “bus”, “trafo” etc.).

name (str) - 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 (list) - List of the indices of matching element(s).

EXAMPLE:
>>> import pandapower.networks as pn
>>> import pandapower as pp
>>> net = pn.example_multivoltage()
>>> idx1 = pp.get_element_indices(net, "bus", ["Bus HV%i" % i for i in range(1, 4)])
>>> idx2 = pp.get_element_indices(net, ["bus", "line"], "HV", exact_match=False)
>>> idx3 = pp.get_element_indices(net, ["bus", "line"], ["Bus HV3", "MV Line6"])
ensure_iterability(var, len_=None)

Ensures iterability of a variable (and optional length).