diff --git a/doc/cba.md b/doc/cba.md index a96ed0a1e5..7ca7ff5d06 100644 --- a/doc/cba.md +++ b/doc/cba.md @@ -9,7 +9,7 @@ The Cost-Benefit Analysis (CBA) evaluates transmission and storage projects by c ## CBA Workflow Methodology -The workflow evaluates projects using a **rolling horizon** approach where the full year is divided into sequential weekly windows (168 hourly snapshots each, with an overlap of 1 snapshot). +The workflow evaluates projects using a **rolling horizon** approach where the full year is divided into sequential weekly windows (168 hourly snapshots each, with an overlap of 1 snapshot). An overview of the CBA rules is documented at [CBA rules](cba_rules.md). To resolve **myopia**—where the optimizer cannot see beyond the current week and makes suboptimal decisions for seasonal storage (H2, gas, large hydro)—the workflow uses Marginal Storage Values (MSV) derived from a full-year optimization. diff --git a/doc/cba_rules.md b/doc/cba_rules.md new file mode 100644 index 0000000000..6887c4f517 --- /dev/null +++ b/doc/cba_rules.md @@ -0,0 +1,142 @@ + + + +# Cost-Benefit Analysis (CBA) + +The Cost-Benefit Analysis (CBA) workflow is implemented in `rules/cba.smk`. Rules are organised into stages: `Retrieve`, `Build MSV`, `Build rolling horizon`, `Postprocess` and `Benchmark`. In addition, a `Collect` stage provides convenient target rules that run the workflow up to a specific stage, aggregating each stage's output across all configured wildcards. + +## Retrieve + +### Rule `retrieve_tyndp_cba_projects` + +Downloads the CBA project explorer dataset, containing project definitions. + +### Rule `retrieve_tyndp_cba_non_co2_emissions` + +Downloads non-CO₂ emission factors (NOx, SO₂, PM, etc.) used to compute B4 indicators. + +### Rule `retrieve_cba_guidelines_reference_projects` + +Downloads the CBA Implementation Guidelines reference project table +(`table_B1_CBA_Implementations_Guidelines_TYNDP2024.csv`) used to reconcile SB investments +with CBA project definitions. + +### Rule `retrieve_presolved_sb_networks` + +Downloads pre-solved SB networks from a previous Open-TYNDP release for use as CBA inputs +when `cba.cba_scenario_input.use_presolved` is `true`. + +## Build MSV + +### Rule `clean_projects` *(checkpoint)* + +::: clean_projects + +### Rule `clean_tyndp_indicators` + +::: clean_tyndp_indicators + +### Rule `simplify_sb_network` + +::: simplify_sb_network + +### Rule `fix_reference_sb_to_cba` + +::: fix_reference_sb_to_cba + +### Rule `prepare_reference` + +::: prepare_reference + +### Rule `build_msv_snapshot_weightings` + +::: build_msv_snapshot_weightings + +## Build rolling horizon + +### Rule `prepare_rolling_horizon` + +::: prepare_rolling_horizon + +### Rule `prepare_project` + +::: prepare_project + +## Solve + +### Rule `solve_cba_msv_extraction` + +::: solve_cba_msv_extraction + +### Rule `solve_cba_reference_network` + +Solves the reference network using the rolling horizon approach. Shares the script with +[`solve_cba_network`](#rule-solve_cba_network). + +::: solve_cba_network + +### Rule `solve_cba_network` + +Solves the CBA network using the rolling horizon approach. Shares the script with [`solve_cba_reference_network`](#rule-solve_cba_reference_network). + +::: solve_cba_network + +## Postprocess + +### Rule `make_indicators` + +::: make_indicators + +### Rule `combine_indicators` + +::: combine_indicators + +### Rule `plot_indicators` + +::: plot_indicators + +## Benchmark + +### Rule `plot_cba_benchmark` + +Plots per-project indicator benchmarking charts comparing computed indicators against +TYNDP 2024 reference values. Shares the script with [`plot_weather_benchmark`](#rule-plot_weather_benchmark). + +::: plot_benchmark_indicators + +### Rule `plot_weather_benchmark` + +Plots weather ensemble benchmarking charts from indicators aggregated across climate years. +Shares the script with [`plot_cba_benchmark`](#rule-plot_cba_benchmark). + +::: plot_benchmark_indicators + +### Rule `average_indicators_per_project_and_planning_horizon` + +::: average_indicators + +### Rule `summarize_indicators_per_project` + +::: summarize_indicators + +### Rule `summarize_all_indicators` + +::: summarize_all + +## Collect + +Aggregate rules that run the corresponding base rule across all configured wildcards. They do not have dedicated scripts. + +### Rule `prepare_references` + +Aggregate [`prepare_reference`](#rule-prepare_reference) outputs. + +### Rule `collect_cba_scenario` + +Collects all per-scenario outputs (indicator plots, benchmark charts) into a single target +for a single climate year run (e.g. `NT-cy2009`). + +### Rule `cba` + +Top-level target rule. Collects ensemble outputs from all climate year runs in a collection +scenario (e.g. `NT-cyears`) and the per-scenario results from nested runs. diff --git a/doc/plotting.md b/doc/plotting.md index 09379f3329..904c673766 100644 --- a/doc/plotting.md +++ b/doc/plotting.md @@ -27,14 +27,6 @@ ::: plot_base_network -## Rule `plot_base_offshore_network` - -::: plot_offshore_network - -## Rule `plot_offshore_network` - -::: plot_offshore_network - ## Rule `plot_power_network_clustered` ::: plot_power_network_clustered @@ -49,10 +41,6 @@ ::: plot_power_network_perfect -## Rule `plot_base_hydrogen_network` - -::: plot_base_hydrogen_network - ## Rule `plot_hydrogen_network` ::: plot_hydrogen_network @@ -93,38 +81,3 @@ ::: plot_interactive_bus_balance -## Rule `clean_tyndp_output_benchmark` - -::: clean_tyndp_output_benchmark - -## Rule `clean_tyndp_report_benchmark` - -::: clean_tyndp_report_benchmark - -## Rule `clean_tyndp_vp_data` - -::: clean_tyndp_vp_data - -## Rule `build_statistics` - -::: build_statistics - -## Rule `make_benchmark` - -::: make_benchmark - -## Rule `plot_benchmark` - -::: plot_benchmark - -## Rule `launch_explorer` - -::: launch_explorer - -## Rule `launch_presolved_explorer` - -Mirrors the `launch_explorer` rule to launch the `PyPSA-Explorer` web interface with pre-solved SB networks from previous Open-TYNDP release runs. - -## Rule `close_explorers` - -Closes all open local instances of launched PyPSA-Explorers and frees up used ports again. diff --git a/doc/preparation.md b/doc/preparation.md index 96889a685b..8225e7265d 100644 --- a/doc/preparation.md +++ b/doc/preparation.md @@ -92,18 +92,10 @@ together into a detailed PyPSA network stored in `networks/base_s_{clusters}_ele ::: build_electricity_demand_base -## Rule `build_electricity_demand_base_tyndp` - -::: build_electricity_demand_base - ## Rule `build_electricity_demand` {#electricity_demand} ::: build_electricity_demand -## Rule `build_electricity_demand_tyndp` - -::: build_electricity_demand - ## Rule `build_hac_features` ::: build_hac_features @@ -155,47 +147,3 @@ together into a detailed PyPSA network stored in `networks/base_s_{clusters}_ele ## Rule `prepare_network` {#prepare} ::: prepare_network - -## Rule `prepare_pecd_release` - -::: prepare_pecd_release - -## Rule `clean_pecd_data` - -::: clean_pecd_data - -## Rule `build_renewable_profiles_pecd` - -::: build_renewable_profiles_pecd - -## Rule `clean_tyndp_hydro_inflows` - -::: clean_tyndp_hydro_inflows - -## Rule `build_tyndp_hydro_profile` - -::: build_tyndp_hydro_profile - -## Rule `build_pemmdb_data` - -::: build_pemmdb_data - -## Rule `build_tyndp_transmission_projects` - -::: build_tyndp_transmission_projects - -## Rule `build_tyndp_trajectories` - -::: build_tyndp_trajectories - -## Rule `clean_tyndp_electricity_demand` - -::: clean_tyndp_electricity_demand - -## Rule `clean_tyndp_smr` - -::: clean_tyndp_smr - -## Rule `clean_tyndp_h2_storages` - -::: clean_tyndp_h2_storages diff --git a/doc/release_notes.md b/doc/release_notes.md index 4431506165..606f9f24aa 100644 --- a/doc/release_notes.md +++ b/doc/release_notes.md @@ -46,6 +46,10 @@ * Improve docstring formatting and add missing type hints (https://github.com/open-energy-transition/open-tyndp/pull/759). +* Improve docstring formatting and add missing type hints ([759](https://github.com/open-energy-transition/open-tyndp/pull/759)). + +* Create rules overview for SB and CBA rules ([761](https://github.com/open-energy-transition/open-tyndp/pull/761)) + **Developers Note** * Change GitHub issue templates to comply with ISO security checks ([#714](https://github.com/open-energy-transition/open-tyndp/pull/714), [#730](https://github.com/open-energy-transition/open-tyndp/pull/730)). diff --git a/doc/retrieve.md b/doc/retrieve.md index d45d9a2434..9e490beb20 100644 --- a/doc/retrieve.md +++ b/doc/retrieve.md @@ -95,34 +95,3 @@ costs: **Outputs** - `data/costs/primary/{version}/costs_{year}.csv` - - -## Rule `retrieve_countries_centroids` - -This rule downloads country centroid geometry data by Copyright (c) 2021 Gavin Rehkemper from https://cdn.jsdelivr.net/gh/gavinr/world-countries-centroids@v1.0.0/dist/countries.geojson. - -**Relevant Settings** - -None. - -**Outputs** - -- `data/countries_centroids.geojson` - - -## Rule `retrieve_presolved_networks` - -This rule downloads pre-solved networks from a previous Open-TYNDP release (*preliminary outcomes* published on [Zenodo](https://zenodo.org/records/18608105)) and extracts the solved network for each planning horizon. These can be investigated with PyPSA-Explorer's web interface using the `launch_presolved_explorer` rule without having to re-run the workflow. - -**Relevant Settings** - -```yaml -data: - open_tyndp_prelim: - source: - version: -``` - -**Outputs** - -- `data/open_tyndp_prelim/{source}/{version}/base_s_all___{planning_horizons}.nc` diff --git a/doc/sb.md b/doc/sb.md index c9d58b9719..eea9075576 100644 --- a/doc/sb.md +++ b/doc/sb.md @@ -79,7 +79,7 @@ a scenario output file from the TYNDP 2024 process used as a fixed input. The SB workflow transforms raw ENTSO-E input datasets into a solved, sector-coupled PyPSA network. The key stages are: integrating public input data, constructing the sector-coupled -network, applying TYNDP-specific constraints, solving the capacity expansion optimisation, visualising results, and running the Open-TYNDP [benchmarking framework](benchmarking.md). +network, applying TYNDP-specific constraints, solving the capacity expansion optimisation, visualising results, and running the Open-TYNDP [benchmarking framework](benchmarking.md). An overview of the SB rules is documented at [SB rules](sb_rules.md). ### Network Construction diff --git a/doc/sb_rules.md b/doc/sb_rules.md new file mode 100644 index 0000000000..8e9335c74b --- /dev/null +++ b/doc/sb_rules.md @@ -0,0 +1,234 @@ + + + +# Scenario Building (SB) + +The Scenario Building (SB) workflow is implemented in `rules/sb.smk`. Rules are organised into stages: `Retrieve`, `Development`, `Build electricity`, `Build sector`, `Postprocess`, `Benchmark` and `Explore`. In addition, a `Collect` stage provides convenient target rules that run the workflow up to a specific stage, aggregating each stage's output across all configured wildcards. + +## Retrieve + +### Rule `retrieve_tyndp_pecd` + +Downloads the PECD dataset. + +### Rule `retrieve_tyndp_vp_data` + +Downloads the TYNDP Visualisation Platform data used by the benchmarking framework. + +### Rule `retrieve_tyndp_nuclear_profiles` + +Downloads per-country nuclear availability profiles. + +### Rule `retrieve_presolved_networks` + +Downloads pre-solved networks from a previous Open-TYNDP release (*preliminary outcomes* +published on [Zenodo](https://doi.org/10.5281/zenodo.18608105)) and extracts the solved network +for each planning horizon. These can be investigated with PyPSA-Explorer's web interface +using the [`launch_presolved_explorer`](#rule-launch_presolved_explorer) rule without having to re-run the workflow. + +**Relevant Settings** + +```yaml +data: + open_tyndp_prelim: + source: + version: +``` + +**Outputs** + +- `data/open_tyndp_prelim/{source}/{version}/base_s_all___{planning_horizons}.nc` + +### Rule `retrieve_countries_centroids` + +Downloads country centroid geometry data by Copyright (c) 2021 Gavin Rehkemper from +. + +**Relevant Settings** + +None. + +**Outputs** + +- `data/countries_centroids.geojson` + +## Development + +### Rule `prepare_pecd_release` + +::: prepare_pecd_release + +## Build electricity + +### Rule `clean_tyndp_electricity_demand` + +::: clean_tyndp_electricity_demand + +### Rule `build_electricity_demand_tyndp` + +Extends the upstream [`build_electricity_demand`](preparation.md#electricity_demand) rule with TYNDP-specific load data. Builds +per-country load time series from the TYNDP electricity demand prepared by +[`clean_tyndp_electricity_demand`](#rule-clean_tyndp_electricity_demand). + +### Rule `clean_pecd_data` + +::: clean_pecd_data + +### Rule `build_renewable_profiles_pecd` + +::: build_renewable_profiles_pecd + +### Rule `build_pemmdb_data` + +::: build_pemmdb_data + +### Rule `build_tyndp_transmission_projects` + +::: build_tyndp_transmission_projects + +### Rule `build_tyndp_trajectories` + +::: build_tyndp_trajectories + +### Rule `clean_tyndp_hydro_inflows` + +::: clean_tyndp_hydro_inflows + +### Rule `build_tyndp_hydro_profile` + +::: build_tyndp_hydro_profile + +### Rule `build_electricity_demand_base_tyndp` + +Extends the upstream [`build_electricity_demand_base`](preparation.md#rule-build_electricity_demand_base) rule with TYNDP-specific load data. Builds +the electricity demand for base regions from the TYNDP electricity demand prepared by +[`build_electricity_demand_tyndp`](#rule-build_electricity_demand_tyndp). + +## Build sector + +### Rule `build_tyndp_gas_demand` + +::: build_tyndp_gas_demand + +### Rule `build_tyndp_h2_demand` + +::: build_tyndp_h2_demand + +### Rule `build_tyndp_h2_network` + +::: build_tyndp_h2_network + +### Rule `clean_tyndp_h2_imports` + +::: clean_tyndp_h2_imports + +### Rule `build_tyndp_h2_imports` + +::: build_tyndp_h2_imports + +### Rule `clean_tyndp_smr` + +::: clean_tyndp_smr + +### Rule `clean_tyndp_h2_storages` + +::: clean_tyndp_h2_storages + +### Rule `build_tyndp_offshore_hubs` + +::: build_tyndp_offshore_hubs + +### Rule `group_tyndp_conventionals` + +::: group_tyndp_conventionals + +## Postprocess + +### Rule `plot_base_hydrogen_network` + +::: plot_base_hydrogen_network + +### Rule `plot_base_offshore_network` + +::: plot_offshore_network + +### Rule `plot_offshore_network` + +::: plot_offshore_network + +## Benchmark + +### Rule `clean_tyndp_output_benchmark` + +::: clean_tyndp_output_benchmark + +### Rule `clean_tyndp_report_benchmark` + +::: clean_tyndp_report_benchmark + +### Rule `clean_tyndp_vp_data` + +::: clean_tyndp_vp_data + +### Rule `build_statistics` + +::: build_statistics + +### Rule `make_benchmark` + +::: make_benchmark + +### Rule `plot_benchmark` + +::: plot_benchmark + +## Collect + +Aggregate rules that run the corresponding base rule across all configured wildcards. They do not have dedicated scripts. + +### Rule `clean_pecd_datas` + +Aggregate [`clean_pecd_data`](#rule-clean_pecd_data) outputs. + +### Rule `build_renewable_profiles_pecds` + +Aggregate [`build_renewable_profiles_pecd`](#rule-build_renewable_profiles_pecd) outputs. + +### Rule `prepare_benchmarks` + +Aggregate benchmark inputs before the benchmarking stage. + +### Rule `make_benchmarks` + +Aggregate [`make_benchmark`](#rule-make_benchmark) outputs. + +### Rule `plot_benchmarks` + +Aggregate [`plot_benchmark`](#rule-plot_benchmark) outputs. + +### Rule `build_pemmdb_and_trajectories` + +Aggregate [`build_pemmdb_data`](#rule-build_pemmdb_data) and [`build_tyndp_trajectories`](#rule-build_tyndp_trajectories) outputs. + +### Rule `build_tyndp_h2_demands` + +Aggregate [`build_tyndp_h2_demand`](#rule-build_tyndp_h2_demand) outputs. + +### Rule `build_tyndp_gas_demands` + +Aggregate [`build_tyndp_gas_demand`](#rule-build_tyndp_gas_demand) outputs. + +## Explore + +### Rule `launch_explorer` + +::: launch_explorer + +### Rule `launch_presolved_explorer` + +Mirrors the [`launch_explorer`](#rule-launch_explorer) rule to launch the PyPSA-Explorer web interface with +pre-solved SB networks from previous Open-TYNDP release runs (see [`retrieve_presolved_networks`](#rule-retrieve_presolved_networks)). + +### Rule `close_explorers` + +Closes all open local instances of launched PyPSA-Explorers and frees up used ports again. diff --git a/doc/sector.md b/doc/sector.md index 1038a0fbad..96ac02b2ba 100644 --- a/doc/sector.md +++ b/doc/sector.md @@ -216,34 +216,6 @@ Having downloaded the necessary data, ::: build_snapshot_weightings -## Rule `build_tyndp_h2_network` - -::: build_tyndp_h2_network - -## Rule `clean_tyndp_h2_imports` - -::: clean_tyndp_h2_imports - -## Rule `build_tyndp_h2_imports` - -::: build_tyndp_h2_imports - -## Rule `build_tyndp_offshore_hubs` - -::: build_tyndp_offshore_hubs - -## Rule `build_tyndp_h2_demand` - -::: build_tyndp_h2_demand - -## Rule `group_tyndp_conventionals` - -::: group_tyndp_conventionals - -## Rule `build_tyndp_gas_demand` - -::: build_tyndp_gas_demand - ## Rule `prepare_sector_network` ::: prepare_sector_network diff --git a/mkdocs.yml b/mkdocs.yml index 355ca64579..d9adc342d5 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -77,6 +77,8 @@ nav: - Data Repositories: data-repos.md - Rules Overview: + - Scenario Building: sb_rules.md + - Cost-Benefit Analysis: cba_rules.md - Retrieving Data: retrieve.md - Building Electricity Networks: preparation.md - Building Sector-Coupled Networks: sector.md @@ -107,6 +109,7 @@ plugins: show_source: false show_root_heading: false show_root_full_path: false + show_root_toc_entry: false members: false allow_inspection: true inventories: diff --git a/rules/cba.smk b/rules/cba.smk index c90db6d1f6..fc76cc9926 100644 --- a/rules/cba.smk +++ b/rules/cba.smk @@ -23,6 +23,9 @@ wildcard_constraints: run="(?!None)[-a-zA-Z0-9]+", # Disallow None as a run wildcard +# Retrieve +########## + if (CBA_PROJECTS_DATASET := dataset_version("tyndp_cba_projects"))[ "source" ] in ARCHIVE_SOURCES: @@ -61,13 +64,13 @@ if (CBA_GUIDELINES_DATASET := dataset_version("cba_guidelines_reference_projects "source" ] in ARCHIVE_SOURCES: - rule retreive_cba_guidelines_reference_projects: + rule retrieve_cba_guidelines_reference_projects: input: file=storage(CBA_GUIDELINES_DATASET["url"]), output: file=f"{CBA_GUIDELINES_DATASET['folder']}/table_B1_CBA_Implementations_Guidelines_TYNDP2024.csv", log: - "logs/retreive_cba_guidelines_reference_projects.log", + "logs/retrieve_cba_guidelines_reference_projects.log", run: copy2(input["file"], output["file"]) @@ -140,6 +143,10 @@ if config.get("cba", {}).get("cba_scenario_input", {}).get("use_presolved", Fals +# Build MSV +############ + + # read in transmission and storage projects from excel sheets # def input_clustered_network(w): @@ -152,7 +159,7 @@ checkpoint clean_projects: input: dir=rules.retrieve_tyndp_cba_projects.output.dir, buses=rules.retrieve_tyndp.output.nodes, - guidelines=rules.retreive_cba_guidelines_reference_projects.output.file, + guidelines=rules.retrieve_cba_guidelines_reference_projects.output.file, output: # TODO: The toot_projects and pint_projects outputs are likely only # transmission projects (no storage). In order to confirm, we should check @@ -267,7 +274,7 @@ def get_elec_project_build_years(w): rule fix_reference_sb_to_cba: input: invest_grid=rules.retrieve_tyndp.output.invest_grid, - guidelines=rules.retreive_cba_guidelines_reference_projects.output.file, + guidelines=rules.retrieve_cba_guidelines_reference_projects.output.file, transmission_projects=rules.clean_projects.output.transmission_projects, buses=rules.build_tyndp_network.output.substations_geojson, output: @@ -314,7 +321,7 @@ rule build_msv_snapshot_weightings: msv_resolution=config_provider("cba", "msv_extraction", "resolution"), drop_leap_day=config_provider("enable", "drop_leap_day"), script: - "../scripts/cba/build_msv_snapshot_weightings.py" + scripts("cba/build_msv_snapshot_weightings.py") def input_msv_snapshot_weightings(w): @@ -343,7 +350,11 @@ rule solve_cba_msv_extraction: msv_resolution=config_provider("cba", "msv_extraction", "resolution"), cyclic_carriers=config_provider("cba", "storage", "cyclic_carriers"), script: - "../scripts/cba/solve_cba_msv_extraction.py" + scripts("cba/solve_cba_msv_extraction.py") + + +# Build rolling horizon +####################### # Prepare network for rolling horizon: disable seasonal cyclicity, apply marginal storage value @@ -427,6 +438,10 @@ rule solve_cba_network: scripts("cba/solve_cba_network.py") +# Postprocess +############## + + # Compute CBA indicators comparing reference and project networks rule make_indicators: input: @@ -475,19 +490,19 @@ def input_indicators(w): ) -# Collect indicators for all projects into overview CSV -rule collect_indicators: +# Combine indicators for all projects into overview CSV +rule combine_indicators: input: indicators=input_indicators, output: indicators=RESULTS + "cba/indicators_{planning_horizons}.csv", script: - scripts("cba/collect_indicators.py") + scripts("cba/combine_indicators.py") rule plot_indicators: input: - indicators=rules.collect_indicators.output.indicators, + indicators=rules.combine_indicators.output.indicators, transmission_projects=rules.clean_projects.output.transmission_projects, output: plot_dir=directory(RESULTS + "cba/plots_{planning_horizons}"), @@ -497,6 +512,10 @@ rule plot_indicators: scripts("cba/plot_indicators.py") +# Benchmarking +############### + + rule plot_cba_benchmark: input: indicators=RESULTS + "cba/project_{cba_project}_{planning_horizons}.csv", @@ -509,7 +528,7 @@ rule plot_cba_benchmark: # rule plot_all_cba_benchmark: # input: -# indicators=rules.collect_indicators.output.indicators, +# indicators=rules.combine_indicators.output.indicators, # output: # plot_dir=directory(RESULTS + "cba/validation_{planning_horizons}"), # script: @@ -518,13 +537,13 @@ rule plot_cba_benchmark: rule plot_weather_benchmark: input: - # indicators=rules.collect_indicators.output.indicators, + # indicators=rules.combine_indicators.output.indicators, indicators=rules.make_indicators.output.indicators, output: plot_file=RESULTS + "cba/ensemble_plots/ensemble_{cba_project}_{planning_horizons}.png", script: - "../scripts/cba/plot_benchmark_indicators.py" + scripts("cba/plot_benchmark_indicators.py") rule average_indicators_per_project_and_planning_horizon: @@ -539,7 +558,7 @@ rule average_indicators_per_project_and_planning_horizon: indicators=RESULTS + "cba/ensemble_indicators/ensemble_indicators_{cba_project}_{planning_horizons}.csv", script: - "../scripts/cba/average_indicators.py" + scripts("cba/average_indicators.py") rule summarize_indicators_per_project: @@ -553,7 +572,7 @@ rule summarize_indicators_per_project: output: plot_file=RESULTS + "cba/ensemble_plots/ensemble_{cba_project}_all_horizons.png", script: - "../scripts/cba/summarize_indicators.py" + scripts("cba/summarize_indicators.py") rule summarize_all_indicators: @@ -567,7 +586,7 @@ rule summarize_all_indicators: output: plot_file=RESULTS + "cba/ensemble_plots/ensemble_all.png", script: - "../scripts/cba/summarize_all.py" + scripts("cba/summarize_all.py") def cba_target_runs(w): @@ -706,6 +725,10 @@ def collect_cba_scenario_inputs(w): return inputs +# Collect +########## + + # collect files to be stored in the scenario directory, e.g., NT-cy1995 rule collect_cba_scenario: input: diff --git a/rules/sb.smk b/rules/sb.smk index a4e4e68b8e..8b9b7c6cae 100644 --- a/rules/sb.smk +++ b/rules/sb.smk @@ -592,7 +592,7 @@ if config["sector"]["h2_topology_tyndp"]: tyndp_scenario=config_provider("tyndp_scenario"), h2_zones_tyndp=config_provider("sector", "h2_zones_tyndp"), script: - "../scripts/sb/clean_tyndp_smr.py" + scripts("sb/clean_tyndp_smr.py") rule clean_tyndp_h2_storages: input: @@ -612,7 +612,7 @@ if config["sector"]["h2_topology_tyndp"]: tyndp_scenario=config_provider("tyndp_scenario"), h2_zones_tyndp=config_provider("sector", "h2_zones_tyndp"), script: - "../scripts/sb/clean_tyndp_h2_storages.py" + scripts("sb/clean_tyndp_h2_storages.py") if config["sector"]["offshore_hubs_tyndp"]["enable"]: @@ -756,8 +756,8 @@ if config["foresight"] != "perfect": expanded=True, -# Benchmarking -############## +# Benchmark +########### if config["benchmarking"]["enable"]: @@ -1103,6 +1103,10 @@ rule build_tyndp_gas_demands: ), +# Explore +########### + + rule launch_explorer: input: expand( diff --git a/scripts/cba/average_indicators.py b/scripts/cba/average_indicators.py index 07f2ae3c06..5868f4ac0f 100644 --- a/scripts/cba/average_indicators.py +++ b/scripts/cba/average_indicators.py @@ -182,7 +182,9 @@ def average_indicators_csv( if "snakemake" not in globals(): from scripts._helpers import mock_snakemake - snakemake = mock_snakemake("collect_indicators") + snakemake = mock_snakemake( + "average_indicators_per_project_and_planning_horizon" + ) configure_logging(snakemake) set_scenario_config(snakemake) diff --git a/scripts/cba/collect_indicators.py b/scripts/cba/combine_indicators.py similarity index 85% rename from scripts/cba/collect_indicators.py rename to scripts/cba/combine_indicators.py index ed64d830a0..4d5c9e30aa 100644 --- a/scripts/cba/collect_indicators.py +++ b/scripts/cba/combine_indicators.py @@ -17,7 +17,7 @@ logger = logging.getLogger(__name__) -def collect_indicators_csv(input_files: list[str], output_file: str) -> None: +def combine_indicators_csv(input_files: list[str], output_file: str) -> None: """ Concatenate multiple CSV files into one using the csv module. @@ -38,7 +38,7 @@ def collect_indicators_csv(input_files: list[str], output_file: str) -> None: pass return - logger.info(f"Collecting {len(input_files)} indicator files") + logger.info(f"Combining {len(input_files)} indicator files") # Read header from first file with open(input_files[0], newline="") as f: @@ -68,17 +68,17 @@ def collect_indicators_csv(input_files: list[str], output_file: str) -> None: writer.writerow(row) row_count += 1 - logger.info(f"Collected {row_count} rows from {len(input_files)} files") + logger.info(f"Combined {row_count} rows from {len(input_files)} files") if __name__ == "__main__": if "snakemake" not in globals(): from scripts._helpers import mock_snakemake - snakemake = mock_snakemake("collect_indicators") + snakemake = mock_snakemake("combine_indicators") configure_logging(snakemake) set_scenario_config(snakemake) - # Collect all indicators into a single CSV - collect_indicators_csv(snakemake.input.indicators, snakemake.output.indicators) + # Combine all indicators into a single CSV + combine_indicators_csv(snakemake.input.indicators, snakemake.output.indicators) diff --git a/scripts/cba/make_indicators.py b/scripts/cba/make_indicators.py index 9ee06026fd..db2dc67db7 100644 --- a/scripts/cba/make_indicators.py +++ b/scripts/cba/make_indicators.py @@ -9,23 +9,24 @@ cases. PINT (Put In at a Time): - - Reference: Network WITHOUT any projects - - Project: Network WITH the specific project added - - B1 = OPEX(reference) - OPEX(with project) + +- Reference: Network WITHOUT any projects +- Project: Network WITH the specific project added +- B1 = OPEX(reference) - OPEX(with project) TOOT (Take Out One at a Time): - - Reference: Network WITH all projects (current plan) - - Project: Network WITHOUT the specific project (removed) - - B1 = OPEX(without project) - OPEX(reference) + +- Reference: Network WITH all projects (current plan) +- Project: Network WITHOUT the specific project (removed) +- B1 = OPEX(without project) - OPEX(reference) References: -- CBA guidelines: https://eepublicdownloads.blob.core.windows.net/public-cdn-container/clean-documents/news/2024/entso-e_4th_CBA_Guideline_240409.pdf - - section 3.2.2: TOOT and PINT, page 23-24 -- CBA implementation guidelines: https://eepublicdownloads.blob.core.windows.net/public-cdn-container/tyndp-documents/TYNDP2024/foropinion/CBA_Implementation_Guidelines.pdf - - section 5.1: B1 - SEW, page 58-59 -""" +- [CBA guidelines](https://eepublicdownloads.blob.core.windows.net/public-cdn-container/clean-documents/news/2024/entso-e_4th_CBA_Guideline_240409.pdf), section 3.2.2: TOOT and PINT, page 23-24 +- [CBA implementation guidelines](https://eepublicdownloads.blob.core.windows.net/public-cdn-container/tyndp-documents/TYNDP2024/foropinion/CBA_Implementation_Guidelines.pdf), section 5.1: B1 - SEW, page 58-59 + +""" # noqa: D412 import logging from pathlib import Path diff --git a/scripts/cba/plot_indicators.py b/scripts/cba/plot_indicators.py index 0a92b810f5..4e069e24ce 100644 --- a/scripts/cba/plot_indicators.py +++ b/scripts/cba/plot_indicators.py @@ -5,7 +5,7 @@ """ Create plots for CBA indicators. -This script reads the collected indicators CSV file and generates various +This script reads the combined indicators CSV file and generates various plots to visualize the cost-benefit analysis results, including the B1 indicator (Total System Cost difference). """ diff --git a/scripts/cba/summarize_all.py b/scripts/cba/summarize_all.py index 6cbca2c559..f884fd0ba4 100644 --- a/scripts/cba/summarize_all.py +++ b/scripts/cba/summarize_all.py @@ -229,7 +229,7 @@ def create_plots( if "snakemake" not in globals(): from scripts._helpers import mock_snakemake - snakemake = mock_snakemake("collect_indicators") + snakemake = mock_snakemake("summarize_all_indicators") configure_logging(snakemake) set_scenario_config(snakemake) diff --git a/scripts/cba/summarize_indicators.py b/scripts/cba/summarize_indicators.py index f55f293e54..62219d2285 100644 --- a/scripts/cba/summarize_indicators.py +++ b/scripts/cba/summarize_indicators.py @@ -374,7 +374,7 @@ def summarize_indicators(input_files: list[str], output_file: str) -> None: if "snakemake" not in globals(): from scripts._helpers import mock_snakemake - snakemake = mock_snakemake("collect_indicators") + snakemake = mock_snakemake("summarize_indicators") configure_logging(snakemake) set_scenario_config(snakemake) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index e06dc22dc1..fd5ceb92e7 100755 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -3929,7 +3929,7 @@ def add_h2_storage_tyndp( n : pypsa.Network The PyPSA network container object. buses_h2_z1 : pd.Index - Nnodes of H2 Z1 buses. + Nodes of H2 Z1 buses. buses_h2_z2 : pd.Index Nodes of H2 Z2 buses. costs : pd.DataFrame diff --git a/scripts/sb/build_pemmdb_data.py b/scripts/sb/build_pemmdb_data.py index 0e99395045..860f09d94c 100644 --- a/scripts/sb/build_pemmdb_data.py +++ b/scripts/sb/build_pemmdb_data.py @@ -11,13 +11,9 @@ - `resources/pemmdb_capacities_{planning_horizon}.csv` in long format - `resources/pemmdb_profiles_{planning_horizon}.nc` with the following structure: - =================== ==================== ========================================================= - Field Coordinates Description - =================== ==================== ========================================================= - p_min_pu, time, bus, carrier, the per unit hourly availability and must-run obligations - p_max_pu index_carrier, for each bus and PEMMDB technology - open_tyndp_type - =================== ==================== ========================================================= + | Field | Coordinates | Description | + | ------------------ | -------------------------------------------------- | -------------------------------------------------------------------- | + | p_min_pu, p_max_pu | time, bus, carrier, index_carrier, open_tyndp_type | the per unit hourly availability and must-run obligations for each bus and PEMMDB technology | """ import logging diff --git a/scripts/sb/build_renewable_profiles_pecd.py b/scripts/sb/build_renewable_profiles_pecd.py index 307b601d18..b80ea145f9 100644 --- a/scripts/sb/build_renewable_profiles_pecd.py +++ b/scripts/sb/build_renewable_profiles_pecd.py @@ -13,11 +13,9 @@ - `resources/profile_pecd_{clusters}_{technology}.nc` with the following structure - =================== ==================== ========================================================= - Field Dimensions Description - =================== ==================== ========================================================= - profile year, bus, bin, time the per unit hourly availability factors for each bus - =================== ==================== ========================================================= + | Field | Dimensions | Description | + | ------- | -------------------- | -------------------------------------------------- | + | profile | year, bus, bin, time | the per unit hourly availability factors for each bus | """ import logging diff --git a/scripts/sb/build_tyndp_hydro_profile.py b/scripts/sb/build_tyndp_hydro_profile.py index 2b9acee2a0..6b7b59c36d 100644 --- a/scripts/sb/build_tyndp_hydro_profile.py +++ b/scripts/sb/build_tyndp_hydro_profile.py @@ -9,12 +9,9 @@ - `resources/profile_pemmdb_hydro.nc`: - =================== ================ ========================================================= - Field Dimensions Description - =================== ================ ========================================================= - inflow bus, time, Inflow to the state of charge (in MW), - year, hydro_tech e.g. due to river inflow in hydro reservoir. - =================== ================ ========================================================= + | Field | Dimensions | Description | + | ------ | ------------------------------- | ------------------------------------------------------------------------ | + | inflow | bus, time, year, hydro_tech | Inflow to the state of charge (in MW), e.g. due to river inflow in hydro reservoir. | """ import logging