oemof.solph.views

Modules for providing convenient views for solph results.

Information about the possible usage is provided within the examples.

class oemof.solph.views.NodeOption[source]

Bases: str, enum.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: '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:

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

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’ and ‘sequences’ holding respective data in a pandas Series 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)
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.Transformer
  • droplevel (list)
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