etrago.analyze package

etrago.analyze.calc_results module

calc_results.py defines methods to calculate results of eTraGo

etrago.analyze.calc_results.annualize_capital_costs(overnight_costs, lifetime, p)[source]
Parameters:
  • overnight_costs (float) – Overnight investment costs in EUR/MW or EUR/MW/km

  • lifetime (int) – Number of years in which payments will be made

  • p (float) – Interest rate in p.u.

Returns:

Annualized capital costs in EUR/MW/a or EUR/MW/km/a

Return type:

float

etrago.analyze.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.analyze.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.analyze.calc_results.german_network(self)[source]

Cut out all network components in Germany

Returns:

new_network – Network with all components in Germany

Return type:

pypsa.Network

etrago.analyze.calc_results.system_costs_germany(self, electricity_only=False)[source]

Calculte system costs for Germany

Returns:

  • marginal_cost (float) – Marginal costs for dispatch in Germany

  • invest_cost (float) – Annualized investment costs for components in Germany

  • import_costs (float) – Costs for energy imported to Germany minus costs for exports

etrago.analyze.calc_results.electricity_system_costs_germany(self)[source]

Calculte system costs for Germany

Returns:

  • marginal_cost (float) – Marginal costs for dispatch in Germany

  • invest_cost (float) – Annualized investment costs for components in Germany

  • import_costs (float) – Costs for energy imported to Germany minus costs for exports

etrago.analyze.calc_results.ac_export(self)[source]

Calculate the balance of electricity exports and imports over AC lines

Returns:

Balance of electricity export in MWh (if negative: import from Germany)

Return type:

float

etrago.analyze.calc_results.ac_export_per_country(self)[source]

Calculate the balance of electricity exports and imports over AC lines per country

Returns:

Balance of electricity exchange in TWh (if > 0: export from Germany)

Return type:

float

etrago.analyze.calc_results.dc_export(self)[source]

Calculate the balance of electricity exports and imports over DC lines

Returns:

Balance of electricity exchange in MWh (if > 0: export from Germany)

Return type:

float

etrago.analyze.calc_results.dc_export_per_country(self)[source]

Calculate the balance of electricity exports and imports over DC lines per country

Returns:

Balance of electricity exchange in TWh (if > 0: export from Germany)

Return type:

float

etrago.analyze.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.analyze.calc_results.total_redispatch(network, only_de=True, plot=False)[source]

etrago.analyze.electrolysis_results module

electrolysis_results.py defines methods used to calculate results for the potential atlas for electrolysis grid connection points, which was one of the main outcomes of the PoWerD-project

etrago.analyze.electrolysis_results.lcoe_germany(etrago)[source]
etrago.analyze.electrolysis_results.regions_per_bus(etrago)[source]

Create matching dataframe of clustered AC-buses and corresponding MV-grids

Returns:

geoms

Return type:

pd.DataFrame

etrago.analyze.electrolysis_results.merit_order_ely_redispatch(etrago)[source]

Each hour, the electrolysers with the highest nodal prices in the grid optimization are designated as dispatch until the electrolysis injection from the market optimization has been met.

Returns:

  • redispatch_electrolysis (pd.DataFrame)

  • redispatch_electrolysis_per_bus (pd.DataFrame)

  • df_mv_grids (gpd.GeoDataFrame)

etrago.analyze.electrolysis_results.remaining_redispatch(etrago, min_flh=3000)[source]

Calculating the remaining redispatch per bus. Furthermore the method shows an electrolyzer potential based on the remaining redispatch and an assumption of 3000 full-load-hours.

Parameters:

min_flh (int) – Assumption of minimum amount of full-load-hours

Returns:

  • max_ely (pd.DataFrame)

  • ramp_down_per_bus (pd.DataFrame)

etrago.analyze.electrolysis_results.calc_atlas_results(etrago, filename=None)[source]

Calculating the final results for the potential_atlas as one of the main outcomes of the PoWerD-project. The results will be stored in a csv file for providing it to the project partners. Additonally the method creates a matching table for assign each clustered bus to the corresponding mv-grids.

Returns:

  • results (pd.DataFrame)

  • matching_mv_grids (gpd.GeoDataFrame)

etrago.analyze.plot module

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

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

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

Parameters:

network (PyPSA network container)

etrago.analyze.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.analyze.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.analyze.plot.plot_background_grid(network, ax, geographical_boundaries, osm)[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

  • geographical_boundaries (list) – Set georaphical boundaries for the plots

  • osm (False or dict.) – False if not osm background map is required or dictionary with x, y and zoom information.

Return type:

None.

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

Add color values to network.carriers

Parameters:

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

Return type:

None.

etrago.analyze.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.analyze.plot.plot_stacked_gen(self, bus=None, resolution='GW', filename=None)[source]

Plot stacked sum of generation grouped by carrier type

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

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

None.

etrago.analyze.plot.plot_curtailment(self, carrier='solar', filename=None)[source]

Plot curtailment of selected carrier

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

  • carrier (str) – Plot curtailemt of this carrier

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

Return type:

None.

etrago.analyze.plot.plot_residual_load(self, gen_carrier=['wind_onshore', 'wind_offshore', 'solar', 'solar_rooftop'], load_carrier=['AC'])[source]

Plots residual load summed of all exisiting buses.

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

  • gen_carrier (list of str, optional) – List of generator carrier types whose generation is considered and subtracted from the load.

  • load_carrier (list of str, optional) – List of load carrier types included in the load summation.

Return type:

None.

etrago.analyze.plot.plot_voltage(self, boundaries=[])[source]

Plot voltage at buses as hexbin

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

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

Return type:

None.

etrago.analyze.plot.plot_storage_soc_sorted(self, filename=None)[source]

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

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

  • filename (path to folder)

Return type:

None.

etrago.analyze.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.analyze.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.analyze.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.analyze.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.analyze.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.analyze.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.analyze.plot.demand_side_management(self, buses, snapshots, agg='5h', used=False, apply_on='grid_model')[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.

  • apply_on (str, optional) – Choose which network is plotted. The available networks depend on your settings. The default is ‘grid_model’

Returns:

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

Return type:

pandas.DataFrame

etrago.analyze.plot.bev_flexibility_potential(self, buses, snapshots, agg='5h', used=False, apply_on='grid_model')[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.

  • apply_on (str, optional) – Choose which network is plotted. The available networks depend on your settings. The default is ‘grid_model’

Returns:

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

Return type:

pandas.DataFrame

etrago.analyze.plot.heat_stores(self, buses, snapshots, agg='5h', used=False, apply_on='grid_model')[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.

  • apply_on (str, optional) – Choose which network is plotted. The available networks depend on your settings. The default is ‘grid_model’

Returns:

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

Return type:

pandas.DataFrame

etrago.analyze.plot.hydrogen_stores(self, buses, snapshots, agg='5h', used=False, apply_on='grid_model')[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.

  • apply_on (str, optional) – Choose which network is plotted. The available networks depend on your settings. The default is ‘grid_model’

Returns:

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

Return type:

pandas.DataFrame

etrago.analyze.plot.plot_flexibility_usage(self, flexibility, agg='5h', snapshots=[], buses=[], pre_path=None, apply_on='grid_model')[source]

Plots temporal distribution of potential and usage for flexibilities

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

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

  • apply_on (str, optional) – Choose which network is plotted. The available networks depend on your settings. The default is ‘grid_model’

Return type:

None.

etrago.analyze.plot.calc_dispatch_per_carrier(network, timesteps, dispatch_type='total')[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

  • dispatch_type (str) – This parameter can receive 3 different options: total, ramp_up and ramp_down. The default is total, which plots the total energy supplied by carrier by the given timesteps.

Returns:

dist – dispatch per carrier

Return type:

pandas.Series

etrago.analyze.plot.calc_storage_expansion_per_bus(network, carriers=['battery', 'H2_overground', 'H2_underground', 'rural_heat_store', 'central_heat_store'])[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.analyze.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.analyze.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:

AC line loading in MVA

Return type:

pandas.Series

etrago.analyze.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.analyze.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:

  • 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.analyze.plot.plot_grid(self, line_colors, bus_sizes=1e-05, bus_colors='grey', timesteps=range(0, 2), osm=False, boundaries=None, filename=None, apply_on='grid_model', ext_min=0.1, ext_width=False, legend_entries='all', scaling_store_expansion=False, geographical_boundaries=[-2.5, 16, 46.8, 58])[source]

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

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

  • 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

    • ’dlr’: energy above nominal capacity

    • ’grey’: plot all lines and DC links grey colored

  • 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

      time steps

    • ’storage_expansion’: storage expansion per bus and technology

    • ’storage_distribution’: installed storage units per bus

    • ’h2_battery_storage_expansion’: storage expansion per bus and

      technology for underground and overground H2 and batteries.

    • ’gen_dist’: dispatch per carrier in selected timesteps

    • ’ramp_up’: re-dispatch up per carrier in selected timesteps

    • ’ramp_down’: re-dispatch down per carrier in selected timesteps

    • ’PowerToH2’: location and sizes of electrolyzers

    • ’flexibility_usage’: use of DSM and BEV charger

    • ’PowerToH2_correlation’: indication of degree of correlation to

    market or nodal price of electrolyzers

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

  • apply_on (str, optional) – Choose which network is plotted. The available networks depend on your settings. The default is ‘grid_model’

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

  • legend_entries (list, optional) – Set the legends for buses to be plotted. The default is ‘all’.

  • scaling_store_expansion (dict, optional) – Set scaling values to be used per technology for the plots storage_expansion and h2_battery_storage_expansion. The default is False, it could be assinged like this: {“H2”: 50, “heat”: 0.1, “battery”: 10}

  • geographical_boundaries (list, optional) – Set georaphical boundaries for the plots. This parameter is overwritten when osm is used. The default is [-2.5, 16, 46.8, 58]

Return type:

None.

etrago.analyze.plot.plot_carrier(self, carrier_links=['AC'], carrier_buses=['AC'], apply_on='grid_model')[source]
Parameters:
  • self (:class:`Etrago) – Overall container of Etrago

  • 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.analyze.plot.plot_clusters(self, carrier='AC', save_path=False, transmission_lines=False, gas_pipelines=False)[source]
Parameters:
  • self (:class:`Etrago) – Overall container of Etrago

  • 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.analyze.plot.plot_flexibility_duration_curve(etrago, etrago_lowflex, filename=None)[source]

Plot duration curves of flexibility options

Parameters:
  • etrago (Etrago) – Object including network with flexibility options

  • etrago_lowflex (Etrago) – Object including network with less flexibility options

  • filename (str, optional) – Name of file to save plot. The default is None.

Return type:

None.

etrago.analyze.plot.plot_gen_diff(networkA, networkB, leave_out_carriers=['geo_thermal', 'oil', 'others', 'reservoir'])[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:

None.

etrago.analyze.plot.plot_gen_dist_diff(networkA, networkB, techs=None, snapshot=0, n_cols=3, gen_size=0.2, filename=None, buscmap=<matplotlib.colors.LinearSegmentedColormap object>, geo_boundaries=[-2.5, 16, 46.8, 58])[source]

Plot difference in generation distribution for each technology. Global legends (colors + sizes) included.

etrago.analyze.plot.plot_line_loading_diff(networkA, networkB, filename=None, boundaries=[])[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

Return type:

None.

etrago.analyze.plot.plot_network_expansion_diff(networkA, networkB, filename=None, boundaries=[])[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

Return type:

None.

etrago.analyze.plot.regions_per_bus(etrago)[source]
etrago.analyze.plot.plot_simplified_distribution_grids(etrago, attribute='expansion_abs', cmap='viridis', filename=None)[source]
etrago.analyze.plot.shifted_energy(network, carrier, buses)[source]

Calulate shifted energy for a specific carrier

Parameters:
  • carrier (str) – Name of energy carrier

  • buses (list) – List of considered bus indices

Returns:

shifted – Shifted energy per time step

Return type:

pandas.Series

etrago.analyze.plot.make_handler_map_to_scale_circles_as_in(ax, dont_resize_actively=False)[source]
etrago.analyze.plot.make_legend_circles_for(sizes, scale=1.0, **kw)[source]