oemof.solph.processing

Modules for providing a convenient data structure for solph results.

Information about the possible usage is provided within the examples.

oemof.solph.processing.convert_keys_to_strings(result, keep_none_type=False)[source]

Convert the dictionary keys to strings.

All (tuple) keys of the result object e.g. results[(pp1, bus1)] are converted into strings that represent the object labels e.g. results[(‘pp1’,’bus1’)].

oemof.solph.processing.create_dataframe(om)[source]

Create a result dataframe with all optimization data.

Results from Pyomo are written into pandas DataFrame where separate columns are created for the variable index e.g. for tuples of the flows and components or the timesteps.

oemof.solph.processing.divide_scalars_sequences(df_dict, k)[source]
oemof.solph.processing.get_timestep(x)[source]

Get the timestep from oemof tuples.

The timestep from tuples (n, n, int), (n, n), (n, int) and (n,) is fetched as the last element. For time-independent data (scalars) zero ist returned.

oemof.solph.processing.get_tuple(x)[source]

Get oemof tuple within iterable or create it.

Tuples from Pyomo are of type (n, n, int), (n, n) and (n, int). For single nodes n a tuple with one object (n,) is created.

oemof.solph.processing.meta_results(om, undefined=False)[source]

Fetch some meta data from the Solver. Feel free to add more keys.

Valid keys of the resulting dictionary are: ‘objective’, ‘problem’, ‘solver’.

om : oemof.solph.Model
A solved Model.
undefined : bool
By default (False) only defined keys can be found in the dictionary. Set to True to get also the undefined keys.
Returns:dict
oemof.solph.processing.parameter_as_dict(system, exclude_none=True, exclude_attrs=None)[source]

Create a result dictionary containing node parameters.

Results are written into a dictionary of pandas objects where a Series holds all scalar values and a dataframe all sequences for nodes and flows. The dictionary is keyed by flows (n, n) and nodes (n, None), e.g. parameter[(n, n)][‘sequences’] or parameter[(n, n)][‘scalars’].

Parameters:
  • system (energy_system.EnergySystem) – A populated energy system.
  • exclude_none (bool) – If True, all scalars and sequences containing None values are excluded
  • exclude_attrs (Optional[List[str]]) – Optional list of additional attributes which shall be excluded from parameter dict
Returns:

dict (Parameters for all nodes and flows)

oemof.solph.processing.remove_timestep(x)[source]

Remove the timestep from oemof tuples.

The timestep is removed from tuples of type (n, n, int) and (n, int).

oemof.solph.processing.results(model, remove_last_time_point=False)[source]

Create a result dictionary from the result DataFrame.

Results from Pyomo are written into a dictionary of pandas objects where a Series holds all scalar values and a dataframe all sequences for nodes and flows. The dictionary is keyed by the nodes e.g. results[idx][‘scalars’] and flows e.g. results[n, n][‘sequences’].

Parameters:
  • model (oemof.solph.BaseModel) – A solved oemof.solph model.
  • remove_last_time_point (bool) – The last time point of all TIMEPOINT variables is removed to get the same length as the TIMESTEP (interval) variables without getting nan-values. By default the last time point is removed if it has not been defined by the user in the EnergySystem but inferred. If all time points has been defined explicitly by the user the last time point will not be removed by default. In that case all interval variables will get one row with nan-values to have the same index for all variables.
oemof.solph.processing.set_result_index(df_dict, k, result_index)[source]