Plotter¶
File name: plotter.py
Last edited: 2020-06-14
Created by: Stefan Bruche (TU Berlin)
The Plotter class provides three basic plotting methods:
plot_operation
: A mixed bar and line plot that visualizes the operation of a component on the basis of a selected commodity.plot_objective
: Bar chart that summarizes the cost contributions of each component to the overall objective function value.quick_plot
: Quick visualization for the values of one component variable as a line, scatter, or bar plot.
Note
The results of the optimization are exported to dictionaries and stored as strings in a json-file to easily handle multidimensional indices (e.g. tuples). To evaluate the Python strings we use the function “literal_eval” from the python built in library “ast”. (the strings can only consist of: strings, bytes, numbers, tuples, lists, dicts, sets, booleans, and None) [Ref]
- class aristopy.plotter.Plotter(json_file)[source]¶
The Plotter class provides three basic plotting methods:
plot_operation
plot_objective
quick_plot
- Parameters
json_file – Path to the optimization results file in JSON-Format
- plot_objective(show_plot=False, save_plot=True, file_name='objective_plot', **kwargs)[source]¶
Method to create a bar chart that summarizes the cost contributions of each component of the EnergySystem instance to the overall objective function value.
- Parameters
show_plot (bool) – State whether the plot should be shown once finalized
Default: Falsesave_plot (bool) – State whether the plot should be saved once finalized
Default: Truefile_name (str) – Name of the file (if saved); no file-ending required
Default: ‘objective_plot’kwargs – Additional keyword arguments to manipulate the plot (e.g., labels, figure size, legend position, …). See dict ‘props’ of the Plotter class.
- quick_plot(component_name, variable_name, kind='bar', save_plot=False, file_name=None)[source]¶
Method to create a quick visualization for the values of one component variable as a line, scatter, or bar plot.
- Parameters
component_name (str) – Name of the component that holds the variable of interest.
variable_name (str) – Name of the variable (or parameter) that should be plotted.
kind (str) – States the kind of plot. Possible options are: ‘plot’ (line plot), ‘scatter’, ‘bar’.
Default: ‘bar’save_plot (bool) – State whether the plot should be saved once finalized
Default: Falsefile_name (str) – Name of the file (if saved); no file-ending required. Name is auto-generated if None is provided and plot should be saved.
Default: None
- plot_operation(component_name, commodity, level_of_detail=2, scale_to_hourly_resolution=False, plot_single_period_with_index=None, show_plot=False, save_plot=True, file_name='operation_plot', **kwargs)[source]¶
Method to create a mixed bar and line plot that visualizes the operation of a component on the basis of a selected commodity.
- Parameters
component_name (str) – Name of the component that holds the commodity of interest.
commodity (str) – Name of the commodity that should be plotted.
level_of_detail (int (1 or 2)) – Specifies the level of plotting detail. Only the commodity in the component itself is plotted if 1 is selected. The composition of the commodity (from which sources formed and to which destinations sent) is visualized if 2 is selected.
Default: 2scale_to_hourly_resolution (bool) – States if the data should be scaled to hourly resolution before plotting. This might be useful, if the optimization was performed with a value for the EnergySystem keyword argument ‘hours_per_time_step’ larger than 1.
Default: Falseplot_single_period_with_index (int or None) – States if only one period with the given index number should be plotted. This is only possible if the optimization was performed with aggregated time series data.
Default: Noneshow_plot (bool) – State whether the plot should be shown once finalized
Default: Falsesave_plot (bool) – State whether the plot should be saved once finalized
Default: Truefile_name (str) – Name of the file (if saved); no file-ending required
Default: ‘operation_plot’kwargs – Additional keyword arguments to manipulate the plot (e.g., labels, figure size, legend position, …). See dict ‘props’ of the Plotter class.