backbonetools.io.inputs#

Functions for processing backbone input data

Classes

BackboneInput(path)

A class to convert an input file to pandas dataframes and work with it (e.g.

class backbonetools.io.inputs.BackboneInput(path)#

Bases: object

A class to convert an input file to pandas dataframes and work with it (e.g. time series aggregation via tsam)

__init__(path)#

initializes class by converting gdx file to dictionary of pandas dataframes

Parameters:

path (str) – path to input file

Raises:

FileNotFoundError – If path to input file was not found

aggregate_timeseries(export_path, hours_per_period=168, n_periods=3, investInit_path=None, alternative_investInit_template=None, ts_params=['ts_influx', 'ts_node', 'ts_unit', 'ts_cf'], err_indicators=None)#

use tsam to aggregate time series

Parameters:
  • export_path (str) – path where file with aggregated time series shall be saved (path/to/filename.gdx)

  • hours_per_period (int, optional) – numbers of hours per period (tsam parameter). Defaults to 24*7.

  • n_periods (int, optional) – number of representative periods (tsam paramter). Defaults to 3.

  • investInit_path (str, optional) – path to updated investInit.gms. investInit is only written if this path is given. Defaults to None.

  • alternative_investInit_template (str, optional) – alternative template for investInit.gms. The following wild cards can be used and will be replaced by the corresponding argument values: “n_periods” and “hours_per_period”. Furthermore, the template should contain ” // add sample timesteps”, ” // add sample probability”, ” // add sample weights” and ” // add sample annuity weights” for insertion of corresponding values. Use method show_investInit_template() to show the default template. Defaults to None.

  • ts_params (list, optional) – parameters that shall be included in the clustering. Defaults to [“ts_influx”, “ts_node”, “ts_unit”, “ts_cf”].

  • err_indicators (str, optional) – only “print” or None possible, for debugging. Defaults to None.

Raises:

NotImplementedError – if err_indicators is something else but “print” or None

property input_symbols#

gets all symbols from the input file

Raises:

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

Returns:

list of all symbols in input file

Return type:

list

investInit_for_aggregatedTimeseries(hours_per_period, n_periods, weights, alternative_investInit_template=None)#

creates new investInit for aggregated timeseries

Parameters:
  • hours_per_period (int, optional) – numbers of hours per period (tsam parameter). Defaults to 24*7.

  • n_periods (int, optional) – number of representative periods (tsam paramter). Defaults to 3.

  • weights (list) – list of weights for sample

  • alternative_investInit_template (str, optional) – alternative template for investInit.gms. The following wild cards can be used and will be replaced by the corresponding argument values: “n_periods” and “hours_per_period”. Furthermore, the template should contain ” // add sample timesteps”, ” // add sample probability”, ” // add sample weights” and ” // add sample annuity weights” for insertion of corresponding values. Use method show_investInit_template() to show the default template. Defaults to None.

Returns:

new investInit

Return type:

str

param_as_df_gdxdump(symbol, encoding='1252', convert_time=True) DataFrame#

Use the ‘gdxdump’ GAMS utility via subprocess to convert a parameter into a pd.DataFrame. This is sometimes beneficial, to circumvent decoding errors

Returns:

parameter converted to a pandas dataframe

Return type:

pandas.dataframe

set_symbols_as_attribs()#

Sets all input symbols as methods. Allows for easy access like bb_input.p_gnu_io() or bb_input.ts_influx()

show_investInit_template()#

Shows investInit.gms template to simplify building own template

update_gams_parameter_in_db(param_name: str, indices: list, value: float | None = None, apply_percentage: float | None = None) GamsDatabase#

change gams parameter in a database

Parameters:
  • param_name (str) – name of parameter to change

  • indices (list) – index of value to be changed

  • value (float, optional) – new value. Defaults to None.

  • apply_percentage (float, optional) – give new value as percentage of old value. Defaults to None.

Raises:
  • ge – if record cannot be found

  • ValueError – if neither value nor percentage are passed

Returns:

gams databased with changed value

Return type:

GamsDatabase