analyze

Singular Model Assessment

assess_scalability

Estimate the scalability of a chosen energy system simulation model.

compare_N_timeseries

Algorithm to detect intervals in which the given timeseries deviate from their mean by a certain threshold.

pearson_correlate

Function to calculate the pearson correlation coefficient to quickly sort out difference between two different models

lag_correlate

Compares two datasets by applying a lag correlation analysis, to find out whether a potential (time) lag exists.

statistically_compare_N_timeseries

Algorithm to calculate a number of statistical (values) for the given timeseries relative to their reference timeseries.

stop_time

Measure elapsed wall time.

trace_memory

Trace allocated memory.

Model Comparison

Comparatier

Quickly compare any number of tessif's supported energy supply system simulation models.

Comparatier.energy_systems

Mapping of the optimized energy system models keyed by model name representing the compared energy supply system simulation model.

Comparatier.graph

networkx.DiGraph object representing the energy system analyzed by this Comparatier.

Comparatier.ICR_graphs

Dictionary of networkx.DiGraph objects keyed by model name.

Comparatier.ICR_graph_charts

Mapping of matplotlib.figure.Figure objects visualizing networkx.DiGraph objects representing the energy system analyzed keyed by model name representing the compared energy supply system simulation models.

Comparatier.integrated_global_results

pandas.DataFrame holding the singular value results (columns) for each model investigated (rows).

Comparatier.pearson_correlation

dict of pandas.DataFrame objects holding the pearson correlation results of each component of each model pairing.

Comparatier.memory_usage_results

collections.abc.Mapping of dictionaries of the time measurement results keyed by the compared energy supply system simulation models.

Comparatier.path

str representing the path, the baseline_es is stored.

Comparatier.scalability_charts_2D

Mapping of matplotlib.figure.Figure objects visualizing the scalability of the compared energy supply system simulation models as array of curves.

Comparatier.scalability_charts_3D

Mapping of matplotlib.figure.Figure objects visualizing the scalability of the compared energy supply system simulation models as 3D field of (stacked) bars.

Comparatier.scalability_results

Mapping of MemoryTime namedtuples keyed the compared energy supply system simulation models..

Comparatier.timing_results

collections.abc.Mapping of dictionaries of the time measurement results keyed by the compared energy supply system simulation models.

Comparatier.comparative_results

ComparativeResultier holding the results of each model keyed by component or by flow, depending on the results.

Comparatier.optimization_results

Mapping of AllResultier objects holding the optimization results keyed by model name representing the compared energy supply system simulation model.

Comparatier.calculate_load_differences

pandas.DataFrame representing the detected load differences among models for the same component.

Comparatier.calculate_statistical_load_differences

pandas.DataFrame representing the statistical load differences among models for the same component.

Comparatier.create_lag_correlation

Utility to compare the load results of 2 models by using a lag correlation.

Comparatier.draw_global_results_chart

Bar plot for comparing the numerical results.

Comparatier.draw_load_differences_chart

matplotlib.figure.Figure object visualizing the load differences among models for the same component im comparison to their mean.

Comparatier.draw_statistical_load_differences_chart

matplotlib.figure.Figure object visualizing the statistical results on comparing one component's load data among models.

Utilities

ComparativeResultier

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:
  • N (int) –

    Number of minimum self similar energy system units (MiSSESUs) the self similar energy system consists of.

    (Adding a stepping parameter for N might also be helpful. Add one if you deem helpful/necessary)

  • T (int) –

    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_models representing 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 None the N-th energy system will be stored in examples_dir/application/computational_comparison/scalability/es_N

    See tessif.frused.paths.examples_dir for 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:

MemoryTime namedtuple dictionaries containing the scalability assessment results as TxN DataFrames.

Return type:

NamedTuple

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.

  • threshold (float) –

    Float representing the relative deviation of the given timeseries from 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:

pandas.DataFrame

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.

  • normalized (bool) –

    Determine the returned values to be normalized or not.

    default = “True”

  • type (str) –

    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:

pandas.DataFrame

tessif.analyze.statistical_value_mapping = {'NMAE': <function _calculate_mean_absolute_error>, 'NMBE': <function _calculate_mean_biased_error>, 'NRMSE': <function _calculate_root_mean_square_error>}

Mapping of 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_lag number 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:

  1. position of the highest pearson correlation therefore follows the

    lag

  2. highest pearson correlation value of the up and down shifted data

    as float

Return type:

list

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:
  • data_dic (dictionary) – all data of the models each stored as pandas DataFrames in a dictionary

  • reference (str) – Defines the reference model to be used as a reference point for determining the statistical values. (average, omf, ppsa….)

Returns:

List of mean absolute errors from each model compared with a reference model.

Return type:

pandas.DataFrame

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:

pandas.Series

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

  • reference (str) –

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

  1. High interest / significantly different

    pearson correlation < pearson_threshold, mae > mae_threshold

  2. Medium interest / borderline significantly

    pearson correlation < pearson_threshold, mae <= mae_threshold pearson correlation >= pearson_threshold, mae > mae_threshold

  3. 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.xlsx

  • model (str) – String specifying one of the registered_models representing 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 in tessif.parse.

  • measurement (str, default="CPU") –

    String specifying which time measurement to use. Either "CPU" or "Wall" are supported using:

  • 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 hooks callables by its registered 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 the forced_links option 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:

  • reading

  • parsing

  • transformation

  • simulation

  • post_processing

Return type:

dict

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

  • model (str) – String specifying one of the registered_models representing 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 in tessif.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 hooks callables by its registered 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 the forced_links option 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:

  • reading

  • parsing

  • transformation

  • simulation

  • post_processing

Return type:

dict

class tessif.analyze.Comparatier(path, parser, models, N=2, T=2, scaling=False, storage_folder=None, hooks={}, trans_ops={})[source]

Bases: object

Quickly compare any number of tessif’s supported energy supply system simulation models.

Parameters:

Examples

See Auto Comparison Between Multiple Models for a detailed example on how to use the Comparatier.

property baseline_es

AbstractEnergySystem serving as baseline scenario on which the models are compared.

property comparative_results

ComparativeResultier holding 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_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.

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

lag_correlate()

property energy_systems

Mapping of the optimized energy system models keyed by model name representing the compared energy supply system simulation model.

property graph

networkx.DiGraph object representing the energy system analyzed by this Comparatier.

property models

tuple of the registered models to compare.

property ICR_graphs

Dictionary of networkx.DiGraph objects 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.nodes and networkx.Graph.edges and tessif.transform.nxgrph.Graph.

ICR_graph_charts(colored_by='name', legend=True, edge_width_scaling=10, **kwargs)[source]

Mapping of matplotlib.figure.Figure objects visualizing networkx.DiGraph objects representing the energy system analyzed keyed by model name representing the compared energy supply system simulation models.

The displayed graphs visualize following information:

  1. Edge length scales with flow costs

  2. Edge width scales with net flow rate

  3. Edge greyscale scales with co2 emission

  4. Node size scales width installed capacity

  5. 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.nodes and networkx.Graph.edges and tessif.transform.nxgrph.Graph for 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 ESTransformer child)

    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 NodeColorGroupings for namedtuple implementation)

  • legend (bool, optional) – Whether to draw a legend or not. If True a 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.kwargs Useful for changing singular attributes of singular nodes as in:

    node_color={'Generator': 'red', }
    

    to color a node 'red' of which the str(node.uid) representation yields 'Generator'

    Or as in:

    node_shape='o'
    

    To impose a circular shape on all nodes.

property integrated_global_results

pandas.DataFrame holding the singular value results (columns) for each model investigated (rows).

Singular value results are:

  • costs

  • emissions

  • time

  • memory

Optionally other global constraints can be formulated using the global_constraints attribute of tessif's energy system

This DataFrame holds the results for drawing the global results chart.

property memory_usage_results

collections.abc.Mapping of dictionaries of the time measurement results keyed by the compared energy supply system simulation models.

property path

str representing the path, the baseline_es is stored.

property pearson_correlation

dict of pandas.DataFrame objects 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

Mapping of matplotlib.figure.Figure objects visualizing the scalability of the compared energy supply system simulation models as array of curves.

property scalability_charts_3D

Mapping of matplotlib.figure.Figure objects visualizing the scalability of the compared energy supply system simulation models as 3D field of (stacked) bars.

property scalability_results

Mapping of MemoryTime namedtuples keyed the compared energy supply system simulation models..

property timing_results

collections.abc.Mapping of dictionaries of the time measurement results keyed by the compared energy supply system simulation models.

property optimization_results

Mapping of AllResultier objects holding the optimization results keyed by model name representing the compared energy supply system simulation model.

calculate_load_differences(component, flow, threshold)[source]

pandas.DataFrame representing 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 Uid string representation (str(component)) of which the load differences among models is to be calculated.

  • flow (str) – String representation of one of the component's flow interfaces of which the load differences among models is to be calculated.

  • threshold (float) –

    Float representing the relative deviation of the given component's 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)\)

Returns:

ldr – DataFrame holding the load difference results.

Return type:

pandas.DataFrame

calculate_statistical_load_differences(component, flow, normalized=True, type='mean', reference='')[source]

pandas.DataFrame representing the statistical load differences among models for the same component. For example error values.

Parameters:
  • component (str) – The component’s Uid string representation (str(component)) of which the load differences among models is to be calculated.

  • flow (str) –

    String representation of one of the component's flow interfaces of which the load differences among models is to be calculated.

    \(|T(t)-\overline{T}(t)| \geq \text{threshold} \cdot \overline{T}(t)\)

  • normalized (bool) –

    Determine the returned values to be normalized or not.

    default = “True”

  • type (str) –

    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:

pandas.DataFrame

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:

    • costs

    • emissions

    • time

    • memory

  • 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:

matplotlib.figure.Figure

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.Figure object visualizing the load differences among models for the same component im comparison to their mean.

Parameters:
  • component (str) – The component’s Uid string representation (str(component)) of which the load differences among models is to be calculated.

  • flow (str) – String representation of one of the component's flow interfaces of which the load differences among models is to be calculated.

  • threshold (float) –

    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}'"
    

  • x-axis_data (Iterable, None, default=None) –

  • 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 data is NOT supplied as a pandas.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 data is NOT supplied as a pandas.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 None to 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:

matplotlib.figure.Figure

draw_statistical_load_differences_chart(component, flow, normalized=True, title='default')[source]

matplotlib.figure.Figure object visualizing the statistical results on comparing one component’s load data among models.

Parameters:
  • component (str) – The component’s Uid string representation (str(component)) of which the load differences among models is to be calculated.

  • flow (str) – String representation of one of the component's flow interfaces of 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:
  • title (str) – String representing the plot title.

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

  • threshold_moving_average (int) –

  • 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: object

Utility for creating comparative dataframes out of optimization results.

Uses Comparatier.optimization_results to create multi indexed DataFrame objects storing the results of the same base energy system simulated using different models as it is done by using the Comparatier to auto compare those different models.

Parameters:

all_resultiers (dict) –

Dictionairy of strings naming the registered_models representing tessif’s supported energy supply system simulation models keying the results of 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):

  1. Silence the spellings module:

    >>> import tessif.frused.configurations as configurations
    >>> configurations.spellings_logging_level = 'debug'
    
  2. Create the Comparatier object 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'),
    ... )
    
  3. Get the ComparativeResultier object using the comparatier.:

    >>> comparative_resultier = comparatier.comparative_results
    >>> print(type(comparative_resultier))
    <class 'tessif.analyze.ComparativeResultier'>
    
  4. 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 specifier

Top-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 specifiers

Example

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 specifiers

Example

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 specifiers

Example

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 specifiers

Example

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 specifiers

Example

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 specifiers

Example

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 None is a tessif 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 None is a tessif 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 None is a tessif 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 None is a tessif 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 None is a tessif 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 None is a tessif 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 None is a tessif 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 None is a tessif 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 None is a tessif 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 None is a tessif default.

Examples

Refer to the detailed comparatier example for accessing the edge weight results.