ego.tools package

Submodules

ego.tools.economics

This module collects useful functions for economic calculation of eGo which can mainly distinguished in operational and investment costs.

ego.tools.economics.annuity_per_period(capex, n, wacc, t, p)[source]

Calculate per given period

Parameters:
  • capex (float) – Capital expenditure (NPV of investment)
  • n (int) – Number of years that the investment is used (economic lifetime)
  • wacc (float) – Weighted average cost of capital
  • t (int) – Timesteps in hours
  • p (float) – interest rate
ego.tools.economics.edisgo_convert_capital_costs(overnight_cost, t, p, json_file)[source]

Get scenario and calculation specific annuity cost by given capital costs and lifetime.

Parameters:
  • json_file (:obj:dict) – Dictionary of the scenario_setting.json file
  • _start_snapshot (int) – Start point of calculation from scenario_setting.json file
  • _end_snapshot (int) – End point of calculation from scenario_setting.json file
  • _p (numeric) – interest rate of investment
  • _t (int) – lifetime of investment
Returns:

annuity_cost – Scenario and calculation specific annuity cost by given capital costs and lifetime

Return type:

numeric

Examples

PVA =   (1 / p) - (1 / (p*(1 + p)^t))

ego.tools.economics.etrago_convert_overnight_cost(annuity_cost, json_file, t=40, p=0.05)[source]

Get annuity cost of simulation and calculation total overnight_costs by given capital costs and lifetime.

Parameters:
  • json_file (:obj:dict) – Dictionary of the scenario_setting.json file
  • _start_snapshot (int) – Start point of calculation from scenario_setting.json file
  • _end_snapshot (int) – End point of calculation from scenario_setting.json file
  • _p (numeric) – interest rate of investment
  • _T (int) – lifetime of investment
Returns:

overnight_cost – Scenario and calculation total overnight_costs by given annuity capital costs and lifetime.

Return type:

numeric

Examples

PVA =   (1 / p) - (1 / (p*(1 + p)^t))

K_{ON} = K_a*PVA*((t/(period+1))

ego.tools.economics.etrago_operating_costs(network)[source]

Function to get all operating costs of eTraGo.

Parameters:network_etrago (etrago.tools.io.NetworkScenario) – eTraGo network object compiled by etrago.appl.etrago()
Returns:operating_costs – DataFrame with aggregate operational costs per component and voltage level in [EUR] per calculated time steps.
Return type:pandas.Dataframe

Example

>>> from ego.tools.io import eGo
>>> ego = eGo(jsonpath='scenario_setting.json')
>>> ego.etrago.operating_costs
component operation_costs voltage_level
biomass 27.0 ehv
line losses 0.0 ehv
wind_onshore 0.0 ehv
ego.tools.economics.etrago_grid_investment(network, json_file)[source]

Function to get grid expantion costs from eTraGo

Parameters:
  • network_etrago (etrago.tools.io.NetworkScenario) – eTraGo network object compiled by etrago.appl.etrago()
  • json_file (:obj:dict) – Dictionary of the scenario_setting.json file
Returns:

grid_investment_costs – Dataframe with voltage_level, number_of_expansion and capital_cost per calculated time steps

Return type:

pandas.Dataframe

Example

>>> from ego.tools.io import eGo
>>> ego = eGo(jsonpath='scenario_setting.json')
>>> ego.etrago.grid_investment_costs
voltage_level number_of_expansion capital_cost
ehv 27.0 31514.1305
hv 0.0 0.0
ego.tools.economics.edisgo_grid_investment(edisgo, json_file)[source]

Function aggregates all costs, based on all calculated eDisGo grids and their weightings :param edisgo: Contains multiple eDisGo networks :type edisgo: ego.tools.edisgo_integration.EDisGoNetworks

Returns:Dataframe containing annuity costs per voltage level
Return type:None or pandas.DataFrame
ego.tools.economics.get_generator_investment(network, scn_name)[source]

Get investment costs per carrier/ generator.

ego.tools.edisgo_integration

ego.tools.io

This file contains the eGo main class as well as input & output functions of eGo in order to build the eGo application container.

class ego.tools.io.egoBasic(*args, **kwargs)[source]

Bases: object

The eGo basic class select and creates based on your scenario_setting.json file your definded eTraGo and eDisGo results container. And contains the session for the database connection.

Parameters:jsonpath (json) – Path to scenario_setting.json file.
Returns:
class ego.tools.io.eTraGoResults(*args, **kwargs)[source]

Bases: ego.tools.io.egoBasic

The eTraGoResults class creates and contains all results of eTraGo and it’s network container for eGo.

Returns:
class ego.tools.io.eDisGoResults(*args, **kwargs)[source]

Bases: ego.tools.io.eTraGoResults

The eDisGoResults class create and contains all results of eDisGo and its network containers.

edisgo

Contains basic informations about eDisGo

Returns:
Return type:pandas.DataFrame
class ego.tools.io.eGo(jsonpath, *args, **kwargs)[source]

Bases: ego.tools.io.eDisGoResults

Main eGo module which includs all results and main functionalities.

Returns:
  • network_etrago (etrago.tools.io.NetworkScenario) – eTraGo network object compiled by etrago.appl.etrago()
  • edisgo.network (ego.tools.edisgo_integration.EDisGoNetworks) – Contains multiple eDisGo networks
  • edisgo (pandas.Dataframe) – aggregated results of eDisGo
  • etrago (pandas.Dataframe) – aggregated results of eTraGo
total_investment_costs

Contains all investment informations about eGo

Returns:
Return type:pandas.DataFrame
total_operation_costs

Contains all operation costs information about eGo

Returns:
Return type:pandas.DataFrame
plot_total_investment_costs(filename=None, display=False, **kwargs)[source]

Plot total investment costs

plot_power_price(filename=None, display=False)[source]

Plot power prices per carrier of calculation

plot_storage_usage(filename=None, display=False)[source]

Plot storage usage by charge and discharge

plot_edisgo_cluster(filename=None, display=False, **kwargs)[source]

Plot the Clustering of selected Dingo networks

plot_line_expansion(**kwargs)[source]

Plot line expantion per line

plot_storage_expansion(**kwargs)[source]

Plot storage expantion per bus

iplot

Get iplot of results as html

ego.tools.io.results_to_excel(ego)[source]

Wirte results of ego.total_investment_costs to an excel file

ego.tools.io.etrago_from_oedb(session, json_file)[source]

Function which import eTraGo results for the Database by the result_id number.

Parameters:
Returns:

network_etrago – eTraGo network object compiled by etrago.appl.etrago()

Return type:

etrago.tools.io.NetworkScenario

ego.tools.io.recover_resultsettings(session, json_file, orm_meta, result_id)[source]

Recover scenario_setting from database

ego.tools.mv_cluster

This file contains all functions regarding the clustering of MV grids

ego.tools.mv_cluster.analyze_attributes(ding0_files)[source]

Calculates the attributes wind and solar capacity and farthest node for all files in ding0_files. Results are written to ding0_files

Parameters:ding0_files (str) – Path to ding0 files
ego.tools.mv_cluster.cluster_mv_grids(no_grids, cluster_base)[source]

Clusters the MV grids based on the attributes, for a given number of MV grids

Parameters:
  • ding0_files (str) – Path to ding0 files
  • no_grids (int) – Desired number of clusters (of MV grids)
Returns:

Dataframe containing the clustered MV grids and their weightings

Return type:

pandas.DataFrame

ego.tools.plots

Module which collects useful functions for plotting eTraGo, eDisGo and eGo results.

ego.tools.plots.carriers_colore()[source]

Return matplotlib colore set per carrier (technologies of generators) of eTraGo.

Returns:colors – List of carriers and matplotlib colores
Return type:dict
ego.tools.plots.ego_colore()[source]

Get the four eGo colores

Returns:colors – List of eGo matplotlib colores
Return type:dict
ego.tools.plots.plot_storage_expansion(ego, filename=None, dpi=300, column='overnight_costs', scaling=1)[source]

Plot line expantion

Parameters:
  • ego (ego.tools.io.eGo) – eGo eGo inclueds on eTraGo and eDisGo
  • filename (list) – Filename and/or path of location to store graphic
  • dpi (int) – dpi value of graphic
  • column (str) – column name of eTraGo’s line costs. Default: overnight_costs in EURO. Also available s_nom_expansion in MVA or annualized investment_costs in EURO
  • scaling (numeric) – Factor to scale storage size of bus_sizes
Returns:

https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.show

Return type:

plot matplotlib.pyplot.show

ego.tools.plots.plot_line_expansion(ego, filename=None, dpi=300, column='overnight_costs')[source]

Plot line expantion

Parameters:
  • ego (ego.tools.io.eGo) – eGo eGo inclueds on eTraGo and eDisGo
  • filename (list) – Filename and or path of location to store graphic
  • dpi (int) – dpi value of graphic
  • column (str) – column name of eTraGo’s line costs. Default: overnight_costs in EURO. Also available s_nom_expansion in MVA or annualized investment_costs in EURO
Returns:

https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.show

Return type:

plot matplotlib.pyplot.show

ego.tools.plots.plot_grid_storage_investment(costs_df, filename, display, var=None)[source]
ego.tools.plots.power_price_plot(ego, filename, display)[source]

Plot power price of calculated scenario of timesteps and carrier

:param ego ego.io.eGo:

Returns:https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.show
Return type:plot matplotlib.pyplot.show
ego.tools.plots.plot_storage_use(ego, filename, display)[source]

Plot storage use by charge and discharge values

:param ego ego.io.eGo:

Returns:https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.show
Return type:plot matplotlib.pyplot.show
ego.tools.plots.get_country(session, region=None)[source]

Get Geometries of scenario Countries

ego.tools.plots.prepareGD(session, subst_id=None, version=None)[source]

Get MV grid districts for plotting

ego.tools.plots.plot_edisgo_cluster(ego, filename, region=['DE'], display=False, dpi=600)[source]

Plot the Clustering of selected Dingo networks

:param ego ego.io.eGo: self class object of eGo() :param filename: file name for plot cluster_plot.pdf :type filename: str :param region: List of background countries e.g. [‘DE’, ‘DK’] :type region: list :param display: True show plot false print plot as filename :type display: boolean

Returns:https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.show
Return type:plot matplotlib.pyplot.show
ego.tools.plots.igeoplot(ego, tiles=None, geoloc=None, args=None)[source]

Plot function in order to display eGo results on leaflet OSM map. This function will open the results in your main web browser

:param network_etrago:: class: eTraGo network object compiled by: meth: etrago.appl.etrago :type network_etrago:: class: etrago.tools.io.NetworkScenario :param tiles: Folium background map style None as OSM or Nasa :type tiles: str :param geoloc: Listwhich define center of map as (lon, lat) :type geoloc: : obj: list

Returns:plot – HTML file with .js plot
Return type:html
ego.tools.plots.colormapper_lines(colormap, lines, line, column='s_nom')[source]

Colore Map for lines

ego.tools.results

This module include the results functions for analyze and creating results based on eTraGo or eDisGo for eGo.

ego.tools.results.create_etrago_results(network, scn_name)[source]

Create eTraGo results

Parameters:
Returns:

generator – Result of generator as DataFrame in ego.etrago.generator

Return type:

pandas.DataFrame

ego.tools.results.results_per_voltage(network)[source]

Get eTraGo results per voltage level

Parameters:network (etrago.tools.io.NetworkScenario) –

eTraGo NetworkScenario based on PyPSA Network. See also pypsa.network

ego.tools.results.ego_results_to_oedb(ego)[source]

Function to upload results into oedb database

ego.tools.specs

This files contains all eGo interface functions

ego.tools.specs.get_etragospecs_direct(session, bus_id, etrago_network, scn_name, grid_version, pf_post_lopf, max_cos_phi_renewable)[source]

Reads eTraGo Results from Database and returns and returns the interface values as a dictionary of corresponding dataframes

Parameters:
Returns:

Dataframes used as eDisGo inputs

Return type:

dict of pandas.DataFrame

ego.tools.storages

This module contains functions for storage units.

ego.tools.storages.etrago_storages(network)[source]

Sum up the pysical storage values of the total scenario based on eTraGo results.

Parameters:network (etrago.tools.io.NetworkScenario) –

eTraGo NetworkScenario based on PyPSA Network. See also pypsa.network

Returns:results – Summarize and returns a DataFrame of the storage optimaziation.
Return type:pandas.DataFrame

Notes

The results dataframe incluedes following parameters:

charge : numeric
Quantity of charged energy in MWh over scenario time steps
discharge : numeric
Quantity of discharged energy in MWh over scenario time steps
count : int
Number of storage units
p_nom_o_sum: numeric
Sum of optimal installed power capacity
ego.tools.storages.etrago_storages_investment(network, json_file)[source]

Calculate storage investment costs of eTraGo

Parameters:network (etrago.tools.io.NetworkScenario) –

eTraGo NetworkScenario based on PyPSA Network. See also pypsa.network

Returns:storage_costs – Storage costs of selected snapshots in [EUR]
Return type:numeric

ego.tools.utilities

This module contains utility functions for the eGo application.

ego.tools.utilities.define_logging(name)[source]

Helps to log your modeling process with eGo and defines all settings.

Parameters:log_name (str) – Name of log file. Default: ego.log.
Returns:logger – Set up logger object of package logging
Return type:logging.basicConfig.
ego.tools.utilities.get_scenario_setting(jsonpath='scenario_setting.json')[source]

Get and open json file with scenaio settings of eGo. The settings incluede eGo, eTraGo and eDisGo 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:json_file – Dictionary of json file
Return type:dict
ego.tools.utilities.fix_leading_separator(csv_file, **kwargs)[source]

Takes the path to a csv-file. If the first line of this file has a leading separator in its header, this field is deleted. If this is done the second field of every row is removed, too.

ego.tools.utilities.get_time_steps(json_file)[source]

Get time step of calculation by scenario settings.

Parameters:json_file (dict) – Dictionary of the scenario_setting.json file
Returns:time_step – Number of timesteps of the calculation.
Return type:int