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 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
- Parameters:
df_dict (dict) – dict of pd.DataFrames, keyed by oemof tuples
k (tuple) – oemof tuple for results processing
- 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 metadata from the Solver. Feel free to add more keys.
Valid keys of the resulting dictionary are: ‘objective’, ‘problem’, ‘solver’.
- omoemof.solph.Model
A solved Model.
- undefinedbool
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 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.
Examples
Standard model: results[idx][‘scalars’] and flows results[n, n][‘sequences’].
Multi-period model: results[idx][‘period_scalars’] and flows 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 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.