edisgo.tools.tools

Module Contents

Functions

select_worstcase_snapshots(edisgo_obj)

Select two worst-case snapshots from time series

calculate_relative_line_load(edisgo_obj[, lines, ...])

Calculates relative line loading for specified lines and time steps.

calculate_line_reactance(line_inductance_per_km, ...)

Calculates line reactance in Ohm.

calculate_line_resistance(line_resistance_per_km, ...)

Calculates line resistance in Ohm.

calculate_line_susceptance(line_capacitance_per_km, ...)

Calculates line shunt susceptance in Siemens.

calculate_apparent_power(nominal_voltage, current, ...)

Calculates apparent power in MVA from given voltage and current.

drop_duplicated_indices(dataframe[, keep])

Drop rows of duplicate indices in dataframe.

drop_duplicated_columns(df[, keep])

Drop columns of dataframe that appear more than once.

select_cable(edisgo_obj, level, apparent_power)

Selects suitable cable type and quantity using given apparent power.

assign_feeder(edisgo_obj[, mode])

Assigns MV or LV feeder to each bus and line, depending on the mode.

get_path_length_to_station(edisgo_obj)

Determines path length from each bus to HV-MV station.

get_downstream_buses(edisgo_obj, comp_name[, comp_type])

Returns all buses downstream (farther away from station) of the given bus or line.

assign_voltage_level_to_component(df, buses_df)

Adds column with specification of voltage level component is in.

get_weather_cells_intersecting_with_grid_district(...)

Get all weather cells that intersect with the grid district.

get_directory_size(start_dir)

Calculates the size of all files within the start path.

get_files_recursive(path[, files])

Recursive function to get all files in a given path and its sub directories.

add_line_susceptance(edisgo_obj[, mode])

Adds line susceptance information in Siemens to lines in existing grids.

resample(object, freq_orig[, method, freq])

Resamples all time series data in given object to a desired resolution.

edisgo.tools.tools.select_worstcase_snapshots(edisgo_obj)[source]

Select two worst-case snapshots from time series

Two time steps in a time series represent worst-case snapshots. These are

  1. Maximum Residual Load: refers to the point in the time series where the

    (load - generation) achieves its maximum.

  2. Minimum Residual Load: refers to the point in the time series where the

    (load - generation) achieves its minimum.

These two points are identified based on the generation and load time series. In case load or feed-in case don’t exist None is returned.

Parameters

edisgo_obj (EDisGo) –

Returns

Dictionary with keys ‘min_residual_load’ and ‘max_residual_load’. Values are corresponding worst-case snapshots of type pandas.Timestamp.

Return type

dict

edisgo.tools.tools.calculate_relative_line_load(edisgo_obj, lines=None, timesteps=None)[source]

Calculates relative line loading for specified lines and time steps.

Line loading is calculated by dividing the current at the given time step by the allowed current.

Parameters
  • edisgo_obj (EDisGo) –

  • lines (list(str) or None, optional) – Line names/representatives of lines to calculate line loading for. If None, line loading is calculated for all lines in the network. Default: None.

  • timesteps (pandas.Timestamp or list(pandas.Timestamp) or None, optional) – Specifies time steps to calculate line loading for. If timesteps is None, all time steps power flow analysis was conducted for are used. Default: None.

Returns

Dataframe with relative line loading (unitless). Index of the dataframe is a pandas.DatetimeIndex, columns are the line representatives.

Return type

pandas.DataFrame

edisgo.tools.tools.calculate_line_reactance(line_inductance_per_km, line_length, num_parallel)[source]

Calculates line reactance in Ohm.

Parameters
  • line_inductance_per_km (float or array-like) – Line inductance in mH/km.

  • line_length (float) – Length of line in km.

  • num_parallel (int) – Number of parallel lines.

Returns

Reactance in Ohm

Return type

float

edisgo.tools.tools.calculate_line_resistance(line_resistance_per_km, line_length, num_parallel)[source]

Calculates line resistance in Ohm.

Parameters
  • line_resistance_per_km (float or array-like) – Line resistance in Ohm/km.

  • line_length (float) – Length of line in km.

  • num_parallel (int) – Number of parallel lines.

Returns

Resistance in Ohm

Return type

float

edisgo.tools.tools.calculate_line_susceptance(line_capacitance_per_km, line_length, num_parallel)[source]

Calculates line shunt susceptance in Siemens.

Parameters
  • line_capacitance_per_km (float) – Line capacitance in uF/km.

  • line_length (float) – Length of line in km.

  • num_parallel (int) – Number of parallel lines.

Returns

Shunt susceptance in Siemens.

Return type

float

edisgo.tools.tools.calculate_apparent_power(nominal_voltage, current, num_parallel)[source]

Calculates apparent power in MVA from given voltage and current.

Parameters
  • nominal_voltage (float or array-like) – Nominal voltage in kV.

  • current (float or array-like) – Current in kA.

  • num_parallel (int or array-like) – Number of parallel lines.

Returns

Apparent power in MVA.

Return type

float

edisgo.tools.tools.drop_duplicated_indices(dataframe, keep='first')[source]

Drop rows of duplicate indices in dataframe.

Parameters
  • dataframe (pandas.DataFrame) – handled dataframe

  • keep (str) – indicator of row to be kept, ‘first’, ‘last’ or False, see pandas.DataFrame.drop_duplicates() method

edisgo.tools.tools.drop_duplicated_columns(df, keep='first')[source]

Drop columns of dataframe that appear more than once.

Parameters
  • df (pandas.DataFrame) – Dataframe of which columns are dropped.

  • keep (str) – Indicator of whether to keep first (‘first’), last (‘last’) or none (False) of the duplicated columns. See drop_duplicates() method of pandas.DataFrame.

edisgo.tools.tools.select_cable(edisgo_obj, level, apparent_power)[source]

Selects suitable cable type and quantity using given apparent power.

Cable is selected to be able to carry the given apparent_power, no load factor is considered. Overhead lines are not considered in choosing a suitable cable.

Parameters
  • edisgo_obj (EDisGo) –

  • level (str) – Grid level to get suitable cable for. Possible options are ‘mv’ or ‘lv’.

  • apparent_power (float) – Apparent power the cable must carry in MVA.

Returns

  • pandas.Series – Series with attributes of selected cable as in equipment data and cable type as series name.

  • int – Number of necessary parallel cables.

edisgo.tools.tools.assign_feeder(edisgo_obj, mode='mv_feeder')[source]

Assigns MV or LV feeder to each bus and line, depending on the mode.

The feeder name is written to a new column mv_feeder or lv_feeder in Topology’s buses_df and lines_df. The MV respectively LV feeder name corresponds to the name of the first bus in the respective feeder.

Parameters
  • edisgo_obj (EDisGo) –

  • mode (str) – Specifies whether to assign MV or LV feeder. Valid options are ‘mv_feeder’ or ‘lv_feeder’. Default: ‘mv_feeder’.

edisgo.tools.tools.get_path_length_to_station(edisgo_obj)[source]

Determines path length from each bus to HV-MV station.

The path length is written to a new column path_length_to_station in buses_df dataframe of Topology class.

Parameters

edisgo_obj (EDisGo) –

Returns

Series with bus name in index and path length to station as value.

Return type

pandas.Series

edisgo.tools.tools.get_downstream_buses(edisgo_obj, comp_name, comp_type='bus')[source]

Returns all buses downstream (farther away from station) of the given bus or line.

In case a bus is given, returns all buses downstream of the given bus plus the given bus itself. In case a line is given, returns all buses downstream of the bus that is closer to the station (thus only one bus of the line is included in the returned buses).

Parameters
  • edisgo_obj (EDisGo object) –

  • comp_name (str) – Name of bus or line (as in index of buses_df or lines_df) to get downstream buses for.

  • comp_type (str) – Can be either ‘bus’ or ‘line’. Default: ‘bus’.

Returns

List of buses (as in index of buses_df) downstream of the given component.

Return type

list(str)

edisgo.tools.tools.assign_voltage_level_to_component(df, buses_df)[source]

Adds column with specification of voltage level component is in.

The voltage level (‘mv’ or ‘lv’) is determined based on the nominal voltage of the bus the component is connected to. If the nominal voltage is smaller than 1 kV, voltage level ‘lv’ is assigned, otherwise ‘mv’ is assigned.

Parameters
  • df (pandas.DataFrame) – Dataframe with component names in the index. Only required column is column ‘bus’, giving the name of the bus the component is connected to.

  • buses_df (pandas.DataFrame) – Dataframe with bus information. Bus names are in the index. Only required column is column ‘v_nom’, giving the nominal voltage of the voltage level the bus is in.

Returns

Same dataframe as given in parameter df with new column ‘voltage_level’ specifying the voltage level the component is in (either ‘mv’ or ‘lv’).

Return type

pandas.DataFrame

edisgo.tools.tools.get_weather_cells_intersecting_with_grid_district(edisgo_obj)[source]

Get all weather cells that intersect with the grid district.

Parameters

edisgo_obj (EDisGo) –

Returns

Set with weather cell IDs

Return type

set

edisgo.tools.tools.get_directory_size(start_dir)[source]

Calculates the size of all files within the start path.

Walks through all files and sub-directories within a given directory and calculate the sum of size of all files in the directory. See also stackoverflow.

Parameters

start_dir (str) – Start path.

Returns

Size of the directory.

Return type

int

edisgo.tools.tools.get_files_recursive(path, files=None)[source]

Recursive function to get all files in a given path and its sub directories.

Parameters
  • path (str) – Directory to start from.

  • files (list, optional) – List of files to start with. Default: None.

edisgo.tools.tools.add_line_susceptance(edisgo_obj, mode='mv_b')[source]

Adds line susceptance information in Siemens to lines in existing grids.

Parameters
  • edisgo_obj (EDisGo) – EDisGo object to which line susceptance information is added.

  • mode (str) –

    Defines how the susceptance is added:

    • ’no_b’

      Susceptance is set to 0 for all lines.

    • ’mv_b’ (Default)

      Susceptance is for the MV lines set according to the equipment parameters and for the LV lines it is set to zero.

    • ’all_b’

      Susceptance is for the MV lines set according to the equipment parameters and for the LV lines 0.25 uF/km is chosen.

Return type

EDisGo

edisgo.tools.tools.resample(object, freq_orig, method: str = 'ffill', freq: str | pd.Timedelta = '15min')[source]

Resamples all time series data in given object to a desired resolution.

Parameters