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’)].


Create a result DataFrame with all optimization data

Results from Pyomo are written into one common 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]

Split results into scalars and sequences results

  • df_dict (dict) – dict of pd.DataFrames, keyed by oemof tuples

  • k (tuple) – oemof tuple for results processing


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.


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 metadata from the Solver. Feel free to add more keys.

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


A solved Model.


By default (False) only defined keys can be found in the dictionary. Set to True to get also the undefined keys.



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’].

  • 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


dict (Parameters for all nodes and flows)


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 nested result dictionary from the result DataFrame

The already rearranged results from Pyomo from the result DataFrame are transferred into a nested dictionary of pandas objects. The first level key of that dictionary is a node (denoting the respective flow or component).

The second level keys are “sequences” and “scalars” for a standard model:

  • A pd.DataFrame holds all results that are time-dependent, i.e. given as a sequence and can be indexed with the energy system’s timeindex.

  • A pd.Series holds all scalar values which are applicable for timestep 0 (i.e. investments).

For a multi-period model, the second level key for “sequences” remains the same while instead of “scalars”, the key “period_scalars” is used:

  • For sequences, see standard model.

  • Instead of a pd.Series, a pd.DataFrame holds scalar values indexed by periods. These hold investment-related variables.


  • Standard model: results[idx][‘scalars’] and flows results[n, n][‘sequences’].

  • Multi-period model: results[idx][‘period_scalars’] and flows results[n, n][‘sequences’].

  • 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 have 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]

Define index for results

  • df_dict (dict) – dict of pd.DataFrames, keyed by oemof tuples

  • k (tuple) – oemof tuple for results processing

  • result_index (pd.Index) – Index to use for results

oemof.solph.processing.set_sequences_index(df, result_index)[source]