Skip to content

Analysis

Scripts for analyzing network results, generating statistics, and creating plots.


Statistics & Summary

make_statistics

Create statistics for a given scenario run.

This script contains functions to create statistics of the workflow for the current execution

Relevant statistics that are created are:

  • For clean_osm_data and download_osm_data, the number of elements, length of the lines and length of dc lines are stored
  • For build_shapes, the surface, total GDP, total population and number of shapes are collected
  • For build_renewable_profiles, total available potential and average production are collected
  • For network rules (base_network, add_electricity, simplify_network and solve_network), length of lines, number of buses and total installed capacity by generation technology
  • Execution time for the rules, when benchmark is available

Outputs

This rule creates a dataframe containing in the columns the relevant statistics for the current run.

generate_scenario_by_country(path_base, country_list, out_dir='configs/scenarios', pre='config.')

Utility function to create copies of a standard yaml file available in path_base for every country in country_list. Copies are saved into the output directory out_dir.

Note: - the clusters are automatically modified for selected countries with limited data - for landlocked countries, offwind technologies are removed (solar, onwind and hydro are forced)

Parameters
path_base : str
    Path to the standard yaml file used as default
country_list : list
    List of countries.
    Note: the input is parsed using download_osm_data.create_country_list
out_dir : str (optional)
    Output directory where output configuration files are executed

collect_basic_osm_stats(path, rulename, header)

Collect basic statistics on OSM data: number of items

collect_network_osm_stats(path, rulename, header, metric_crs='EPSG:3857')

Collect statistics on OSM network data: - number of items - length of the stored shapes - length of objects with tag_frequency == 0 (DC elements)

collect_osm_stats(rulename, **kwargs)

Collect statistics on OSM data.

When lines and cables are considered, then network-related statistics are collected (collect_network_osm_stats), otherwise basic statistics are (collect_basic_osm_stats)

collect_raw_osm_stats(rulename='download_osm_data', metric_crs='EPSG:3857')

Collect basic statistics on OSM data; used for raw OSM data.

collect_clean_osm_stats(rulename='clean_osm_data', metric_crs='EPSG:3857')

Collect statistics on OSM data; used for clean OSM data.

collect_bus_regions_stats(bus_region_rule='build_bus_regions')

Collect statistics on bus regions.

  • number of onshore regions
  • number of offshore regions

collect_network_stats(network_rule, scenario_config)

Collect statistics on pypsa networks: - installed capacity by carrier - lines total length (accounting for parallel lines) - lines total capacity

collect_shape_stats(rulename='build_shapes', area_crs='ESRI:54009')

Collect statistics on the shapes created by the workflow: - area - number of gadm shapes - Percentage of shapes having country flag matching the gadm file - total population - total gdp

collect_only_computational(rulename)

Rule to create only computational statistics of rule rulename.

collect_snakemake_stats(name, dict_dfs, renewable_config, renewable_carriers_config)

Collect statistics on what rules have been successful.

aggregate_computational_stats(name, dict_dfs)

Function to aggregate the total computational statistics of the rules.

collect_renewable_stats(rulename, technology)

Collect statistics on the renewable time series generated by the workflow: - potential - average production by plant (hydro) or bus (other RES)

add_computational_stats(df, snakemake, column_name=None)

Add the major computational information of a given rule into the existing dataframe.

calculate_stats(scenario_config, renewable_config, renewable_carriers_config, metric_crs='EPSG:3857', area_crs='ESRI:54009')

Function to collect all statistics

make_summary

Creates summaries of aggregated energy and costs as .csv files.

Relevant Settings

.. code:: yaml

scenario:

.. seealso:: Documentation of the configuration file config.yaml at :ref:toplevel_cf

Inputs

Outputs

Description

The following rule can be used to summarize the results in separate .csv files:

.. code:: bash

snakemake results/summaries/elec_s_all_lall_Co2L-3H_all
                                     clusters
                                         line volume or cost cap
                                            - options
                                                    - all countries

The line volume/cost cap field can be set to one of the following:

  • lv1.25 for a particular line volume extension by 25%
  • lc1.25 for a line cost extension by 25 %
  • lall for all evaluated caps
  • lvall for all line volume caps
  • lcall for all line cost caps

Replacing summaries with plots creates nice colored maps of the results.

calculate_supply(n, label, supply)

Calculate the max dispatch of each component at the buses where the loads are attached.

calculate_supply_energy(n, label, supply_energy)

Calculate the total dispatch of each component at the buses where the loads are attached.


Plotting

plot_network

Plots map with pie charts and cost box bar charts.

Relevant Settings

Inputs

Outputs

Description

plot_summary

Plots energy and cost summaries for solved networks.

Relevant Settings

Inputs

Outputs

Description