omf

Api

transform

Transform an ES dict to an oemof EnergySystem

Internal Functionalities

create_nodes

Create the energy system nodes.

parse_flow_parameters

Transform an energy system object dict into a ready to pass flow parameter dict.

infer_timeindex

Try inferring the timeindex from the energy system dictionairy.

omf is a tessif module to transform energy system data represented as mapping like it is returned by ie: parse.

tessif.transform.mapping2es.omf.parse_ideal_flow_params(es_object)[source]

Transform an energy system object dict into a ready to pass ideal flow parameter dict.

Read-in the dictionary representation of an energy system object to extract ideal optimization flow parameters and transform them into a keyword argument dictionary ready to provide to oemof.solph.network.Flow.

A flow is regarded as ‘ideal’ in this context as a flow that has no ‘physical’ restriction, i.e. no gradient, no maximum, no minimum, etc. Available ideal flow parameters are the following: (see also oemof.solph.network.Flow)

  • oemof.solph.network.Flow.variable_costs

  • emissions

Note

An ideal flow can still be subject to an ‘expansion_plan’ problem. The respective parsing however is handled in parse_invest_flow_params().

Parameters:

es_object (pandas.Series) –

Series representation of the energy system node of which the timeseries is to be parsed.

(Usually accessed by string keying the columns of a pandas.DataFrame which in themselves are keyed by a timeseries-like key inside an energy system dictionary which is usually returned by one of the tessif.parse functionalities)

Returns:

ideal_flow_parameters – Dictionary having keyword-value pairings ready to pass to oemof.solph.network.Flow.

Return type:

dict

tessif.transform.mapping2es.omf.parse_linear_flow_params(es_object)[source]

Transform an energy system object dict into a ready to pass linear flow parameter dict.

Read-in the dictionary representation of an energy system object to extract linear optimization flow parameters and transform them into a keyword argument dictionary ready to provide to oemof.solph.network.Flow.

A flow is regarded as ‘linear’ in this context as a flow that only has linear ‘physical’ restriction, ie. gradient, maximum, minimum, and is otherwise characterized by b actual or nominal values. Available linear flow parameters are the following: (see also oemof.solph.network.Flow)

  • oemof.solph.network.Flow.nominal_value

  • oemof.solph.network.Flow.summed_min

  • oemof.solph.network.Flow.summed_max

  • oemof.solph.network.Flow.min

  • oemof.solph.network.Flow.max

  • oemof.solph.network.Flow.positive_gradient

  • oemof.solph.network.Flow.negative_gradient

  • oemof.solph.network.Flow.nominal_value

Note

A linear flow can still be subject to an ‘expansion_plan’ problem. The respective parsing however is handled in parse_invest_flow_params().

Parameters:

es_object (pandas.Series) –

Series representation of the energy system node of which the timeseries is to be parsed.

(Usually accessed by string keying the columns of a pandas.DataFrame which in themselves are keyed by a timeseries-like key inside an energy system dictionary which is usually returned by one of the tessif.parse functionalities)

Returns:

linear_flow_parameters – Dictionary having keyword-value pairings ready to pass to oemof.solph.network.Flow.

Return type:

dict

tessif.transform.mapping2es.omf.parse_invest_flow_params(es_object)[source]

Transform an energy system object dict into a ready to pass invest flow parameter dict.

Read-in the dictionary representation of an energy system object to extract investment optimization flow parameters and transform them into a keyword argument dictionary ready to provide to oemof.solph.network.Flow.

A flow is regarded as ‘investment’ in this context as a flow that has no nominal value (aka installed capacity) given as input. But rather one of which the installed capacity is subject to the optimization problem. Available investment flow parameters are the following: (see also oemof.solph.options.Investment)

  • oemof.solph.options.Investment.maximum

  • oemof.solph.options.Investment.minimum

  • oemof.solph.options.Investment.ep_costs

  • oemof.solph.options.Investment.existing

Note

Any non-convex flow can be subject to an investment flow.

Parameters:

es_object (pandas.Series) –

Series representation of the energy system node of which the timeseries is to be parsed.

(Usually accessed by string keying the columns of a pandas.DataFrame which in themselves are keyed by a timeseries-like key inside an energy system dictionary which is usually returned by one of the tessif.parse functionalities)

Returns:

investment_flow_parameters – Dictionary having keyword-value pairings ready to pass to oemof.solph.network.Flow.

Return type:

dict

tessif.transform.mapping2es.omf.parse_nonconvex_flow_params(es_object)[source]
Transform an energy system object dict into a ready to pass NonConvex

flow parameter dict.

Read-in the dictionary representation of an energy system object to extract NonConvex optimization flow parameters and transform them into a keyword argument dictionary ready to provide to oemof.solph.network.Flow.

A flow is regarded as ‘NonConvex’ in this context as a flow that has mixed integer linear ‘physical’ restrictions i.e, able to turn ‘off’, but having a minimum greater than 0. Available nonconvex flow parameters are the following: (see also oemof.solph.options.NonConvex)

  • oemof.solph.options.NonConvex.startup_costs

  • oemof.solph.options.NonConvex.shutdown_costs

  • oemof.solph.options.NonConvex.activity_costs

  • oemof.solph.options.NonConvex.minimum_uptime

  • oemof.solph.options.NonConvex.minimum_downtime

  • oemof.solph.options.NonConvex.maximum_startups

  • oemof.solph.options.NonConvex.maximum_shutdowns'

  • oemof.solph.options.NonConvex.initial_status

Note

Any non investment flow can be subject to a nonconvex flow.

Parameters:

es_object (pandas.Series) –

Series representation of the energy system node of which the timeseries is to be parsed.

(Usually accessed by string keying the columns of a pandas.DataFrame which in themselves are keyed by a timeseries-like key inside an energy system dictionary which is usually returned by one of the tessif.parse functionalities)

Returns:

nonconvex_flow_parameters – Dictionary having keyword-value pairings ready to pass to oemof.solph.network.Flow.

Return type:

dict

tessif.transform.mapping2es.omf.parse_fixed_flow_params(es_object)[source]

Transform an energy system object dict into a ready to pass fixed flow parameter dict.

Read-in the dictionary representation of an energy system object to extract fixed flow parameters and transform them into a keyword argument dictionary ready to provide to oemof.solph.network.Flow.

A flow is regarded as ‘fixed’ in this context as a flow that is set outside of the optimization flow problem, i.e the value(s) for oemof.solph.network.Flow.fix are read-in/hardcoded before the actual Flow object initialization takes place. During the optimization the flow is then fixed to fix \(\cdot\) nominal_value.

Available ideal flow parameters are the following: (see also oemof.solph.network.Flow)

  • oemof.solph.network.Flow.fix

  • emissions

Note

A fixed flow can still be subject to an ‘expansion_plan’ problem. The respective parsing however is handled in parse_invest_flow_params().

Parameters:

es_object (pandas.Series) –

Series representation of the energy system node of which the timeseries is to be parsed.

(Usually accessed by string keying the columns of a pandas.DataFrame which in themselves are keyed by a timeseries-like key inside an energy system dictionary which is usually returned by one of the tessif.parse functionalities.

Returns:

fixed_flow_parameters – Dictionary having keyword-value pairings ready to pass to oemof.solph.network.Flow.

Return type:

dict

tessif.transform.mapping2es.omf.parse_flow_parameters(es_object={}, timeseries={})[source]

Transform an energy system object dict into a ready to pass flow parameter dict.

Read-in the dictionary representation of an energy system object to extract fixed flow parameters and transform them into a keyword argument dictionary ready to provide to oemof.solph.network.Flow.

Parameters:
  • es_object (pandas.Series) –

    Series representation of the energy system node of which the timeseries is to be parsed.

    (Usually accessed by string keying the columns of a pandas.DataFrame which in themselves are keyed by a timeseries-like key inside an energy system dictionary which is usually returned by one of the tessif.parse functionalities)

  • timeseries (dict) – Dictionary containing a string of the represented kind of timeseries (i.e. min, max, fix, variable_cost see oemof.solph.network.Flow) as key and the corresponding timeseries as sequence as value.

Returns:

parsed_flow_parameters – Dictionary having keyword-value pairings ready to pass to oemof.solph.network.Flow.

Return type:

dict

tessif.transform.mapping2es.omf.parse_timeseries(es_object, energy_system_dict)[source]

Create a timeseries mapping for the es_object by looking up its data inside the energy_system_dict.

Note

Timeseries data is expected to be string keyed like:

{ES_OBJECT}{SEPERATOR}{TIMESERIES_PARAMETER}.

So for example:

PV.max
Onshore.fix

Where SEPERATOR is the timeseries_seperator.

Parameters:
  • es_object (pandas.Series) –

    Series representation of the energy system node of which the timeseries is to be parsed.

    (Usually accessed by string keying the columns of a pandas.DataFrame which in themselves are keyed by a timeseries-like key inside the energy_system_dict.

  • energy_system_dict (dict) – Dictionary of pandas.DataFrame objects keyed strings. With the key strings representing energy system components. Usually returned by something like the tessif.parse functionalities.

Returns:

timeseries – Dictionary containing a string of the represented kind of timeseries (i.e. min, max, fix, variable_cost see oemof.solph.network.Flow) as key and the corresponding timeseries as sequence as value.

Return type:

dict

tessif.transform.mapping2es.omf.generate_busses(energy_system_dict)[source]

Generate Bus objects out of the energy_system_dict.

Parameters:

energy_system_dict (dict) – Dictionary of pandas.DataFrame objects keyed by strings. With the key strings representing energy system components. Usually returned by something like the tessif.parse functionalities.

Returns:

generated_busses – Generator object yielding the parsed bus objects.

Return type:

Generator

tessif.transform.mapping2es.omf.generate_sources(energy_system_dict, bus_dict)[source]

Generate Source objects out of the energy_system_dict connecting to the Bus objects in bus_dict

Parameters:
  • energy_system_dict (dict) – Dictionary of pandas.DataFrame objects keyed by strings. With the key strings representing energy system components. Usually returned by something like the tessif.parse functionalities.

  • bus_dict (dict) – Dictionary of Bus objects keyed by their str(label) representation.

Returns:

generated_sources – Generator object yielding the parsed source objects.

Return type:

Generator

tessif.transform.mapping2es.omf.generate_sinks(energy_system_dict, bus_dict)[source]

Generate Sink objects out of the energy_system_dict connecting to the Bus objects in bus_dict

Parameters:
  • energy_system_dict (dict) – Dictionary of pandas.DataFrame objects keyed by strings. With the key strings representing energy system components. Usually returned by something like the tessif.parse functionalities.

  • bus_dict (dict) – Dictionary of Bus objects keyed by their str(label) representation.

Returns:

generated_sinks – Generator object yielding the parsed sink objects.

Return type:

Generator

tessif.transform.mapping2es.omf.generate_mimo_transformers(energy_system_dict, bus_dict)[source]

Generate multiple-input multiple output Transformer objects out of the energy_system_dict connecting to the Bus objects in bus_dict

Note

Mimo transformer parsing assumes zero-based numbering! and are parsed based on respective spellings.

Notably:

Parameters:
  • energy_system_dict (dict) – Dictionary of pandas.DataFrame objects keyed by strings. With the key strings representing energy system components. Usually returned by something like the tessif.parse functionalities.

  • bus_dict (dict) – Dictionary of Bus objects keyed by their str(label) representation.

Returns:

generated_transformers – Generator object yielding the parsed transformer objects.

Return type:

Generator

tessif.transform.mapping2es.omf.generate_sito_flex_transformers(energy_system_dict, bus_dict)[source]

Generate single input two output ExtractionTurbineCHP objects out of the energy_system_dict connecting to the Bus objects in bus_dict

Note

Sito flex transformer parsing assumes zero-based numbering! for the outflows and are parsed based on respective spellings.

Notably:

Parameters:
  • energy_system_dict (dict) – Dictionary of pandas.DataFrame objects keyed by strings. With the key strings representing energy system components. Usually returned by something like the tessif.parse functionalities.

  • bus_dict (dict) – Dictionary of Bus objects keyed by their str(label) representation.

Returns:

generated_sito_flex_transformers – Generator object yielding the parsed Single Input Two Output Flexible Transformer objects.

Return type:

Generator

tessif.transform.mapping2es.omf.generate_generic_chps(energy_system_dict, bus_dict, timeindex=None)[source]

Generate single input two output GenericCHP objects out of the energy_system_dict connecting to the Bus objects in bus_dict

Note

This might become a convenience wrapper interface to parameterize the objects more intuitively.

Following mapping is used for parsing:

parameter_name_mapping = {
    'minimum_fuelgas_losses': 'H_L_FG_share_min',
    'maximum_fuelgas_losses': 'H_L_FG_share_max',
    'maximum_power': 'P_max_woDH',
    'minimum_power': 'P_min_woDH',
    'maximum_efficiency': 'Eta_el_max_woDH',
    'minimum_efficiency': 'Eta_el_min_woDH',
    'minimum_heat': 'Q_CW_min',
    'power_loss_index': 'Beta',}

Where the respective spellings (left hand side) are mapped to the GenericCHP parameters (right hand side)

Parameters:
  • energy_system_dict (dict) – Dictionary of pandas.DataFrame objects keyed by strings. With the key strings representing energy system components. Usually returned by something like the tessif.parse functionalities.

  • bus_dict (dict) – Dictionary of Bus objects keyed by their str(label) representation.

  • timeindex (DatetimeIndex, default=None) – Representation of the time frame and resolution used in the simulation. If none, the timeindex is tried to be inferred from energy_system_dict using infer_timeindex().

Returns:

generated_generic_chps – Generator object yielding the parsed generic chp objects.

Return type:

Generator

tessif.transform.mapping2es.omf.generate_siso_nonlinear_transformers(energy_system_dict, bus_dict)[source]

Generate OffsetTransformer objects out of the energy_system_dict connecting to the Bus objects in bus_dict

Parameters:
  • energy_system_dict (dict) – Dictionary of pandas.DataFrame objects keyed by strings. With the key strings representing energy system components. Usually returned by something like the tessif.parse functionalities.

  • bus_dict (dict) – Dictionary of Bus objects keyed by their str(label) representation.

Returns:

generated_siso_nonlinear_transformers – Generator object yielding the parsed offset transformer objects.

Return type:

Generator

tessif.transform.mapping2es.omf.generate_generic_storages(energy_system_dict, bus_dict)[source]

Generate GenericStorage objects out of the energy_system_dict connecting to the Bus objects in bus_dict

Parameters:
  • energy_system_dict (dict) – Dictionary of pandas.DataFrame objects keyed by strings. With the key strings representing energy system components. Usually returned by something like the tessif.parse functionalities.

  • bus_dict (dict) – Dictionary of Bus objects keyed by their str(label) representation.

Returns:

generated_generic_storages – Generator object yielding the parsed offset storage objects.

Return type:

Generator

tessif.transform.mapping2es.omf.create_nodes(es_object_types, info_tag='Info', bus_tag='Grid', renewables_tag='Renewable', chp_tag='CHP', powerplant_tag='PowerPlant', heatplant_tag='HeatPlant', commodity_tag='Commodity', demand_tag='Demand', timeseries_tag='Timeseries')[source]

Create the energy system nodes.

tessif.transform.mapping2es.omf.infer_timeindex(energy_system_dictionary)[source]

Try inferring the timeindex from the energy system dictionairy.

The timeframe to be simulated is referred to here as “timeindex”.

Parameters:

energy_system_dictionary (dict) – Dictionairy containing the energy system data. Typically returned by one of the tessif.parse functionalities

Returns:

timeindex – The time frame inferred from the energy system dictionairy.

Return type:

DatetimeIndex

Example

Setting spellings.get_from's logging level to debug for decluttering doctest output:

>>> from tessif.frused import configurations
>>> configurations.spellings_logging_level = 'debug'

Read in the oemof standard energy system and transform it:

>>> import os
>>> from tessif.frused.paths import example_dir
>>> from tessif.parse import xl_like
>>> import tessif.transform.mapping2es.omf as tomf
>>> idx = tomf.infer_timeindex(xl_like(
...     os.path.join(
...         example_dir, 'data', 'omf', 'xlsx', 'energy_system.xlsx')))
>>> print(idx)
DatetimeIndex(['2016-01-01 00:00:00', '2016-01-01 01:00:00',
               '2016-01-01 02:00:00', '2016-01-01 03:00:00',
               '2016-01-01 04:00:00'],
              dtype='datetime64[ns]', freq='H')
tessif.transform.mapping2es.omf.transform(energy_system_dictionary, **kwargs)[source]

Transform an ES dict to an oemof EnergySystem

Parameters:
  • energy_system_dictionary (dict) – Dictionairy containing the energy system data. Typically returned by one of the tessif.parse functionalities

  • timeindex (DatetimeIndex, default=None) – Representation of the time frame and resolution If not stated it is tried to be inferred.

  • global_constraints (dict, default={'emissions': float('+inf')}) – Dictionairy of constraint values mapped to constraint names.

  • kwargs – Key word arguments are passed to add()

Returns:

energy_system – The dictionairy transformed oemof energy system, ready for simulation.

Return type:

EnergySystem

Example

Setting spellings.get_from's logging level to debug for decluttering doctest output:

>>> from tessif.frused import configurations
>>> configurations.spellings_logging_level = 'debug'

Read in the oemof standard energy system and transform it:

>>> import os
>>> from tessif.frused.paths import example_dir
>>> from tessif.parse import xl_like
>>> import tessif.transform.mapping2es.omf as tomf
>>> es = tomf.transform(xl_like(
...     os.path.join(
...         example_dir, 'data', 'omf', 'xlsx', 'energy_system.xlsx')))
>>> print(type(es))
<class 'oemof.solph.network.energy_system.EnergySystem'>
>>> print(*[node for node in es.nodes if str(node.label) == 'Power Grid'])
Power Grid

Read in an ods version instead:

>>> es = tomf.transform(xl_like(
...     os.path.join(
...         example_dir, 'data', 'omf', 'xlsx', 'energy_system.ods'),
...     engine='odf'))