etrago.tools package

etrago.tools.calc_results module

calc_results.py defines methods to calculate results of eTraGo

etrago.tools.calc_results.calc_investment_cost(self)[source]

Function that calulates overall annualized investment costs.

Returns

  • network_costs (float) – Investments in line expansion (AC+DC)

  • link_costs (float) – Investments in sectorcoupling link expansion

  • stor_costs (float) – Investments in storage and store expansion

etrago.tools.calc_results.calc_marginal_cost(self)[source]

Function that caluclates and returns marginal costs, considering generation and link and storage dispatch costs

Returns

marginal_cost – Annual marginal cost in EUR

Return type

float

etrago.tools.calc_results.calc_etrago_results(self)[source]

Function that calculates main results of grid optimization and adds them to Etrago object.

Return type

None.

etrago.tools.constraints module

Constraints.py includes additional constraints for eTraGo-optimizations

etrago.tools.constraints.read_max_gas_generation(self)[source]

Return the values limiting the gas production in Germany

Read max_gas_generation_overtheyear from scenario.egon_scenario_parameters if the table is available in the database and return the dictionnary containing the values needed for the constraints to limit the gas production in Germany, depending of the scenario.

Returns

arg

Return type

dict

etrago.tools.constraints.add_ch4_constraints(self, network, snapshots)[source]

Add CH4 constraints for optimization with pyomo

Functionality that limits the dispatch of CH4 generators. In Germany, there is one limitation specific for biogas and one limitation specific for natural gas (natural gas only in eGon2035). Abroad, each generator has its own limitation contains in the column e_nom_max.

Parameters
  • network (pypsa.Network) – Overall container of PyPSA

  • snapshots (pandas.DatetimeIndex) – List of timesteps considered in the optimization

Return type

None.

etrago.tools.constraints.add_ch4_constraints_nmp(self, network, snapshots)[source]

Add CH4 constraints for optimization without pyomo

Functionality that limits the dispatch of CH4 generators. In Germany, there is one limitation specific for biogas and one limitation specific for natural gas (natural gas only in eGon2035). Abroad, each generator has its own limitation contains in the column e_nom_max.

Parameters
  • network (pypsa.Network) – Overall container of PyPSA

  • snapshots (pandas.DatetimeIndex) – List of timesteps considered in the optimization

Return type

None.

etrago.tools.constraints.snapshot_clustering_daily_bounds(self, network, snapshots)[source]

Bound the storage level to 0.5 max_level every 24th hour.

Parameters
  • network (pypsa.Network) – Overall container of PyPSA

  • snapshots (pandas.DatetimeIndex) – List of timesteps that will be constrained

Return type

None

etrago.tools.constraints.snapshot_clustering_daily_bounds_nmp(self, network, snapshots)[source]

Bound the storage level to 0.5 max_level every 24th hour.

Parameters
  • network (pypsa.Network) – Overall container of PyPSA

  • snapshots (pandas.DatetimeIndex) – List of timesteps that will be constrained

Return type

None

etrago.tools.constraints.snapshot_clustering_seasonal_storage(self, network, snapshots, simplified=False)[source]

Depicts intertemporal dependencies of storage units and stores when using snapshot clustering to typical periods for temporal complexity reduction.

According to:

L. Kotzur et al: ‘Time series aggregation for energy system design: Modeling seasonal storage’, 2018

Parameters
  • network (pypsa.Network) – Overall container of PyPSA

  • snapshots (list) – A list of datetime objects representing the timestamps of the snapshots to be clustered.

  • simplified (bool, optional) – A flag indicating whether to use a simplified version of the model that does not include intra-temporal constraints and variables.

Return type

None

etrago.tools.constraints.snapshot_clustering_seasonal_storage_hourly(self, network, snapshots)[source]

Depicts intertemporal dependencies of storage units and stores when using snapshot clustering to typical periods for temporal complexity reduction.

According to:

L. Kotzur et al: ‘Time series aggregation for energy system design: Modeling seasonal storage’, 2018

Parameters
  • network (pypsa.Network) – Overall container of PyPSA

  • snapshots (list) – A list of datetime objects representing the timestamps of the snapshots to be clustered.

Return type

None

etrago.tools.constraints.snapshot_clustering_seasonal_storage_nmp(self, n, sns, simplified=False)[source]

Depicts intertemporal dependencies of storage units and stores when using snapshot clustering to typical periods for temporal complexity reduction.

According to:

L. Kotzur et al: ‘Time series aggregation for energy system design: Modeling seasonal storage’, 2018

Parameters
  • n (pypsa.Network) – Overall container of PyPSA

  • sns (list) – A list of datetime objects representing the timestamps of the snapshots to be clustered.

  • simplified (bool, optional) – A flag indicating whether to use a simplified version of the model that does not include intra-temporal constraints and variables.

Return type

None

etrago.tools.constraints.snapshot_clustering_seasonal_storage_hourly_nmp(self, n, sns)[source]

Depicts intertemporal dependencies of storage units and stores when using snapshot clustering to typical periods for temporal complexity reduction.

According to:

L. Kotzur et al: ‘Time series aggregation for energy system design: Modeling seasonal storage’, 2018

Parameters
  • n (pypsa.Network) – Overall container of PyPSA

  • sns (list) – A list of datetime objects representing the timestamps of the snapshots to be clustered.

Return type

None

etrago.tools.constraints.split_dispatch_disaggregation_constraints(self, n, sns)[source]

Add constraints for state of charge of storage units and stores when separating the optimization into smaller subproblems while conducting thedispatch_disaggregation in temporally fully resolved network

The state of charge at the end of each slice is set to the value calculated in the optimization with the temporally reduced network to account to ensure compatibility and to reproduce saisonality

Parameters
  • network (pypsa.Network) – Overall container of PyPSA

  • snapshots (pandas.DatetimeIndex) – List of timesteps considered in the optimization

Return type

None.

etrago.tools.constraints.split_dispatch_disaggregation_constraints_nmp(self, n, sns)[source]
class etrago.tools.constraints.Constraints(args, conduct_dispatch_disaggregation)[source]

Bases: object

Methods

functionality(network, snapshots)

Add constraints to pypsa-model using extra-functionality.

functionality(network, snapshots)[source]

Add constraints to pypsa-model using extra-functionality. Serveral constraints can be choosen at once. Possible constraints are set and described in the above functions.

Parameters
  • network (pypsa.Network) – Overall container of PyPSA

  • snapshots (pandas.DatetimeIndex) – List of timesteps considered in the optimization

etrago.tools.constraints.add_chp_constraints_nmp(n)[source]

Limits the dispatch of combined heat and power links based on T.Brown et. al : Synergies of sector coupling and transmission reinforcement in a cost-optimised, highly renewable European energy system, 2018

Parameters

n (pypsa.Network) – Network container

Return type

None.

etrago.tools.constraints.add_chp_constraints(network, snapshots)[source]

Limits the dispatch of combined heat and power links based on T.Brown et. al : Synergies of sector coupling and transmission reinforcement in a cost-optimised, highly renewable European energy system, 2018

Parameters
  • network (pypsa.Network) – Network container

  • snapshots (pandas.DataFrame) – Timesteps to optimize

Return type

None.

etrago.tools.execute module

execute.py defines optimization and simulation methods for the etrago object.

etrago.tools.execute.update_electrical_parameters(network, l_snom_pre, t_snom_pre)[source]

Update electrical parameters of active branch components considering s_nom of previous iteration.

Parameters
  • network (pypsa.Network object) – Container for all network components.

  • l_snom_pre (pandas.Series) – s_nom of ac-lines in previous iteration.

  • t_snom_pre (pandas.Series) – s_nom of transformers in previous iteration.

Return type

None.

etrago.tools.execute.run_lopf(etrago, extra_functionality, method)[source]

Function that performs lopf with or without pyomo

Parameters
  • etrago (etrago object) – eTraGo containing all network information and a PyPSA network.

  • extra_functionality (dict) – Define extra constranits.

  • method (dict) – Choose ‘n_iter’ and integer for fixed number of iterations or ‘threshold’ and derivation of objective in percent for variable number of iteration until the threshold of the objective function is reached.

Return type

None.

etrago.tools.execute.iterate_lopf(etrago, extra_functionality, method={'n_iter': 4, 'pyomo': True})[source]

Run optimization of lopf. If network extension is included, the specified number of iterations is calculated to consider reactance changes.

Parameters
  • etrago (etrago object) – eTraGo containing all network information and a PyPSA network.

  • extra_functionality (dict) – Define extra constranits.

  • method (dict) – Choose ‘n_iter’ and integer for fixed number of iterations or ‘threshold’ and derivation of objective in percent for variable number of iteration until the threshold of the objective function is reached.

etrago.tools.execute.lopf(self)[source]

Functions that runs lopf according to arguments.

Return type

None.

etrago.tools.execute.dispatch_disaggregation(self)[source]

Function running the tempral disaggregation meaning the optimization of dispatch in the temporally fully resolved network; therfore, the problem is reduced to smaller subproblems by slicing the whole considered time span while keeping inforation on the state of charge of storage units and stores to ensure compatibility and to reproduce saisonality.

Return type

None.

etrago.tools.execute.run_pf_post_lopf(self)[source]

Function that runs pf_post_lopf according to arguments.

Return type

None.

etrago.tools.execute.pf_post_lopf(etrago, calc_losses=False)[source]

Function that prepares and runs non-linar load flow using PyPSA pf. If crossborder lines are DC-links, pf is only applied on german network. Crossborder flows are still considerd due to the active behavior of links. To return a network containing the whole grid, the optimised solution of the foreign components can be added afterwards.

Parameters
  • etrago (etrago object) – eTraGo containing all network information and a PyPSA network.

  • add_foreign_lopf (boolean) – Choose if foreign results of lopf should be added to the network when foreign lines are DC.

  • q_allocation (str) – Choose allocation of reactive power. Possible settings are listed in distribute_q function.

  • calc_losses (bolean) – Choose if line losses will be calculated.

etrago.tools.execute.distribute_q(network, allocation='p_nom')[source]

Function that distributes reactive power at bus to all installed generators and storages.

Parameters
  • network (pypsa.Network object) – Container for all network components.

  • allocation (str) – Choose key to distribute reactive power: ‘p_nom’ to dirstribute via p_nom ‘p’ to distribute via p_set.

Return type

None.

etrago.tools.execute.calc_line_losses(network, converged)[source]

Calculate losses per line with PF result data.

Parameters
  • network (pypsa.Network object) – Container for all network components.

  • converged (pd.Series) – List of snapshots with their status (converged or not).

Return type

None.

etrago.tools.execute.set_slack(network)[source]

Function that chosses the bus with the maximum installed power as slack.

Parameters

network (pypsa.Network object) – Container for all network components.

Returns

network – Container for all network components.

Return type

pypsa.Network object

etrago.tools.extendable module

Extendable.py defines function to set PyPSA components extendable.

etrago.tools.extendable.extendable(self, grid_max_D=None, grid_max_abs_D={'110': {'circuits': 2, 'i': 1020, 'wires': 4}, '220': {'circuits': 4, 'i': 1020, 'wires': 4}, '380': {'circuits': 4, 'i': 1020, 'wires': 4}, 'dc': 0}, grid_max_foreign=4, grid_max_abs_foreign=None)[source]

Function that sets selected components extendable.

Parameters
  • grid_max_D (int, optional) – Upper bounds for electrical grid expansion relative to existing capacity. The default is None.

  • grid_max_abs_D (dict, optional) – Absolute upper bounds for electrical grid expansion in Germany.

  • grid_max_foreign (int, optional) – Upper bounds for expansion of electrical foreign lines relative to the existing capacity. The default is 4.

  • grid_max_abs_foreign (dict, optional) – Absolute upper bounds for expansion of foreign electrical grid. The default is None.

Return type

None.

etrago.tools.extendable.snommax(i=1020, u=380, wires=4, circuits=4)[source]

Function to calculate limitation for capacity expansion.

Parameters
  • i (int, optional) – Current. The default is 1020.

  • u (int, optional) – Voltage level. The default is 380.

  • wires (int, optional) – Number of wires per line. The default is 4.

  • circuits (int, optional) – Number of circuits. The default is 4.

Returns

s_nom_max – Limitation for capacity expansion.

Return type

float

etrago.tools.extendable.line_max_abs(network, buses, line_max_abs={'110': {'circuits': 2, 'i': 1020, 'wires': 4}, '220': {'circuits': 4, 'i': 1020, 'wires': 4}, '380': {'circuits': 4, 'i': 1020, 'wires': 4}, 'dc': 0})[source]

Function to calculate limitation for capacity expansion of lines in network.

Parameters
  • network (pypsa.Network object) – Container for all network components.

  • buses (pypsa.Network buses) – Considered buses in network.

  • line_max_abs (dict, optional) – Line parameters considered to calculate maximum capacity.

Return type

None.

etrago.tools.extendable.transformer_max_abs(network, buses)[source]

Function to calculate limitation for capacity expansion of transformers in network.

Parameters
  • network (pypsa.Network object) – Container for all network components.

  • buses (pypsa.Network buses) – Considered buses in network.

Return type

None.

etrago.tools.extendable.extension_preselection(etrago, method, days=3)[source]

Function that preselects lines which are extendend in snapshots leading to overloading to reduce nubmer of extension variables.

Parameters
  • network (pypsa.Network object) – Container for all network components.

  • args (dict) – Arguments set in appl.py.

  • method (str) – Choose method of selection: ‘extreme_situations’ for remarkable timsteps (e.g. minimal resiudual load) ‘snapshot_clustering’ for snapshot clustering with number of days

  • days (int) – Number of clustered days, only used when method = ‘snapshot_clustering’

Returns

network – Container for all network components.

Return type

pypsa.Network object

etrago.tools.extendable.print_expansion_costs(network)[source]

Function that prints network and storage investment costs.

Parameters

network (pypsa.Network object) – Container for all network components.

Return type

None.

etrago.tools.io module

io.py

Input/output operations between powerflow schema in the oedb and PyPSA. Additionally oedb wrapper classes to instantiate PyPSA network objects.

etrago.tools.io.packagename

Package containing orm class definitions

Type

str

etrago.tools.io.temp_ormclass

Orm class name of table with temporal resolution

Type

str

etrago.tools.io.carr_ormclass

Orm class name of table with carrier id to carrier name datasets

Type

str

Notes

A configuration file connecting the chosen optimization method with components to be queried is needed for NetworkScenario class.

class etrago.tools.io.ScenarioBase(engine, session, version=None)[source]

Bases: object

Base class to address the dynamic provision of orm classes representing powerflow components from egoio

Parameters
  • session (sqla.orm.session.Session) – Handles conversations with the database.

  • version (str) – Version number of data version control in grid schema of the oedb.

class etrago.tools.io.NetworkScenario(engine, session, scn_name='Status Quo', start_snapshot=1, end_snapshot=20, temp_id=1, **kwargs)[source]

Bases: ScenarioBase

Adapter class between oedb powerflow data and PyPSA. Provides the method build_network to generate a pypsa.Network.

Parameters
  • scn_name (str) – Scenario name.

  • method (str) – Objective function.

  • start_snapshot (int) – First snapshot or timestep.

  • end_snapshot (int) – Last timestep.

  • temp_id (int) – Nummer of temporal resolution.

Methods

build_network([network])

Core method to construct PyPSA Network object.

configure_timeindex()

Construct a DateTimeIndex with the queried temporal resolution, start- and end_snapshot.

fetch_by_relname(name)

Construct DataFrame with component data from filtered table data.

series_fetch_by_relname(network, name, ...)

Construct DataFrame with component timeseries data from filtered table data.

id_to_source

configure_timeindex()[source]

Construct a DateTimeIndex with the queried temporal resolution, start- and end_snapshot.

id_to_source()[source]
fetch_by_relname(name)[source]

Construct DataFrame with component data from filtered table data.

Parameters

name (str) – Component name.

Returns

Component data.

Return type

pd.DataFrame

series_fetch_by_relname(network, name, pypsa_name)[source]

Construct DataFrame with component timeseries data from filtered table data.

Parameters
  • name (str) – Component name.

  • column (str) – Component field with timevarying data.

Returns

Component data.

Return type

pd.DataFrame

build_network(network=None, *args, **kwargs)[source]

Core method to construct PyPSA Network object.

etrago.tools.io.clear_results_db(session)[source]

Used to clear the result tables in the OEDB. Caution! This deletes EVERY RESULT SET!

etrago.tools.io.results_to_oedb(session, network, args, grid='hv', safe_results=False)[source]

Return results obtained from PyPSA to oedb

Parameters
  • session

  • network (PyPSA network container) – Holds topology of grid including results from powerflow analysis

  • args (dict) – Settings from appl.py

  • grid (str) – Choose voltage-level, currently only ‘hv’ implemented

  • safe_results (boolean) – If it is set to ‘True’ the result set will be saved to the versioned grid schema eventually apart from being saved to the model_draft by a SQL-script. ONLY set to True if you know what you are doing.

etrago.tools.io.run_sql_script(conn, scriptname='results_md2grid.sql')[source]

This function runs .sql scripts in the folder ‘sql_scripts’

etrago.tools.io.extension(self, **kwargs)[source]

Function that adds an additional network to the existing network container. The new network can include every PyPSA-component (e.g. buses, lines, links). To connect it to the existing network, transformers are needed.

All components and its timeseries of the additional scenario need to be inserted in the fitting ‘model_draft.ego_grid_pf_hv_extension_’ table. The scn_name in the tables have to be labled with ‘extension_’ + scn_name (e.g. ‘extension_nep2035’).

Until now, the tables include three additional scenarios: ‘nep2035_confirmed’: all new lines and needed transformers planed in the ‘Netzentwicklungsplan 2035’ (NEP2035) that have been confirmed by the Bundesnetzagentur (BNetzA)

‘nep2035_b2’: all new lines and needed transformers planned in the NEP 2035 in the scenario 2035 B2

‘BE_NO_NEP 2035’: DC-lines and transformers to connect the upcomming electrical-neighbours Belgium and Norway Generation, loads and its timeseries in Belgium and Norway for scenario ‘NEP 2035’

Parameters
  • network – The existing network container (e.g. scenario ‘NEP 2035’)

  • session – session-data

  • overlay_scn_name – Name of the additional scenario (WITHOUT ‘extension_’)

  • start_snapshot

  • end_snapshot – Simulation time

Return type

Network container including existing and additional network

etrago.tools.io.decommissioning(self, **kwargs)[source]

Function that removes components in a decommissioning-scenario from the existing network container. Currently, only lines can be decommissioned.

All components of the decommissioning scenario need to be inserted in the fitting ‘model_draft.ego_grid_pf_hv_extension_’ table. The scn_name in the tables have to be labled with ‘decommissioning_’ + scn_name (e.g. ‘decommissioning_nep2035’).

Parameters
  • network – The existing network container (e.g. scenario ‘NEP 2035’)

  • session – session-data

  • overlay_scn_name – Name of the decommissioning scenario

Return type

Network container including decommissioning

etrago.tools.io.distance(x0, x1, y0, y1)[source]

Function that calculates the square of the distance between two points.

Parameters
  • x0 – x - coordinate of point 0

  • x1 – x - coordinate of point 1

  • y0 – y - coordinate of point 0

  • y1 – y - coordinate of point 1

Returns

distance – square of distance

Return type

float

etrago.tools.io.calc_nearest_point(bus1, network)[source]

Function that finds the geographical nearest point in a network from a given bus.

Parameters
  • bus1 (float) – id of bus

  • network (Pypsa network container) – network including the comparable buses

Returns

bus0 – bus_id of nearest point

Return type

float

etrago.tools.io.add_ch4_h2_correspondence(self)[source]

Method adding the database table grid.egon_etrago_ch4_h2 to self. It contains the mapping from H2 buses to their corresponding CH4 buses.

etrago.tools.network module

etrago.tools.plot module

Plot.py defines functions necessary to plot results of eTraGo.

etrago.tools.plot.set_epsg_network(network)[source]

Change EPSG from 4326 to 3857. Needed when using osm-background.

Parameters

network (PyPSA network container) –

etrago.tools.plot.plot_osm(x, y, zoom, alpha=0.4)[source]

Plots openstreetmap as background of network-plots

Parameters
  • x (array of two floats) – Define x-axis boundaries (lat) of osm plot

  • y (array of two floats) – Define y-axis boundaries (long) of osm plot

  • zoom (int) – Define zoom of osm, higher values for higher resolution

  • alpha (float) – Sets osm-visibility, increase value if osm covers network-plot

etrago.tools.plot.coloring()[source]

Return a dictionary with a color assign to each kind of carrier used in etrago.network. This is used for plotting porpuses.

Returns

colors – Color for each kind of carrier.

Return type

dict

etrago.tools.plot.plot_line_loading_diff(networkA, networkB, timestep=0, osm=False)[source]

Plot difference in line loading between two networks (with and without switches) as color on lines

Positive values mean that line loading with switches is bigger than without Plot switches as small dots

Parameters
  • networkA (PyPSA network container) – Holds topology of grid with switches including results from powerflow analysis

  • networkB (PyPSA network container) – Holds topology of grid without switches including results from powerflow analysis

  • filename (str) – Specify filename If not given, figure will be show directly

  • timestep (int) – timestep to show, default is 0

  • osm (bool or dict, e.g. {'x': [1,20], 'y': [47, 56], 'zoom' : 6}) –

    If not False, osm is set as background with the following settings as dict:

    • ’x’: array of two floats, x axis boundaries (lat)

    • ’y’: array of two floats, y axis boundaries (long)

    • ’zoom’ : resolution of osm

etrago.tools.plot.network_expansion_diff(networkA, networkB, filename=None, boundaries=[], osm=False)[source]

Plot relative network expansion derivation of AC- and DC-lines.

Parameters
  • networkA (PyPSA network container) – Holds topology of grid including results from powerflow analysis

  • networkB (PyPSA network container) – Holds topology of grid including results from powerflow analysis

  • filename (str or None) – Save figure in this direction

  • boundaries (array) – Set boundaries of heatmap axis

  • osm (bool or dict, e.g. {'x': [1,20], 'y': [47, 56], 'zoom' : 6}) –

    If not False, osm is set as background with the following settings as dict:

    • ’x’: array of two floats, x axis boundaries (lat)

    • ’y’: array of two floats, y axis boundaries (long)

    • ’zoom’ : resolution of osm

etrago.tools.plot.plot_residual_load(network)[source]

Plots residual load summed of all exisiting buses.

Parameters

network (PyPSA network containter) –

Return type

Plot

etrago.tools.plot.plot_stacked_gen(network, bus=None, resolution='GW', filename=None)[source]

Plot stacked sum of generation grouped by carrier type

Parameters
  • network (PyPSA network container) –

  • bus (string) – Plot all generators at one specific bus. If none, sum is calulated for all buses

  • resolution (string) – Unit for y-axis. Can be either GW/MW/KW

Return type

Plot

etrago.tools.plot.plot_gen_diff(networkA, networkB, leave_out_carriers=['geothermal', 'oil', 'other_non_renewable', 'reservoir', 'waste'])[source]

Plot difference in generation between two networks grouped by carrier type

Parameters
  • networkA (PyPSA network container with switches) –

  • networkB (PyPSA network container without switches) –

  • leave_out_carriers – list of carriers to leave out (default to all small carriers)

Return type

Plot

etrago.tools.plot.plot_voltage(network, boundaries=[], osm=False)[source]

Plot voltage at buses as hexbin

Parameters
  • network (PyPSA network container) –

  • boundaries (list of 2 values, setting the lower and upper bound of colorbar) –

  • osm (bool or dict, e.g. {'x': [1,20], 'y': [47, 56], 'zoom' : 6}) –

    If not False, osm is set as background with the following settings as dict:

    • ’x’: array of two floats, x axis boundaries (lat)

    • ’y’: array of two floats, y axis boundaries (long)

    • ’zoom’ : resolution of osm

Return type

Plot

etrago.tools.plot.curtailment(network, carrier='solar', filename=None)[source]

Plot curtailment of selected carrier

Parameters
  • network (PyPSA network container) – Holds topology of grid including results from powerflow analysis

  • carrier (str) – Plot curtailemt of this carrier

  • filename (str or None) – Save figure in this direction

Return type

Plot

etrago.tools.plot.calc_dispatch_per_carrier(network, timesteps)[source]

Function that calculates dispatch per carrier in given timesteps

Parameters
  • network (PyPSA network container) – Holds topology of grid including results from powerflow analysis

  • timesteps (array) – Timesteps considered in dispatch calculation

Returns

dist – dispatch per carrier

Return type

pandas.Series

etrago.tools.plot.calc_storage_expansion_per_bus(network)[source]

Function that calculates storage expansion per bus and technology

Parameters

network (PyPSA network container) – Holds topology of grid including results from powerflow analysis

Returns

dist – storage expansion per bus and technology

Return type

pandas.Series

etrago.tools.plot.gen_dist_diff(networkA, networkB, techs=None, snapshot=0, n_cols=3, gen_size=0.2, filename=None, buscmap=<matplotlib.colors.LinearSegmentedColormap object>)[source]

Difference in generation distribution Green/Yellow/Red colors mean that the generation at a location is bigger with switches than without Blue colors mean that the generation at a location is smaller with switches than without

Parameters
  • networkA (PyPSA network container) – Holds topology of grid with switches including results from powerflow analysis

  • networkB (PyPSA network container) – Holds topology of grid without switches including results from powerflow analysis

  • techs (dict) – type of technologies which shall be plotted

  • snapshot (int) – snapshot

  • n_cols (int) – number of columns of the plot

  • gen_size (num) – size of generation bubbles at the buses

  • filename (str) – Specify filename If not given, figure will be show directly

Return type

None.

etrago.tools.plot.nodal_gen_dispatch(network, networkB=None, techs=['wind_onshore', 'solar'], item='energy', direction=None, scaling=1, filename=None, osm=False)[source]

Plot nodal dispatch or capacity. If networkB is given, difference in dispatch is plotted.

Parameters
  • network (PyPSA network container) – Holds topology of grid including results from powerflow analysis

  • networkB (PyPSA network container) – If given and item is ‘energy’, difference in dispatch between network and networkB is plotted. If item is ‘capacity’, networkB is ignored. default None

  • techs (None or list,) – Techs to plot. If None, all techs are plotted. default [‘wind_onshore’, ‘solar’]

  • item (str) – Specifies the plotted item. Options are ‘energy’ and ‘capacity’. default ‘energy’

  • direction (str) – Only considered if networkB is given and item is ‘energy’. Specifies the direction of change in dispatch between network and networkB. If ‘positive’, generation per tech which is higher in network than in networkB is plotted. If ‘negative’, generation per tech whcih is lower in network than in networkB is plotted. If ‘absolute’, total change per node is plotted. Green nodes have higher dispatch in network than in networkB. Red nodes have lower dispatch in network than in networkB. default None

  • scaling (int) – Scaling to change plot sizes. default 1

  • filename (path to folder) –

  • osm (bool or dict, e.g. {'x': [1,20], 'y': [47, 56], 'zoom' : 6}) –

    If not False, osm is set as background with the following settings as dict:

    • ’x’: array of two floats, x axis boundaries (lat)

    • ’y’: array of two floats, y axis boundaries (long)

    • ’zoom’ : resolution of osm

Return type

None.

etrago.tools.plot.nodal_production_balance(network, timesteps, scaling=1e-05)[source]

Function that calculates residual load per node in given timesteps

Parameters
  • network (PyPSA network container) – Holds topology of grid including results from powerflow analysis

  • timesteps (array) – timesteps considered in calculation

  • scaling (float, optional) – Scaling factor for bus size. The default is 0.00001.

Returns

  • bus_sizes (pandas.Series) – scaled residual load per node

  • bus_colors (pandas.Series) – ‘green’ for producer and ‘red’ for consumer

etrago.tools.plot.storage_p_soc(network, mean='1H', filename=None)[source]

Plots the dispatch and state of charge (SOC) of extendable storages.

Parameters
  • network (PyPSA network container) – Holds topology of grid including results from powerflow analysis

  • mean (str) – Defines over how many snapshots the p and soc values will averaged.

  • filename (path to folder) –

Return type

None.

etrago.tools.plot.storage_soc_sorted(network, filename=None)[source]

Plots the soc (state-pf-charge) of extendable storages

Parameters
  • network (PyPSA network container) – Holds topology of grid including results from powerflow analysis

  • filename (path to folder) –

Return type

None.

etrago.tools.plot.mul_weighting(network, timeseries)[source]

Returns timeseries considering snapshot_weighting

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • timeseries (pd.Series) – timeseries not considering snapshot_weighting

Returns

timeseries considering snapshot_weightings

Return type

pd.Series

etrago.tools.plot.calc_ac_loading(network, timesteps)[source]

Calculates loading of AC-lines

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • timesteps (range) – Defines which timesteps are considered. If more than one, an average line loading is calculated.

Returns

ACC line loading in MVA

Return type

pandas.Series

etrago.tools.plot.calc_dc_loading(network, timesteps)[source]

Calculates loading of DC-lines

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • timesteps (range) – Defines which timesteps are considered. If more than one, an average line loading is calculated.

Returns

DC line loading in MW

Return type

pandas.Series

etrago.tools.plot.plotting_colors(network)[source]

Add color values to network.carriers

Parameters

network (:class:`pypsa.Network) – Overall container of PyPSA

Return type

None.

etrago.tools.plot.calc_network_expansion(network, method='abs', ext_min=0.1)[source]

Calculates absolute or relative expansion per AC- and DC-line

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • method (str, optional) – Choose ‘rel’ or ‘abs’. The default is ‘abs’.

  • ext_min (float, optional) – Remove lines extended less than this value. The default is 0.1.

Returns

  • all_network (:class:`pypsa.Network) – Whole network including not extended lines

  • extension_lines (pandas.Series) – AC-line expansion

  • extension_links (pandas.Series) – DC-line expansion

etrago.tools.plot.plot_background_grid(network, ax)[source]

Plots grid topology in background of other network.plot

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • ax (matplotlib.axes._subplots.AxesSubplot) – axes of plot

Return type

None.

etrago.tools.plot.demand_side_management(self, buses, snapshots, agg='5h', used=False)[source]

Calculate shifting potential of demand side management

Parameters
  • buses (array) – List of electricity buses.

  • snapshots (array) – List of snapshots.

  • agg (str, optional) – Temporal resolution. The default is ‘5h’.

  • used (boolean, optional) – State if usage should be included in the results. The default is False.

Returns

df – Shifting potential (and usage) of power (MW) and energy (MWh)

Return type

pandas.DataFrame

etrago.tools.plot.bev_flexibility_potential(self, buses, snapshots, agg='5h', used=False)[source]

Calculate shifting potential of electric vehicles

Parameters
  • buses (array) – List of electricity buses.

  • snapshots (array) – List of snapshots.

  • agg (str, optional) – Temporal resolution. The default is ‘5h’.

  • used (boolean, optional) – State if usage should be included in the results. The default is False.

Returns

df – Shifting potential (and usage) of power (MW) and energy (MWh)

Return type

pandas.DataFrame

etrago.tools.plot.heat_stores(self, buses, snapshots, agg='5h', used=False)[source]

Calculate shifting potential (and usage) of heat stores

Parameters
  • buses (array) – List of electricity buses.

  • snapshots (array) – List of snapshots.

  • agg (str, optional) – Temporal resolution. The default is ‘5h’.

  • used (boolean, optional) – State if usage should be included in the results. The default is False.

Returns

df – Shifting potential (and usage) of power (MW) and energy (MWh)

Return type

pandas.DataFrame

etrago.tools.plot.hydrogen_stores(self, buses, snapshots, agg='5h', used=False)[source]

Calculate shifting potential (and usage) of heat stores

Parameters
  • buses (array) – List of electricity buses.

  • snapshots (array) – List of snapshots.

  • agg (str, optional) – Temporal resolution. The default is ‘5h’.

  • used (boolean, optional) – State if usage should be included in the results. The default is False.

Returns

df – Shifting potential (and usage) of power (MW) and energy (MWh)

Return type

pandas.DataFrame

etrago.tools.plot.flexibility_usage(self, flexibility, agg='5h', snapshots=[], buses=[], pre_path=None)[source]

Plots temporal distribution of potential and usage for flexibilities

Parameters
  • flexibility (str) – Name of flexibility option.

  • agg (str, optional) – Temporal resolution. The default is “5h”.

  • snapshots (list, optional) – Considered snapshots, if empty all are considered. The default is [].

  • buses (list, optional) – Considered components at AC buses, if empty all are considered. The default is [].

  • pre_path (str, optional) – State of and where you want to store the figure. The default is None.

Return type

None.

etrago.tools.plot.plot_carrier(network, carrier_links=['AC'], carrier_buses=['AC'])[source]
Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • carrier_links (list) – List of links to be plotted. The default is [“AC”].

  • carrier_buses (list) – List of buses to be plotted. The default is [“AC”].

  • cartopy (bool, optional) – Provide data about the availability of Cartopy. The default is True.

Return type

None.

etrago.tools.plot.plot_grid(self, line_colors, bus_sizes=0.001, bus_colors='grey', timesteps=range(0, 2), osm=False, boundaries=None, filename=None, disaggregated=False, ext_min=0.1, ext_width=False)[source]

Function that plots etrago.network and results for lines and buses

Parameters
  • line_colors (str) –

    Set static line color or attribute to plot e.g. ‘expansion_abs’ Current options:

    • ’line_loading’: mean line loading in p.u. in selected timesteps

    • ’v_nom’: nominal voltage of lines

    • ’expansion_abs’: absolute network expansion in MVA

    • ’expansion_rel’: network expansion in p.u. of existing capacity

    • ’q_flow_max’: maximal reactive flows

  • bus_sizes (float, optional) – Size of buses. The default is 0.001.

  • bus_colors (str, optional) –

    Set static bus color or attribute to plot. The default is ‘grey’. Current options:

    • ’nodal_production_balance’: net producer/consumer in selected timeteps

    • ’storage_expansion’: storage expansion per bus and technology

    • ’storage_distribution’: installed storage units per bus

    • ’gen_dist’: dispatch per carrier in selected timesteps

  • timesteps (array, optional) – Timesteps consideredd in time depended plots. The default is range(2).

  • osm (bool or dict, e.g. {'x': [1,20], 'y': [47, 56], 'zoom' : 6}) –

    If not False, osm is set as background with the following settings as dict:

    • ’x’: array of two floats, x axis boundaries (lat)

    • ’y’: array of two floats, y axis boundaries (long)

    • ’zoom’ : resolution of osm. The default is False.

  • boundaries (array) – Set fixed boundaries of heatmap axis. The default is None.

  • filename (str or None) – Save figure in this direction. The default is None.

  • disaggregated (bool, optional) – Choose if disaggregated network is shown. The default is False.

  • ext_min (float) – Choose minimum relative line extension shown in plot in p.u..

  • ext_width (float or bool) – Choose if line_width respects line extension. Turn off with ‘False’ or set linear factor to decremise extension line_width. The default is False.

Return type

None.

etrago.tools.plot.make_handler_map_to_scale_circles_as_in(ax, dont_resize_actively=False)[source]
etrago.tools.plot.make_legend_circles_for(sizes, scale=1.0, **kw)[source]
etrago.tools.plot.plot_clusters(self, carrier='AC', save_path=False, transmission_lines=False, gas_pipelines=False)[source]
Parameters
  • carrier (str, optional) – This variable set the carrier of the buses that will be plotted. The default is “AC”.

  • cartopy (bool, optional) – Set it to True when cartopy is installed and the map is supposed to include country’s boundaries and bodies of water

  • save_path (bool, optional) – Path to save the generated plot. The default is False.

  • transmission_lines (bool, optional) – The default is False. Define if the original transmission lines are plotted or not.

  • gas_pipelines (bool, optional) – The default is False. Define if the original gas pipelines are plotted or not.

Return type

None.

etrago.tools.plot.plot_gas_generation(self, t_resolution='20H', save_path=False)[source]

Plots timeseries data for gas generation

Parameters
  • self (:class:`Etrago) – Overall container of Etrago

  • t_resolution (str, optional) – sets the resampling rate of timeseries data to allow for smoother line plots

  • save_path (bool, optional) – Path to save the generated plot. The default is False.

Return type

None.

etrago.tools.plot.plot_gas_summary(self, t_resolution='20H', stacked=True, save_path=False)[source]

Plots timeseries data for gas loads (and generation)

Parameters
  • self (:class:`Etrago) – Overall container of Etrago

  • t_resolution (str, optional) – sets the resampling rate of timeseries data to allow for smoother line plots

  • stacked (bool, optional) – If True all TS data will be shown as stacked area plot. Total gas generation will then also be plotted to check for matching demand and generation.

  • save_path (bool, optional) – Path to save the generated plot. The default is False.

Return type

None.

etrago.tools.plot.plot_h2_generation(self, t_resolution='20H', save_path=False)[source]

Plots timeseries data for H2 generation

Parameters
  • self (:class:`Etrago) – Overall container of Etrago

  • t_resolution (str, optional) – sets the resampling rate of timeseries data to allow for smoother line plots

  • save_path (bool, optional) – Path to save the generated plot. The default is False.

Return type

None.

etrago.tools.plot.plot_h2_summary(self, t_resolution='20H', stacked=True, save_path=False)[source]

Plots timeseries data for H2 loads (and generation)

Parameters
  • self (:class:`Etrago) – Overall container of Etrago

  • t_resolution (str, optional) – sets the resampling rate of timeseries data to allow for smoother line plots

  • stacked (bool, optional) – If True all TS data will be shown as stacked area plot. Total H2 generation will then also be plotted to check for matching demand and generation.

  • save_path (bool, optional) – Path to save the generated plot. The default is False.

Return type

None.

etrago.tools.plot.plot_heat_loads(self, t_resolution='20H', save_path=False)[source]

Plots timeseries data for heat loads

Parameters
  • self (:class:`Etrago) – Overall container of Etrago

  • t_resolution (str, optional) – sets the resampling rate of timeseries data to allow for smoother line plots

  • save_path (bool, optional) – Path to save the generated plot. The default is False.

Return type

None.

etrago.tools.plot.plot_heat_summary(self, t_resolution='20H', stacked=True, save_path=False)[source]

Plots timeseries data for heat generation (and demand)

Parameters
  • self (:class:`Etrago) – Overall container of Etrago

  • t_resolution (str, optional) – sets the resampling rate of timeseries data to allow for smoother line plots

  • stacked (bool, optional) – If True all TS data will be shown as stacked area plot. Total heat demand will then also be plotted to check for matching generation and demand.

  • save_path (bool, optional) – Path to save the generated plot. The default is False.

Return type

None.

etrago.tools.utilities module

Utilities.py includes a wide range of useful functions.

Parameters
  • carrier (list or str) – name of the carriers of interest. Can be a list of carriers or single sting.

  • like (bool, optional) – When like set to True, the links with carrier names that includes the carrier(s) supplied are returned, Not just exact matches. The default is True.

Returns

df – Dataframe that contains just links with carriers of the types given in the argument carrier.

Return type

pandas.DataFrame object

etrago.tools.utilities.buses_of_vlvl(network, voltage_level)[source]

Get bus-ids of given voltage level(s).

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • voltage_level (list) –

Returns

List containing bus-ids.

Return type

list

etrago.tools.utilities.buses_grid_linked(network, voltage_level)[source]

Get bus-ids of a given voltage level connected to the grid.

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • voltage_level (list) –

Returns

List containing bus-ids.

Return type

list

etrago.tools.utilities.geolocation_buses(self)[source]

If geopandas is installed: Use geometries of buses x/y(lon/lat) and polygons of countries from RenpassGisParameterRegion in order to locate the buses

Else: Use coordinats of buses to locate foreign buses, which is less accurate.

TODO: Why not alway use geopandas??

Parameters

etrago (etrago.Etrago) – Transmission grid object

etrago.tools.utilities.buses_by_country(self)[source]

Find buses of foreign countries using coordinates and return them as Pandas Series

Parameters

self (Etrago object) – Overall container of PyPSA

Return type

None

etrago.tools.utilities.clip_foreign(network)[source]

Delete all components and timelines located outside of Germany. If applied after optimization, transborder flows divided by country of origin are added as network.foreign_trade.

Parameters

network (:class:`pypsa.Network) – Overall container of PyPSA

Returns

network – Overall container of PyPSA

Return type

:class:`pypsa.Network

Change transmission technology of foreign lines from AC to DC (links).

Parameters

network (:class:`pypsa.Network) – Overall container of PyPSA

Returns

network – Overall container of PyPSA

Return type

:class:`pypsa.Network

etrago.tools.utilities.set_q_national_loads(self, cos_phi)[source]

Set q component of national loads based on the p component and cos_phi

Parameters
  • network (pypsa.Network) – Overall container of PyPSA

  • cos_phi (float) – Choose ration of active and reactive power of foreign loads

Returns

network – Overall container of PyPSA

Return type

pypsa.Network

etrago.tools.utilities.set_q_foreign_loads(self, cos_phi)[source]

Set reative power timeseries of loads in neighbouring countries

Parameters
  • etrago (:class:`etrago.Etrago) – Transmission grid object

  • cos_phi (float) – Choose ration of active and reactive power of foreign loads

Return type

None

etrago.tools.utilities.connected_grid_lines(network, busids)[source]

Get grid lines connected to given buses.

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • busids (list) – List containing bus-ids.

Returns

PyPSA lines.

Return type

class:`pandas.DataFrame

etrago.tools.utilities.connected_transformer(network, busids)[source]

Get transformer connected to given buses.

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • busids (list) – List containing bus-ids.

Returns

PyPSA transformer.

Return type

class:`pandas.DataFrame

etrago.tools.utilities.load_shedding(self, temporal_disaggregation=False, **kwargs)[source]

Implement load shedding in existing network to identify feasibility problems

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • marginal_cost (int) – Marginal costs for load shedding

  • p_nom (int) – Installed capacity of load shedding generator

etrago.tools.utilities.data_manipulation_sh(network)[source]

Adds missing components to run calculations with SH scenarios.

Parameters

network (:class:`pypsa.Network) – Overall container of PyPSA

Return type

None

etrago.tools.utilities.export_to_csv(self, path)[source]

Write calculation results to csv-files in path.

Parameters
  • network (pypsa.Network) – Overall container of PyPSA

  • args (dict) – Contains calculation settings of appl.py

  • path (str or False or None) – Choose path for csv-files. Specify “”, False or None to not do anything.

Return type

None

etrago.tools.utilities.loading_minimization(network, snapshots)[source]

Minimizes the sum of the products of each element in the passive_branches of the model.

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • snapshots ('pandas.core.indexes.datetimes.DatetimeIndex') – snapshots to perform the minimization

Return type

None

etrago.tools.utilities.agg_series_lines(l0, network)[source]

Given a pandas DataFrame l0 containing information about lines in a network and a network object, aggregates the data in l0 for all its attributes. Returns a pandas Series containing the aggregated data.

Parameters
  • l0 (pandas.DataFrame) – contain information about lines in a network.

  • network (:class:`pypsa.Network) – Overall container of PyPSA

Returns

A pandas Series containing aggregated data for the lines in the network.

Return type

pandas.Series

etrago.tools.utilities.group_parallel_lines(network)[source]

Function that groups parallel lines of the same voltage level to one line component representing all parallel lines

Parameters

network (:class:`pypsa.Network) – Overall container of PyPSA

Return type

None.

etrago.tools.utilities.delete_dispensable_ac_buses(etrago)[source]

Function that identifies and delete AC buses without links, transformers, generators, loads, stores or storage_units, which also are connected to just one or two other buses

Parameters

etrago (etrago object) –

Return type

None.

etrago.tools.utilities.set_line_costs(self, cost110=230, cost220=290, cost380=85, costDC=375)[source]

Set capital costs for extendable lines in respect to PyPSA [€/MVA]

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • args (dict) – containing settings from appl.py

  • cost110 – capital costs per km for 110kV lines and cables default: 230€/MVA/km, source: costs for extra circuit in dena Verteilnetzstudie, p. 146)

  • cost220 – capital costs per km for 220kV lines and cables default: 280€/MVA/km, source: costs for extra circuit in NEP 2025, capactity from most used 220 kV lines in model

  • cost380 – capital costs per km for 380kV lines and cables default: 85€/MVA/km, source: costs for extra circuit in NEP 2025, capactity from most used 380 kV lines in NEP

  • costDC – capital costs per km for DC-lines default: 375€/MVA/km, source: costs for DC transmission line in NEP 2035

etrago.tools.utilities.set_trafo_costs(self, cost110_220=7500, cost110_380=17333, cost220_380=14166)[source]

Set capital costs for extendable transformers in respect to PyPSA [€/MVA]

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • cost110_220 – capital costs for 110/220kV transformer default: 7500€/MVA, source: costs for extra trafo in dena Verteilnetzstudie, p. 146; S of trafo used in osmTGmod

  • cost110_380 – capital costs for 110/380kV transformer default: 17333€/MVA, source: NEP 2025

  • cost220_380 – capital costs for 220/380kV transformer default: 14166€/MVA, source: NEP 2025

etrago.tools.utilities.add_missing_components(self)[source]

Add a missing transformer at Heizkraftwerk Nord in Munich and a missing transformer in Stuttgart.

Parameters

network (:class:`pypsa.Network) – Overall container of PyPSA

Returns

network – Overall container of PyPSA

Return type

:class:`pypsa.Network

etrago.tools.utilities.convert_capital_costs(self)[source]

Convert capital_costs to fit to considered timesteps

Parameters

etrago (:class:`etrago.Etrago) – Transmission grid object

etrago.tools.utilities.find_snapshots(network, carrier, maximum=True, minimum=True, n=3)[source]

Function that returns snapshots with maximum and/or minimum feed-in of selected carrier.

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • carrier (str) – Selected carrier of generators

  • maximum (bool) – Choose if timestep of maximal feed-in is returned.

  • minimum (bool) – Choose if timestep of minimal feed-in is returned.

  • n (int) – Number of maximal/minimal snapshots

Returns

calc_snapshots – List containing snapshots

Return type

‘pandas.core.indexes.datetimes.DatetimeIndex’

etrago.tools.utilities.ramp_limits(network)[source]

Add ramping constraints to thermal power plants.

Parameters

network (:class:`pypsa.Network) – Overall container of PyPSA

etrago.tools.utilities.get_args_setting(self, jsonpath='scenario_setting.json')[source]

Get and open json file with scenaio settings of eTraGo args. The settings incluedes all eTraGo specific settings of arguments and parameters for a reproducible calculation.

Parameters

json_file (str) – Default: scenario_setting.json Name of scenario setting json file

Returns

args – Dictionary of json file

Return type

dict

etrago.tools.utilities.merge_dicts(dict1, dict2)[source]

Return a new dictionary by merging two dictionaries recursively.

Parameters
  • dict1 (dict) – dictionary 1.

  • dict2 (dict) – dictionary 2.

Returns

result – Union of dict1 and dict2

Return type

dict

etrago.tools.utilities.get_clustering_data(self, path)[source]

Import the final busmap and the initial buses, lines and links

Parameters

path (str) – Name of folder from which to import CSVs of network data.

Return type

None

etrago.tools.utilities.set_random_noise(self, sigma=0.01)[source]

Sets random noise to marginal cost of each generator.

Parameters
  • etrago (:class:`etrago.Etrago) – Transmission grid object

  • seed (int) – seed number, needed to reproduce results

  • sigma (float) – Default: 0.01 standard deviation, small values reduce impact on dispatch but might lead to numerical instability

etrago.tools.utilities.set_line_country_tags(network)[source]

Set country tag for AC- and DC-lines.

Parameters

network (:class:`pypsa.Network) – Overall container of PyPSA

etrago.tools.utilities.crossborder_capacity_tyndp2020()[source]

This function downloads and extracts a scenario datafile for the TYNDP 2020 (Ten-Year Network Development Plan), reads a specific sheet from the file, filters it based on certain criteria, and then calculates the minimum cross-border capacities for a list of European countries. The minimum cross-border capacity is the minimum of the export and import capacities between two countries.

Returns

Dictionary with cossborder capacities.

Return type

dict

etrago.tools.utilities.crossborder_capacity(self)[source]

Adjust interconnector capacties.

Parameters
  • network (:class:`pypsa.Network) – Overall container of PyPSA

  • method (string) – Method of correction. Options are ‘ntc_acer’ and ‘thermal_acer’. ‘ntc_acer’ corrects all capacities according to values published by the ACER in 2016. ‘thermal_acer’ corrects certain capacities where our dataset most likely overestimates the thermal capacity.

etrago.tools.utilities.set_branch_capacity(etrago)[source]

Set branch capacity factor of lines and transformers, different factors for HV (110kV) and eHV (220kV, 380kV).

Parameters

etrago (:class:`etrago.Etrago) – Transmission grid object

etrago.tools.utilities.check_args(etrago)[source]

Function that checks the consistency of etragos input parameters.

Parameters

etrago (:class:`etrago.Etrago) – Overall container of eTraGo

Return type

None.

etrago.tools.utilities.drop_sectors(self, drop_carriers)[source]

Manually drop secors from network. Makes sure the network can be calculated without the dropped sectors.

Parameters

drop_carriers (array) – List of sectors that will be dropped. e.g. [‘dsm’, ‘CH4’, ‘H2_saltcavern’, ‘H2_grid’, ‘central_heat’, ‘rural_heat’, ‘central_heat_store’, ‘rural_heat_store’, ‘Li ion’] means everything but AC

Return type

None.

etrago.tools.utilities.update_busmap(self, new_busmap)[source]

Update busmap after any clustering process

Parameters

new_busmap (dictionary) – busmap used to clusted the network.

Return type

None.

etrago.tools.utilities.adjust_CH4_gen_carriers(self)[source]

Precise the carrier for the generators with CH4 carrier

For the eGon2035 scenario, the generators with carrier CH4 represent the prodution od biogas and methan. In the data model, these two differents types are differenciated only by the marginal cost of the generator. This function introduces a carrier distion (CH4_biogas and CH4_NG) in order to avoid the clustering of these two types of generator together and facilitate the contraint applying differently to each of them.

etrago.tools.utilities.residual_load(network, sector='electricity')[source]

Calculate the residual load for the specified sector.

In case of the electricity sector residual load is calculated using all AC loads and all renewable generators with carriers ‘wind_onshore’, ‘wind_offshore’, ‘solar’, ‘solar_rooftop’, ‘biomass’, ‘run_of_river’, and ‘reservoir’.

In case of the central heat sector residual load is calculated using all central heat loads and all renewable generators with carriers ‘solar_thermal_collector’ and ‘geo_thermal’.

Parameters
  • network (PyPSA network) – Network to retrieve load and generation time series from, needed to determine residual load.

  • sector (str) – Sector to determine residual load for. Possible options are ‘electricity’ and ‘central_heat’. Default: ‘electricity’.

Returns

Dataframe with residual load for each bus in the network. Columns of the dataframe contain the corresponding bus name and index of the dataframe is a datetime index with the corresponding time step.

Return type

pd.DataFrame

etrago.tools.utilities.manual_fixes_datamodel(etrago)[source]

Apply temporal fixes to the data model until a new egon-data run is there

Parameters

etrago (:class:`Etrago) – Overall container of Etrago

Return type

None.