backbonetools.io.outputs#

Classes

BackboneResult(path)

A class to convert a backbone output file to pandas dataframes and work with it (e.g.

BackboneScenarioAnalysis([results_dir, ...])

Class to analysis multiple backbone results together

class backbonetools.io.outputs.BackboneResult(path)#

Bases: object

A class to convert a backbone output file to pandas dataframes and work with it (e.g. plot results or convert an invest result to a schedule input)

__init__(path)#

initializes class by converting gdx file to dictionary of pandas dataframes

Parameters:

path (str) – path to backbone result file

Raises:
  • GamsException – if path is invalid

  • TypeError – if path does not lead to a gdx file

  • GamsException – is gdx file at path is no backbone result file

eqn_as_df(eqn_name)#

converts a gams equation to a dataframe (e.g. for debugs)

Parameters:

eqn_name (str) – name of equation

Returns:

equation as dataframe

Return type:

pandas.dataframe

param_as_df(param_name, convert_time=True)#

converts a gams parameter to a dataframe

Parameters:
  • param_name (str) – name of parameter

  • convert_time (bool, optional) – If time shall be converted from backbones t000001 to numerical values. Defaults to True.

Returns:

parameter as dataframe

Return type:

pandas.dataframe

param_as_df_gdxdump(param_name, encoding='1252', convert_time=True)#

converts a gams parameter to a dataframe with the ‘gdxdump’ GAMS utility via subprocess. This is sometimes beneficial, to circumvent decoding errors

Parameters:
  • param_name (str) – name of parameter

  • encoding (str, optional) – encoding parameter for gdxdump. Defaults to “1252”.

  • convert_time (bool, optional) – If time shall be converted from backbones t000001 to numerical values. Defaults to True.

Returns:

parameter as dataframe

Return type:

pandas.dataframe

set_as_df(set_name)#

converts a gams set to a dataframe

Parameters:

set_name (str) – name of set

Returns:

set as dataframe

Return type:

pandas.dataframe

set_symbols_as_attribs()#

Sets all output symbols as methods. This allows to access result parameters by BackboneResult.r_emission().

property symbols#

gets all symbols from the output file

Raises:

ge – if something is wrong with the length of the file

Returns:

list of all symbols in the {result_file}.gdx

Return type:

list

class backbonetools.io.outputs.BackboneScenarioAnalysis(results_dir: str | None = None, result_files: list | None = None)#

Bases: object

Class to analysis multiple backbone results together

__init__(results_dir: str | None = None, result_files: list | None = None) None#

initalizes class by reading in multiple backbone files as instances of class BackboneResult

Parameters:
  • results_dir (str, optional) – Directory with result files. Defaults to None.

  • result_files (list, optional) – List of result files to read in. Defaults to None.

Raises:

ValueError – If neither results_dir or results_files is set

energy_provided_per_unitType(unitTypeList=None, unitTypeDict=None) DataFrame#

returns pandas dataframe with energy provided per unit and scenario, can be grouped by unitType if either unitTypeList or unitTypeDict is given.

Parameters:
  • unitTypeList (list, optional) – If plot shall be made by unit type rather than unit. Give list of unittypes. All units which name contains the unittype will be sorted to the unittype. Defaults to None.

  • unitTypeDict (dict, optional) – If plot shall be made by unit type rather than unit. Give dict of unittypes. All units which name contains the unittype key will be sorted to the unittype. Defaults to None.

Returns:

pandas dataframe with energy provided per unit and scenario

Return type:

pandas.DataFrame

installed_capacity(unitTypeList=None, unitTypeDict=None) DataFrame#

Returns installed capacity per unit and scenario, can be grouped by unitType if either unitTypeList or unitTypeDict is given.

Parameters:
  • unitTypeList (list, optional) – If plot shall be made by unit type rather than unit. Give list of unittypes. All units which name contains the unittype will be sorted to the unittype. Defaults to None.

  • unitTypeDict (dict, optional) – If plot shall be made by unit type rather than unit. Give dict of unittypes. All units which name contains the unittype key will be sorted to the unittype. Defaults to None.

Returns:

dataframe with installed capacity per unit and scenario

Return type:

pandas.DataFrame

plot_energy_per_unitType(unitTypeList=None, unitTypeDict=None, colors=None)#

plots energy provided per unit and scenario, plot can be done by unitType if either unitTypeList or unitTypeDict is given.

Parameters:
  • unitTypeList (list, optional) – If plot shall be made by unit type rather than unit. Give list of unittypes. All units which name contains the unittype will be sorted to the unittype. Defaults to None.

  • unitTypeDict (dict, optional) – If plot shall be made by unit type rather than unit. Give dict of unittypes. All units which name contains the unittype key will be sorted to the unittype. Defaults to None.

  • colors (list, optional) – list with colors for plotting. Defaults to None.

Returns:

plot with energy provided per unit type

Return type:

plotly.graph_objects.figure

plot_energy_per_unitType_stacked(unitTypeList=None, unitTypeDict=None, colors=None)#

plots energy provided per unit and scenario as stacked bars, plot can be done by unitType if either unitTypeList or unitTypeDict is given.

Parameters:
  • unitTypeList (list, optional) – If plot shall be made by unit type rather than unit. Give list of unittypes. All units which name contains the unittype will be sorted to the unittype. Defaults to None.

  • unitTypeDict (dict, optional) – If plot shall be made by unit type rather than unit. Give dict of unittypes. All units which name contains the unittype key will be sorted to the unittype. Defaults to None.

  • colors (list, optional) – list of colors for plotting. Defaults to None.

Returns:

plot with energy provided per unit type as stacked bars

Return type:

plotly.graph_objects.figure

plot_installed_capacity(unitTypeList=None, unitTypeDict=None, colors=None)#

plots installed capacity per scenario, plot can be done by unitType if either unitTypeList or unitTypeDict is given.

Parameters:
  • unitTypeList (list, optional) – If plot shall be made by unit type rather than unit. Give list of unittypes. All units which name contains the unittype will be sorted to the unittype. Defaults to None.

  • unitTypeDict (dict, optional) – If plot shall be made by unit type rather than unit. Give dict of unittypes. All units which name contains the unittype key will be sorted to the unittype. Defaults to None.

  • colors (list, optional) – list of colors. Defaults to None.

Returns:

figure showing the invested capacities per scenario

Return type:

plotly.express.fig

plot_priceDurationCurve(nodes=[], stylelist=[], colorlist=None)#

Plots electricity price duration curves, i.e. the ordered dual variable of the balance constraint of each electricity node defined in the list “nodes” (the default is the complete list of electricity nodes) by Scenario.

Parameters:
  • nodes (list, optional) – list of all nodes to look at. If not set, all nodes from the “elec” grid will be plotted. Defaults to [].

  • stylelist (list, optional) – list for linestyles. Defaults to [].

  • colorlist (list, optional) – list for plot colors. Defaults to None.

Returns:

list of plotted pandas dataframes (price duration curves)

Return type:

list

plot_priceDurationCurve2(nodes=[], stylelist=[], colorlist=None)#

Plots electricity price duration curves, i.e. the ordered dual variable of the balance constraint of electricity nodes, for all scenarios by nodes as defined in the list “nodes” (the default is the complete list of electricity nodes) by Scenario.

Parameters:
  • nodes (list, optional) – list of all nodes to look at. If not set, all nodes from the “elec” grid will be plotted. Defaults to [].

  • stylelist (list, optional) – list for linestyles. Defaults to [].

  • colorlist (list, optional) – list for plot colors. Defaults to None.

Returns:

list of plotted pandas dataframes (price duration curves)

Return type:

list

plot_system_cost_composition()#

plots cost components per scenario

Returns:

figure showing the cost components per scenario

Return type:

plotly.express.fig

set_symbols_as_attribs()#

Sets all output symbols as methods. This allows to access result parameters by BackboneResult.r_emission().

system_cost_composition() DataFrame#

writes cost components (invest costs, transmission costs, emissions costs, fom costs, vom costs) per scenario to a dataframe

Returns:

dataframe containing different cost components per scenario

Return type:

pandas.DataFrame