analyze
Singular Model Assessment
Estimate the scalability of a chosen energy system simulation model. |
|
Algorithm to detect intervals in which the given timeseries deviate from their mean by a certain threshold. |
|
Function to calculate the pearson correlation coefficient to quickly sort out difference between two different models |
|
Compares two datasets by applying a lag correlation analysis, to find out whether a potential (time) lag exists. |
|
Algorithm to calculate a number of statistical (values) for the given timeseries relative to their reference timeseries. |
|
Measure elapsed wall time. |
|
Trace allocated memory. |
Model Comparison
Quickly compare any number of tessif's supported energy supply system simulation models. |
|
|
|
|
|
Dictionary of |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Utility to compare the load results of 2 models by using a lag correlation. |
|
Bar plot for comparing the numerical results. |
|
|
|
|
Utilities
Utility for creating comparative dataframes out of optimization results. |
analyze is a tessif module aggregating functionalities
for inspecting energy system simulation models
to evaluate and compare them.
It serves as main reference point for tessif’s scientific evaluation process.
- tessif.analyze.assess_scalability(N, T, model, N_resolution=4, T_resolution=4, only_total=False, storage_folder=None, example='minimal', **kwargs)[source]
Estimate the scalability of a chosen energy system simulation model. Investigate an energy system simulation model for scalability in simulated time as well as number of components.
- Parameters:
Number of minimum self similar energy system units (MiSSESUs) the
self similar energy systemconsists of.(Adding a stepping parameter for N might also be helpful. Add one if you deem helpful/necessary)
Number of timeframe steps used for scaling.
Has to be 2 or higher.
(Adding a stepping parameter for T might also be helpful. Add one if you deem helpful/necessary)
model¶ (str) – String specifying one of the
registered_modelsrepresenting the energy system simulation model investigated.N_resolution¶ (int, default=4) –
Number of different energy system sizes to be measured.
The amount of measured sizes might sometimes be fewer than the specified value if that is similar in size to the value of N.
T_resolution¶ (int, default=4) –
Number of different timeframes to be measured.
The amount of timeframes might sometimes be fewer than the specified value if that is similar in size to the value of T.
only_total¶ (bool, default=False) – Set to true to only return the total result.
storage_folder¶ (str, None, default=None) –
String representing the top level folder the energy system data will be stored in.
If
NonetheN-thenergy system will be stored inexamples_dir/application/computational_comparison/scalability/es_NSee
tessif.frused.paths.examples_dirfor more information on its location.example¶ (str) – Specify which of tessif’s hardcoded examples should be measured. Is passed to create_self_similar_energy_system(). For more info look at its docs.
kwargs¶ – Are passed to the create_self_similar_energy_system() function.
- Returns:
MemoryTimenamedtupledictionariescontaining the scalability assessment results as TxNDataFrames.- Return type:
- tessif.analyze.average(timeseries)[source]
Calculate the average of different software results.
- Parameters:
timeseries¶ (Mapping, pandas.DataFrame) – Mapping of timeseries to an identifier or a DataFrame containing the timeseries as columns, the corresponding timestamps as index and the identifiers as column header.
- Returns:
average – np.array containing the average timeseries data
- Return type:
np.array
- tessif.analyze.compare_N_timeseries(timeseries, threshold)[source]
Algorithm to detect intervals in which the given timeseries deviate from their mean by a certain threshold.
- Parameters:
timeseries¶ (Mapping, pandas.DataFrame) –
Mapping of timeseries to an identifier or a DataFrame containing the timeseries as columns, the corresponding timestamps as index and the identifiers as column header.
Note
If no DataFrame is passed, the index will be set automatically as integers (0-indexed) counting the values position inside the timeseries. Meaning the N-th value will have and index of N-1.
Float representing the relative deviation of the given
timeseriesfrom their mean that is considered as threshold for identifying the series values as different.To recognize a series value as different from the others following statement has to be
True:\(|T(t)-\overline{T}(t)| \geq \text{threshold} \cdot \overline{T}(t)\)
- Returns:
load_differences – DataFrame representing the comparison results. The first column represents the average timeseries. The following columns are filled by the timeseries (ordered as they were passed) in which differences were recognized. The index of the DataFrame represents the indices passed (usually timestamps) in which differences were detected.
- Return type:
- tessif.analyze.statistically_compare_N_timeseries(timeseries, normalized=True, reference='', type='mean')[source]
Algorithm to calculate a number of statistical (values) for the given timeseries relative to their reference timeseries.
- Parameters:
timeseries¶ (Mapping, pandas.DataFrame) –
Mapping of timeseries to an identifier or a DataFrame containing the timeseries as columns, the corresponding timestamps as index and the identifiers as column header.
Note
If no DataFrame is passed, the index will be set automatically as integers (0-indexed) counting the values position inside the timeseries. Meaning the N-th value will have and index of N-1.
Determine the returned values to be normalized or not.
default = “True”
Define the type of normalization. Statistical (values) can be normalized by ‘mean’ or by the timeseries ‘range’:
default = “mean”
reference¶ (str) – Determine the reference system that is to serve as a reference to which the statistical values are determined.
- Returns:
ldr – DataFrame holding the statistical load difference results. The index (rows) represent the calculated value names/types, the columns the respective model names. For Example:
omf test rmse 42 42 mae 0 0 mbe 9000 9000
- Return type:
- tessif.analyze.statistical_value_mapping = {'NMAE': <function _calculate_mean_absolute_error>, 'NMBE': <function _calculate_mean_biased_error>, 'NRMSE': <function _calculate_root_mean_square_error>}
Mappingof the statistical value calculation utilities used to statistically compare the N timeseries.Edit/ Monkey Patch this mapping to change the behavior of
statistically_compare_N_timeseries().
- tessif.analyze.lag_correlate(timeseries, number_of_steps)[source]
Compares two datasets by applying a lag correlation analysis, to find out whether a potential (time) lag exists.
During the lag correlation analysis the data of one set is shifted by up to
maximum_lagnumber of (time) steps to find out if a better correlation can be found.This would then imply that the data of one set might be shifted by a certain number of time steps, or in other words that one dataset might lag behind the other.
- Parameters:
timeseries¶ (pandas.DataFrame) – Mapping of timeseries to an identifier or a DataFrame containing the timeseries as columns, the corresponding timestamps as index and the identifiers as column header.
number_of_steps¶ (numpy arange) – Integer specifying the maximum lag to be assessed. Meaning during the lag correlation analysis the datasets are shifted by 0 to maximum_lag number of (time) steps to find out if a better correlation can be found. Which would imply that both datasets might be shifted by a certain number of (time) steps, or in other words whether one set lags behind.
See also
https//en.wikipedia.org/wiki/Cross-correlation
- Returns:
List containing:
- position of the highest pearson correlation therefore follows the
lag
- highest pearson correlation value of the up and down shifted data
as float
- Return type:
- tessif.analyze.create_average_model(data_dic)[source]
function to create the “average” or “medium” model
- Parameters:
data_dic¶ (dictionary) –
dictionary (all _sphinx_paramlinks_tessif.analyze.create_average_model.data of the models each stored as Pandas DataFrames in a) –
- Returns:
contains the medium model
- Return type:
dictionary
- tessif.analyze.mae_list(data_dic, reference='')[source]
Create a list of mean absolute errors form each model compared with a reference model
- Parameters:
- Returns:
List of mean absolute errors from each model compared with a reference model.
- Return type:
- tessif.analyze.pearson_correlate(dataframe1, dataframe2)[source]
Function to calculate the pearson correlation coefficient to quickly sort out difference between two different models
Note
Its only Possible to compare two different models
- Parameters:
dataframe1¶ (pandas.DataFrame) – Dataframe containing all components and flows of one model (calliope, fine, oemof, pypsa, …)
dataframe2¶ (pandas.DataFrame) – Dataframe containing all components and flows of another software (calliope, fine, oemof, pypsa, …)
- Returns:
Pandas Series of the pairwise pearson correlation results. Where:
1= perfect correlation (good)0= no correlation at all (bad)-1= trending in opposite directions (woops!)
- Return type:
See also
- tessif.analyze.pearson_list(data_dic, reference='')[source]
Create a list of pearson correlations from each model compared with a reference model.
- Parameters:
data_dic¶ (dictionary) –
dictionary (all _sphinx_paramlinks_tessif.analyze.pearson_list.data of the models each stored as Pandas DataFrames in a) –
the (Define _sphinx_paramlinks_tessif.analyze.pearson_list.the reference model to be used as a reference point to determine) –
(average (statistical _sphinx_paramlinks_tessif.analyze.pearson_list.values.) –
omf¶ –
ppsa¶....) –
- Returns:
pandas.DataFrame
List of pearson correlations from each model compared with a reference
model.
- tessif.analyze.autoselect(pearson_df, mae_df, pearson_threshold=0.7, mae_threshold=0.05, desired_condition='all')[source]
Algorythm that works out the differences of the individual time series of the components/flows from all the models studied. The pearson correlation and the mean absolute error are calculated once for the models in regard to a reference model. From the respective combinations of the two statistical quantities, it can be determined how strongly certain components/flows differ from each other. In general, a high pearson correlation means a high linear equality and a low mean absolute error means a small total difference of the values. Three different types of conditions can be processed.
- High interest / significantly different
pearson correlation < pearson_threshold, mae > mae_threshold
- Medium interest / borderline significantly
pearson correlation < pearson_threshold, mae <= mae_threshold pearson correlation >= pearson_threshold, mae > mae_threshold
- Least interesting / most likely of no interest
pearson correlation >= pearson_threshold, mae <= mae_threshold
See also
https//en.wikipedia.org/wiki/Pearson_correlation_coefficient
https//en.wikipedia.org/wiki/Mean_absolute_error
- Parameters:
pearson_df¶ (panda.DataFrame) – Pearson correlations from each model compared with a reference model.
mae_df¶ (panda.DataFrame) – Mean absolute errors from each model compared with a reference model.
pearson_threshold¶ (float ; default = 0.7) – Define at which value the pearson correlation should be undercut to be considered as a significant difference. Large values mean high linear equality
mae_threshold¶ (float ; default = 0.05) – Defines at which value the mean absolute error should be exceeded to be considered as a significant difference. Small values mean that there are hardly any differences in the values of the time series.
desired_condition¶ (str ; default = "all") –
- determines according to which condition the data should be filtered
” condition_1” or ‘very_interesting’ == High interest / significantly different. ” condition_2” or ‘interesting_high_mae_low_pearson’ == Medium interest / boderline significantly ” condition_2_3” or ‘all_from_interest’ == Medium interest / boderline significantly shows both conditions 2 and 3 ” condition_3” or ‘interesting_low_mae_high_pearson’ == Medium interest / boderline significantly ” condition_4” or ‘not_interesting’ == Least interesting / most likely of no interest ” condition_5” or “all” == shows the complete data set (no condition)
- Returns:
Values of the pearson correlation and the mean absolute errors of the selected condition.
- Return type:
dictionary
- tessif.analyze.stop_time(path, parser, model, measurement='CPU', timeframe='primary', hook=None, only_total=False, trans_ops=None)[source]
Measure elapsed wall time.
- Parameters:
path¶ (str) – String representing the path the energy system data resides in. e.g.
examples_dir/application/computational_comparison/fractal.xlsxmodel¶ (str) – String specifying one of the
registered_modelsrepresenting the energy system simulation model investigated.parser¶ (
Callable) – Functional used to read in and parse the energy system data. Usually one of the module functions found intessif.parse.measurement¶ (str, default="CPU") –
String specifying which time measurement to use. Either
"CPU"or"Wall"are supported using:"CPU"for measuring the CPU time utilizingtime.process_time()"Wall"for measuring the elapsed wall time utilizingtime.time()
timeframe¶ (str, default='primary') – String specifying which of the (potentially multiple) timeframes passed is to be used. One of
'primary','secondary', etc… by convention.hook¶ (dict, None, default=None) – Dictionary keying
hookscallables by itsregistered name. See a use case in Hamburg Energy System Example (Brief).only_total¶ (bool, default=False) – Set to true to only return the total result.
trans_ops¶ (dict, None, default=None) –
Dictionary keying transformation options of a model by its
registered name. For example theforced_linksoption when using PyPSA as in:trans_ops={'pypsa': { 'forced_links': ['Transformator_1', 'Transformator_2']} }
- Returns:
results – Dictionary containing timing results in seconds keyed by the corresponding simulation steps that were investigated:
readingparsingtransformationsimulationpost_processing
- Return type:
- tessif.analyze.trace_memory(path, parser, model, timeframe='primary', hook=None, only_total=False, trans_ops=None)[source]
Trace allocated memory.
# Very similar in concept to stop_time()
- Parameters:
path¶ (str) – String representing the path the energy system data resides in. e.g.
examples_dir/application/computational_comparison/fractal.xlsxmodel¶ (str) – String specifying one of the
registered_modelsrepresenting the energy system simulation model investigated.parser¶ (
Callable) – Functional used to read in and parse the energy system data. Usually one of the module functions found intessif.parse.timeframe¶ (str, default='primary') – String specifying which of the (potentially multiple) timeframes passed is to be used. One of
'primary','secondary', etc… by convention.hook¶ (dict, None, default=None) – Dictionary keying
hookscallables by itsregistered name. See a use case in Hamburg Energy System Example (Brief).only_total¶ (bool, default=False) – Set to true to only return the total result.
trans_ops¶ (dict, None, default=None) –
Dictionary keying transformation options of a model by its
registered name. For example theforced_linksoption when using PyPSA as in:trans_ops={'pypsa': { 'forced_links': ['Transformator_1', 'Transformator_2']} }
- Returns:
results – Dictionary containing memory results in KiB keyed by the corresponding simulation steps that were investigated:
readingparsingtransformationsimulationpost_processing
- Return type:
- class tessif.analyze.Comparatier(path, parser, models, N=2, T=2, scaling=False, storage_folder=None, hooks={}, trans_ops={})[source]
Bases:
objectQuickly compare any number of tessif’s supported energy supply system simulation models.
- Parameters:
path¶ (str) – String representing the path the tessif energy system data is stored at. This
energy systemserves as scenario on which themodelsare compared.parser¶ (
Callable) – Functional used to read in and parse the energy system data. Usually one of the module functions found intessif.parse.models¶ (Sequence) – Sequence of strings naming the
registered_modelsrepresenting tessif’s supported energy supply system simulation models.scaling¶ (bool, default=False) – Bool indicating if scalability should be assessed using
assess_scalability().N¶ (int, default=2) – Maximum number of minimum self similar energy system units the
self similar energy systemis created with as part of the scalability assessment. assessment. Only used ifscalingisTrue.T¶ (int, default=2) – Maximum number of timesteps used for scalability assessment. Only used if
scalingisTrue.hooks¶ (dict, default=dict()) – Dictionary keying
hookscallables by itsregistered name. See a use case in Hamburg Energy System Example (Brief).trans_ops¶ (dict, default=dict()) –
Dictionary keying transformation options of a model by its
registered name. For example theforced_linksoption when using PyPSA as in:trans_ops={'pypsa': { 'forced_links': ['Transformator_1', 'Transformator_2']} }
Examples
See Auto Comparison Between Multiple Models for a detailed example on how to use the
Comparatier.- property baseline_es
AbstractEnergySystemserving as baseline scenario on which themodelsare compared.
- property comparative_results
ComparativeResultierholding the results of each model keyed by component or by flow, depending on the results.
- create_lag_correlation(number_of_steps, component, flow)[source]
Utility to compare the load results of 2 models by using a lag correlation.
During the lag correlation analysis the load results of one model are shifted by up to
maximum_lagnumber of time steps to find out if a better correlation can be found.This would then imply that one model’s load results would be shifted by a certain number of time steps, or in other words one model’s load results might lag behind the other’s.
- Parameters:
maximum_lag¶ (int) – Integer specifying the maximum lag to be assessed. Meaning during the lag correlation analysis the load results are shifted by 0 up to maximum_lag number of time steps to find out if a better correlation can be found. This would then imply that one model’s load results would be shifted by a certain number of time steps, or in other words one model’s load results might lag behind the other’s.
See also
- property energy_systems
Mappingof the optimized energy system models keyed by model name representing the compared energy supply system simulation model.
- property graph
networkx.DiGraphobject representing the energy system analyzed by thisComparatier.
- property models
tupleof theregistered modelsto compare.
- property ICR_graphs
Dictionary of
networkx.DiGraphobjects keyed by model name. Representing the compared energy supply system simulation models and their respective integrated component results.Note
To access the result data with which the graphs were plotted see
networkx.Graph.nodesandnetworkx.Graph.edgesandtessif.transform.nxgrph.Graph.
- ICR_graph_charts(colored_by='name', legend=True, edge_width_scaling=10, **kwargs)[source]
Mappingofmatplotlib.figure.Figureobjects visualizingnetworkx.DiGraphobjects representing the energy system analyzed keyed by model name representing the compared energy supply system simulation models.The displayed graphs visualize following information:
Edge length scales with flow costs
Edge width scales with net flow rate
Edge greyscale scales with co2 emission
Node size scales width installed capacity
Node filling scales width capacity factor
Note
Graph objects are accessible via
Comparatier.ICR_graphs.Results for generating the graph chart are stored within the respective graph object. (See
networkx.Graph.nodesandnetworkx.Graph.edgesandtessif.transform.nxgrph.Graphfor attribute accessing)- Parameters:
colored_by¶ ({'component', 'name', 'carrier', 'sector'}, optional) –
Specification on how to group nodes for coloring. (Respective node color dict provided by a
ESTransformerchild)Default implementations are:
'component': Matches component to it’s type'name': Searches for keywords in str(node.uid.name)'carrier': Searches for keywords in node.uid.carrier'sector': Searches for keywords in node.uid.sector
(Refer to
NodeColorGroupingsfor namedtuple implementation)legend¶ (bool, optional) – Whether to draw a legend or not. If
Truea legend is drawn.edge_width_scaling¶ (Number) – Number with which the edge width is scaled. Useful for emphasizing edge width proportionality to net energy flow. Tweak this if node and figure size lead to edge widths too difficult to distinguish.
kwargs¶ –
Kwargs are passed to
tessif.visualize.nxgrph.draw_graph.kwargsUseful for changing singular attributes of singular nodes as in:node_color={'Generator': 'red', }
to color a node
'red'of which thestr(node.uid)representation yields'Generator'Or as in:
node_shape='o'
To impose a circular
shapeon all nodes.
- property integrated_global_results
pandas.DataFrameholding the singular value results (columns) for each model investigated (rows).Singular value results are:
costsemissionstimememory
Optionally other global constraints can be formulated using the
global_constraintsattribute oftessif's energy systemThis DataFrame holds the results for drawing the
global results chart.
- property memory_usage_results
collections.abc.Mappingofdictionariesof the time measurement results keyed by the compared energy supply system simulation models.
- property path
strrepresenting the path, thebaseline_esis stored.
- property pearson_correlation
dictofpandas.DataFrameobjects holding the pearson correlation results of each component of each model pairing.Serves as main entry point for finding out which components to analyze more thoroughly.
- property scalability_charts_2D
Mappingofmatplotlib.figure.Figureobjects visualizing the scalability of the compared energy supply system simulation models as array of curves.
- property scalability_charts_3D
Mappingofmatplotlib.figure.Figureobjects visualizing the scalability of the compared energy supply system simulation models as 3D field of (stacked) bars.
- property scalability_results
MappingofMemoryTimenamedtupleskeyed the compared energy supply system simulation models..
- property timing_results
collections.abc.Mappingofdictionariesof the time measurement results keyed by the compared energy supply system simulation models.
- property optimization_results
MappingofAllResultierobjects holding the optimization results keyed by model name representing the compared energy supply system simulation model.
- calculate_load_differences(component, flow, threshold)[source]
pandas.DataFramerepresenting the detected load differences among models for the same component.The first column represents the average timeseries. The following columns are filled by the compared models’ timeseries (ordered as they were passed) in which differences were recognized. The index of the DataFrame represents the points in time during the simulation where the differences occurred.
- Parameters:
component¶ (str) – The component’s
Uidstring representation (str(component)) of which the load differences among models is to be calculated.flow¶ (str) – String representation of one of the
component'sflow interfacesof which the load differences among models is to be calculated.Float representing the relative deviation of the given
component'sload series from the mean of all components that is considered as threshold for identifying the series values as different.To recognize a series value as different from the others following statement has to be
True:\(|T(t)-\overline{T}(t)| \geq \text{threshold} \cdot \overline{T}(t)\)
- Returns:
ldr – DataFrame holding the load difference results.
- Return type:
- calculate_statistical_load_differences(component, flow, normalized=True, type='mean', reference='')[source]
pandas.DataFramerepresenting the statistical load differences among models for the same component. For example error values.- Parameters:
component¶ (str) – The component’s
Uidstring representation (str(component)) of which the load differences among models is to be calculated.String representation of one of the
component'sflow interfacesof which the load differences among models is to be calculated.\(|T(t)-\overline{T}(t)| \geq \text{threshold} \cdot \overline{T}(t)\)
Determine the returned values to be normalized or not.
default = “True”
Defines the type of normalization. Statistical (values) can be normalized in different matters. Two options by ‘mean’ or by the timeseries ‘range’:
default = “mean”
reference¶ (str) – Define the reference model to be used as a reference point to determine the statistical values. (average, omf, ppsa….)
- Returns:
ldr – DataFrame holding the statistical load difference results. The index (rows) represent the calculated value names/types, the columns the respective model names.
- Return type:
- draw_global_results_chart(results_to_compare=('costs', 'emissions', 'time', 'memory'), title='default')[source]
Bar plot for comparing the numerical results.
Comparing one or all of
costs
emissions
simulation time
memory usage
of the compared energy supply system simulation models.
Utilizes
tessif.visualize.compare.bar().- Parameters:
results_to_compare¶ (Container) –
Container holding the strings of the numerical results to compare. Any combination of the following values is recognized:
costsemissionstimememory
title¶ (str, default='default') –
String representing the plot title. If default is used title results in:
"Integrated Global Results of Models '{self._models}'."
- Returns:
ldc – Generated load difference chart
- Return type:
- draw_pearson_self_corr_grid()[source]
correlation matrix Create a correlation matrix for each model to analyse interrelationships within each model.
- Returns:
ldc – Return a correlation matrix for each model.
- Return type:
matplotlib.figure.Figures
- draw_load_differences_chart(component, flow, threshold, title='default', x_axis_data=None, labels=[], colors=[], where='post', x_axis_label='x')[source]
matplotlib.figure.Figureobject visualizing the load differences among models for the same component im comparison to their mean.- Parameters:
component¶ (str) – The component’s
Uidstring representation (str(component)) of which the load differences among models is to be calculated.flow¶ (str) – String representation of one of the
component'sflow interfacesof which the load differences among models is to be calculated.Float representing the relative deviation of the given
component's <load_differences_chart.component> load series from the mean of all components that is considered as threshold for identifying the series values as different.To recognize a series value as different from the others following statement has to be
True:\(|T(t)-\overline{T}(t)| \geq \text{threshold} \cdot \overline{T}(t)\)
title¶ (str, default='default') –
String representing the plot title. If default is used title results in:
"Time step resolved analysis of {component}'s flow to '{flow}'"
in:: (Iterable _sphinx_paramlinks_tessif.analyze.Comparatier.draw_load_differences_chart.representing the x-axis data as) –
x = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13) x = range(13) x = pd.date_range(pd.datetime.now().date(), periods=13, freq=’H’)
Note
This parameter is only needed when
datais NOT supplied as apandas.DataFrame. It is ignored otherwise.labels¶ (Iterable, default=[]) –
Iterable of strings labeling the data sets in
component_loads.step.data.If not empty a legend entry will be drawn for each item.
Must be of equal length or longer than
data.Note
This parameter is only needed when
datais NOT supplied as apandas.DataFrame. It is ignored otherwise.colors¶ (Iterable, default=[]) –
Iterable of color specification string coloring the data sets in
data.If not empty each plot will be colord accordingly. Otherwise, matplotlib’s default color rotation will be used.
List of colors stated must be greater or equal the stacks to be plotted.
x-axis_label¶ (str, None, default='x') –
String labeling the x-axis.
Use
Noneto not plot any axis labels.where¶ (str, default = 'post') –
# https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.step.html
Define where the steps should be placed:
- ’pre’: The y value is continued constantly to the left from every x
position, i.e. the interval (x[i-1], x[i]] has the value y[i].
’post’: The y value is continued constantly to the right from every x position, i.e. the interval [x[i], x[i+1]) has the value y[i].
’mid’: Steps occur half-way between the x positions.
- Returns:
ldc – Generated load difference chart
- Return type:
- draw_statistical_load_differences_chart(component, flow, normalized=True, title='default')[source]
matplotlib.figure.Figureobject visualizing the statistical results on comparing one component’s load data among models.- Parameters:
component¶ (str) – The component’s
Uidstring representation (str(component)) of which the load differences among models is to be calculated.flow¶ (str) – String representation of one of the
component'sflow interfacesof which the load differences among models is to be calculated.normalized¶ (bool) – bool operator determine the returned values to be normalized or not default = “True”
title¶ (str, default='default') –
String representing the plot title. If default is used title results in:
"Statistical analysis of {component}'s flow to '{flow}'"
- separate_data(pearson_threshold=0.7, mae_threshold=0.05, threshold_moving_average=10, title='', condition='all', reference='')[source]
tool for visualizing and separating the differences of the individual time series of the components/flows from all the models studied, based on the previously selected condition. For the visualization the data are smooth before because only a trend should become visible
See also
https//en.wikipedia.org/wiki/Pearson_correlation_coefficient
https//en.wikipedia.org/wiki/Mean_absolute_error
https//en.wikipedia.org/wiki/Moving_average
- Parameters:
pearson_threshold¶ (float ; default = 0.7) – Defines at which value the person correlation should be undercut to be considered as a significant difference. Large values mean high linear equality
mae_threshold¶ (float ; default = 0.05) – Defines at which value the mean absolute error should be exceeded to be considered as a significant difference. Small values mean that there are hardly any differences in the values of the time series.
condition¶ (str ; default = "all") –
- determines according to which condition the data should be filtered
” condition_1” or ‘very_interesting’ == High interest / significantly different. ” condition_2” or ‘interesting_high_mae_low_pearson’ == Medium interest / boderline significantly ” condition_2_3” or ‘all_from_interest’ == Medium interest / boderline significantly ” condition_3” or ‘interesting_low_mae_high_pearson’ == Medium interest / boderline significantly ” condition_4” or ‘not_interesting’ == Least interesting / most likely of no interest: ” condition_5” or “all” == shows the complete data set (no condition)
reference¶ (str) – Defines the reference model to be used as a reference point to determine the statistical values. (average, omf, ppsa….)
- Returns:
pd.Dataframe – Contains the values of the pearson correlation and the mean absolute errors of the selected condition.
matplotlib.figure.Figure – Visualization of the components determined by the algorithm.
- class tessif.analyze.ComparativeResultier(all_resultiers, results_to_compare='all')[source]
Bases:
objectUtility for creating comparative dataframes out of optimization results.
Uses
Comparatier.optimization_resultsto create multi indexedDataFrameobjects storing the results of the samebase energy systemsimulated using different models as it is done by using theComparatierto auto compare those different models.- Parameters:
Dictionairy of strings naming the
registered_modelsrepresenting tessif’s supported energy supply system simulation models keying theresultsof those models.A mapping of this kind is returned by
Comparatier.optimization_results.
Examples
Comparing the models oemof and pypsa on
tessif's fully parameterized working example (fpwe):Silence the
spellingsmodule:>>> import tessif.frused.configurations as configurations >>> configurations.spellings_logging_level = 'debug'
Create the
Comparatierobject for automated comparison:>>> import tessif.analyze, tessif.parse, os >>> from tessif.frused.paths import write_dir
>>> comparatier = tessif.analyze.Comparatier( ... path=os.path.join( ... write_dir, 'tsf', 'es_to_compare.hdf5'), ... parser=tessif.parse.hdf5, ... models=('oemof', 'pypsa'), ... )
Get the
ComparativeResultierobject using the comparatier.:>>> comparative_resultier = comparatier.comparative_results >>> print(type(comparative_resultier)) <class 'tessif.analyze.ComparativeResultier'>
Refer to the detailed use case examples.
- property all_loads
Dictionary of multi-indexed dataframes of all load results of all components keyed inside the dict by the respective
software specifierTop-level index represents the individual components, while the second-level index represent the respective outflow targets.
Meaning for an energy system like:
A -> B -> C | v D
The dataframe would look something like:
A B B C D 0 10 8 2 1 0 0 0 2 20 2 18
Warning
Depending on the energy system, this might be a huge dataframe. Hence, a lazy evaluation approach is chosen.
Example
Refer to the detailed comparatier example for accessing the all-loads results.
- property all_socs
DataFrame of all state of charges of all storages.
DataFrame is indexed by component names and columned by respective
software specifiersExample
Refer to the detailed comparatier example for accessing the all_capacities results.
- property all_capacities
DataFrame of all installed capacities post optimization.
DataFrame is indexed by component names and columned by respective
software specifiersExample
Refer to the detailed comparatier example for accessing the all_capacities results.
- property all_original_capacities
DataFrame of all installed capacities pre optimization.
DataFrame is indexed by component names and columned by respective
software specifiersExample
Refer to the detailed comparatier example for accessing the all_original_capacities results.
- property all_net_energy_flows
DataFrame of all net energy flows post optimization.
DataFrame is indexed by component names and columned by respective
software specifiersExample
Refer to the detailed comparatier example for accessing the all-loads results.
- property all_costs_incurred
DataFrame of all net energy flows post optimization.
DataFrame is indexed by component names and columned by respective
software specifiersExample
Refer to the detailed comparatier example for accessing the all-loads results.
- property all_emissions_caused
DataFrame of all net energy flows post optimization.
DataFrame is indexed by component names and columned by respective
software specifiersExample
Refer to the detailed comparatier example for accessing the all-loads results.
- property capacities
Return a mapping of the installed capacity results among models keyed by component uid.
Note
Entries of value NaN are to be interpreted as Not a Node. Whereas
Noneis atessif default.Examples
Refer to the detailed comparatier example for accessing the capacity results.
- property costs
Return a mapping of the flow cost results among models keyed by component edges.
Note
Entries of value NaN are to be interpreted as Not a Node. Whereas
Noneis atessif default.Examples
Refer to the detailed comparatier example for accessing the cost results.
- property cvs
Return a mapping of the characteristic value results among models keyed by component uid.
Note
Entries of value NaN are to be interpreted as Not a Node. Whereas
Noneis atessif default.Examples
Refer to the detailed comparatier example for accessing the characteristic value results.
- property emissions
Return a mapping of the flow emission results among models keyed by component edges.
Note
Entries of value NaN are to be interpreted as Not aN edge. Whereas
Noneis atessif default.Examples
Refer to the detailed comparatier example for accessing the emissions results.
- property expansion_costs
Return a mapping of the costs for expanding a nodes installed capacity.
Note
Entries of value NaN are to be interpreted as Not a Node. Whereas
Noneis atessif default.Examples
Refer to the detailed comparatier example for accessing the emissions results.
- property loads
Return a mapping of the load results among models keyed by component uid.
Note
Entries of value NaN are to be interpreted as Not a Node. Whereas
Noneis atessif default.Examples
Refer to the detailed comparatier example for accessing the loads results.
- property net_energy_flows
Return a mapping of the net energy flow results among models keyed by component edges.
Note
Entries of value NaN are to be interpreted as Not aN edge. Whereas
Noneis atessif default.Examples
Refer to the detailed comparatier example for accessing the net energy flow results.
- property original_capacities
Return a mapping of the installed capacity prior to optimization among models keyed by component uid.
Note
Entries of value NaN are to be interpreted as Not a Node. Whereas
Noneis atessif default.Examples
Refer to the detailed comparatier example for accessing the original capacity results.
- property socs
Return a mapping of the state of charge results among models keyed by component uid.
Note
Entries of value NaN are to be interpreted as Not a Node. Whereas
Noneis atessif default.Examples
Refer to the detailed comparatier example for accessing the state of charge results.
- property weights
Return a mapping of the edge weight results among models keyed by component edges.
Note
Entries of value NaN are to be interpreted as Not aN edge. Whereas
Noneis atessif default.Examples
Refer to the detailed comparatier example for accessing the edge weight results.