oemof.outputlib package

Module contents

class oemof.outputlib.DataFramePlot(**kwargs)[source]

Bases: oemof.outputlib.ResultsDataFrame

Creates plots based on the subset of a multi-indexed pandas dataframe of the ResultsDataFrame class.

Parameters:
  • subset (pandas.DataFrame) – A subset of the results DataFrame.
  • ax (matplotlib axis object) – Axis object of the last plot.
subset

pandas.DataFrame

A subset of the results DataFrame.

ax

matplotlib axis object

Axis object of the last plot.

color_from_dict(colordict)[source]

Method to convert a dictionary containing the components and its colors to a color list that can be directly used with the color parameter of the pandas plotting method.

Parameters:colordict (dictionary) – A dictionary that has all possible components as keys and its colors as items.
Returns:Containing the colors of all components of the subset attribute
Return type:list
io_plot(bus_label, cdict, line_kwa=None, lineorder=None, bar_kwa=None, barorder=None, **kwargs)[source]

Plotting a combined bar and line plot to see the fitting of in- and out-coming flows of a bus balance.

Parameters:
  • bus_label (string) – Uid of the bus to plot the balance.
  • cdict (dictionary) – A dictionary that has all possible components as keys and its colors as items.
  • line_kwa (dictionary) – Keyword arguments to be passed to the pandas line plot.
  • bar_kwa (dictionary) – Keyword arguments to be passed to the pandas bar plot.
  • lineorder (list) – Order of columns to plot the line plot
  • barorder (list) – Order of columns to plot the bar plot

Note

Further keyword arguments will be passed to the slice_unstacked method.

Returns:Manipulated labels to correct the unusual construction of the stack line plot. You can use them for further manipulations.
Return type:handles, labels
outside_legend(reverse=False, plotshare=0.9, **kwargs)[source]

Move the legend outside the plot. Bases on the ideas of Joe Kington. See http://stackoverflow.com/questions/4700614/how-to-put-the-legend-out-of-the-plot for more information.

Parameters:
  • reverse (boolean (default: False)) – Print out the legend in reverse order. This is interesting for stack-plots to have the legend in the same order as the stacks.
  • plotshare (real (default: 0.9)) – Share of the plot area to create space for the legend (0 to 1).
Other Parameters:
 
  • loc (string (default: ‘center left’)) – Location of the plot.
  • bbox_to_anchor (tuple (default: (1, 0.5))) – Set the anchor for the legend.
  • ncol (integer (default: 1)) – Number of columns of the legend.
  • handles (list of handles) – A list of handels if they are already modified by another function or method. Normally these handles will be automatically taken from the artist object.
  • lables (list of labels) – A list of labels if they are already modified by another function or method. Normally these handles will be automatically taken from the artist object.

Note

All keyword arguments (kwargs) will be directly passed to the matplotlib legend class. See http://matplotlib.org/api/legend_api.html#matplotlib.legend.Legend for more parameters.

plot(**kwargs)[source]

Passing the subset attribute to the pandas plotting method. All parameters will be directly passed to pandas.DataFrame.plot(). See http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.plot.html for more information.

Returns:
Return type:self
rearrange_subset(order)[source]

Change the order of the subset DataFrame

Parameters:order (list) – New order of columns
Returns:
Return type:self
set_datetime_ticks(tick_distance=None, number_autoticks=3, date_format='%d-%m-%Y %H:%M')[source]

Set configurable ticks for the time axis. One can choose the number of ticks or the distance between ticks and the format.

Parameters:
  • tick_distance (real) – The distance between to ticks in hours. If not set autoticks are set (see number_autoticks).
  • number_autoticks (int (default: 3)) – The number of ticks on the time axis, independent of the time range. The higher the number of ticks is, the shorter should be the date_format string.
  • date_format (string (default: '%d-%m-%Y %H:%M')) – The string to define the format of the date and time. See https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior for more information.
slice_unstacked(unstacklevel='obj_label', **kwargs)[source]

Method for slicing the ResultsDataFrame. The subset attribute will set to an unstacked subset. The self-attribute is returned to allow chaining. This method is an extension of the slice_unstacked method of the ResultsDataFrame class (parent class).

Parameters:unstacklevel (string (default: 'obj_label')) – Level to unstack the subset of the DataFrame.
class oemof.outputlib.ResultsDataFrame(**kwargs)[source]

Bases: pandas.core.frame.DataFrame

Creates a multi-indexed pandas dataframe from a solph result object and holds methods to create subsets of the data.

Note

This is so far only a rough sketch and serves as a base for discussion.

Parameters:
  • result_object (dictionary) – solph result objects
  • bus_labels (list if strings) – List of strings with buses that should be contained in dataframe. If not set, all buses are contained.
result_object

dictionary

solph result objects

bus_labels

list if strings

List of strings with buses that should be contained in dataframe. If not set, all buses are contained.

bus_types

list if strings

List of strings with bus types that should be contained in dataframe. If not set, all bus types are contained.

data_frame

pandas dataframe

Multi-indexed pandas dataframe holding the data from the result object. For more information on advanced dataframe indexing see: http://pandas.pydata.org/pandas-docs/stable/advanced.html

slice_by(**kwargs)[source]

Method for slicing the ResultsDataFrame. A subset is returned.

Other Parameters:
 
  • bus_label (string)
  • type (string (to_bus/from_bus/other))
  • obj_label (string)
  • date_from (string) – Start date selection e.g. “2016-01-01 00:00:00”. If not set, the whole time range will be plotted.
  • date_to (string) – End date selection e.g. “2016-03-01 00:00:00”. If not set, the whole time range will be plotted.
slice_unstacked(unstacklevel='obj_label', formatted=False, **kwargs)[source]

Method for slicing the ResultsDataFrame. An unstacked subset is returned.

Parameters:
  • unstacklevel (string (default: 'obj_label')) – Level to unstack the subset of the DataFrame.
  • formatted (boolean) – missing...