oemof.solph.views¶
Modules for providing convenient views for solph results.
See examples for to learn about the possible usage of the provided functions.
- class oemof.solph.views.NodeOption(value)[source]¶
Bases:
str
,Enum
An enumeration.
- All = 'all'¶
- HasInputs = 'has_inputs'¶
- HasOnlyInputs = 'has_only_inputs'¶
- HasOnlyOutputs = 'has_only_outputs'¶
- HasOutputs = 'has_outputs'¶
- oemof.solph.views.convert_to_multiindex(group, index_names=None, droplevel=None)[source]¶
Convert dict to pandas DataFrame with multiindex
- Parameters:
group (dict) – Sequences of the oemof.solph.Model.results dictionary
index_names (arraylike) – Array with names of the MultiIndex
droplevel (arraylike) – List containing levels to be dropped from the dataframe
- oemof.solph.views.filter_nodes(results, option=NodeOption.All, exclude_busses=False)[source]¶
Get set of nodes from results-dict for given node option.
This function filters nodes from results for special needs. At the moment, the following options are available:
NodeOption.All
: ‘all’: Returns all nodesNodeOption.HasOutputs
: ‘has_outputs’:Returns nodes with an output flow (eg. Converter, Source)
NodeOption.HasInputs
: ‘has_inputs’:Returns nodes with an input flow (eg. Converter, Sink)
NodeOption.HasOnlyOutputs
: ‘has_only_outputs’:Returns nodes having only output flows (eg. Source)
NodeOption.HasOnlyInputs
: ‘has_only_inputs’:Returns nodes having only input flows (eg. Sink)
Additionally, busses can be excluded by setting exclude_busses to True.
- Parameters:
results (dict)
option (NodeOption)
exclude_busses (bool) – If set, all bus nodes are excluded from the resulting node set.
- Returns:
set
– A set of Nodes.
- oemof.solph.views.get_node_by_name(results, *names)[source]¶
Searches results for nodes
Names are looked up in nodes from results and either returned single node (in case only one name is given) or as list of nodes. If name is not found, None is returned.
- oemof.solph.views.net_storage_flow(results, node_type)[source]¶
Calculates the net storage flow for storage models that have one input edge and one output edge both with flows within the domain of non-negative reals.
- Parameters:
results (dict) – A result dictionary from a solved oemof.solph.Model object
node_type (oemof.solph class) – Specifies the type for which (storage) type net flows are calculated, e.g. solph.components.GenericStorage
- Returns:
pandas.DataFrame object with multiindex colums. Names of levels of columns – are: from, to, net_flow.
Examples
import oemof.solph as solph from oemof.solph import views # solve oemof solph model 'm' # Then collect node weights views.net_storage_flow( m.results(), node_type=solph.components.GenericStorage )
- oemof.solph.views.node(results, node, multiindex=False, keep_none_type=False)[source]¶
Obtain results for a single node e.g. a Bus or Component.
Either a node or its label string can be passed. Results are written into a dictionary which is keyed by ‘scalars’ (resp. ‘periods_scalars’ for a multi-period model) and ‘sequences’ holding respective data in a pandas Series (resp. DataFrame) and DataFrame.
- oemof.solph.views.node_input_by_type(results, node_type, droplevel=None)[source]¶
Gets all inputs for all nodes of the type node_type and returns a dataframe.
- Parameters:
results (dict) – A result dictionary from a solved oemof.solph.Model object
node_type (oemof.solph class) – Specifies the type of the node for that inputs are selected, e.g. solph.components.Sink
droplevel (list)
Examples
from oemof import solph from oemof.solph import views # solve oemof solph model 'm' # Then collect node weights views.node_input_by_type( m.results(), node_type=solph.components.Sink )
- oemof.solph.views.node_output_by_type(results, node_type, droplevel=None)[source]¶
Gets all outputs for all nodes of the type node_type and returns a dataframe.
- Parameters:
results (dict) – A result dictionary from a solved oemof.solph.Model object
node_type (oemof.solph class) – Specifies the type of the node for that outputs are selected, e.g. solph.components.Converter
droplevel (list)
Examples
import oemof.solph as solph from oemof.solph import views # solve oemof solph model 'm' # Then collect node weights views.node_output_by_type( m.results(), node_type=solph.components.Converter )
- oemof.solph.views.node_weight_by_type(results, node_type)[source]¶
Extracts node weights (if exist) of all components of the specified node_type.
Node weight are endogenous optimzation variables associated with the node and not the edge between two node, foxample the variable representing the storage level.
- Parameters:
results (dict) – A result dictionary from a solved oemof.solph.Model object
node_type (oemof.solph class) – Specifies the type for which node weights should be collected, e.g. solph.components.GenericStorage
Example
from oemof.solph import views # solve oemof model 'm' # Then collect node weights views.node_weight_by_type( m.results(), node_type=solph.components.GenericStorage )