edisgo.tools.tools
¶
Module Contents¶
Functions¶
|
Select two worst-case snapshots from time series |
|
Calculates relative line loading for specified lines and time steps. |
|
Calculates line reactance in Ohm. |
|
Calculates line resistance in Ohm. |
|
Calculates line shunt susceptance in Siemens. |
|
Calculates apparent power in MVA from given voltage and current. |
|
Drop rows of duplicate indices in dataframe. |
|
Drop columns of dataframe that appear more than once. |
|
Selects suitable cable type and quantity using given apparent power. |
|
Assigns MV or LV feeder to each bus and line, depending on the mode. |
|
Determines path length from each bus to HV-MV station. |
|
Returns all buses downstream (farther away from station) of the given bus or line. |
|
Adds column with specification of voltage level component is in. |
Get all weather cells that intersect with the grid district. |
|
|
Calculates the size of all files within the start path. |
|
Recursive function to get all files in a given path and its sub directories. |
|
Adds line susceptance information in Siemens to lines in existing grids. |
|
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
- Maximum Residual Load: refers to the point in the time series where the
(load - generation) achieves its maximum.
- 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
- 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
- edisgo.tools.tools.calculate_line_reactance(line_inductance_per_km, line_length, num_parallel)[source]¶
Calculates line reactance in Ohm.
- edisgo.tools.tools.calculate_line_resistance(line_resistance_per_km, line_length, num_parallel)[source]¶
Calculates line resistance in Ohm.
- edisgo.tools.tools.calculate_line_susceptance(line_capacitance_per_km, line_length, num_parallel)[source]¶
Calculates line shunt susceptance in Siemens.
- edisgo.tools.tools.calculate_apparent_power(nominal_voltage, current, num_parallel)[source]¶
Calculates apparent power in MVA from given voltage and current.
- 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
- 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
’sbuses_df
andlines_df
. The MV respectively LV feeder name corresponds to the name of the first bus in the respective 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
- 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
- Returns
List of buses (as in index of
buses_df
) downstream of the given component.- Return type
- 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
- edisgo.tools.tools.get_weather_cells_intersecting_with_grid_district(edisgo_obj)[source]¶
Get all weather cells that intersect with the grid district.
- 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.
- edisgo.tools.tools.get_files_recursive(path, files=None)[source]¶
Recursive function to get all files in a given path and its sub directories.
- 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.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
object (
TimeSeries
) – Object of which to resample time series data.freq_orig (pandas.Timedelta) – Frequency of original time series data.
method (str, optional) – See method parameter in
resample_timeseries
for more information.freq (str, optional) – See freq parameter in
resample_timeseries
for more information.