Skip to content

Commit 0c98512

Browse files
author
Michael Lindner
authored
Merge branch 'main' into fix-power-limit
2 parents da6fced + 98a27b5 commit 0c98512

File tree

73 files changed

+18637
-2538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+18637
-2538
lines changed

.github/workflows/codeql.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959

6060
# Initializes the CodeQL tools for scanning.
6161
- name: Initialize CodeQL
62-
uses: github/codeql-action/init@v3
62+
uses: github/codeql-action/init@v4
6363
with:
6464
languages: ${{ matrix.language }}
6565
build-mode: ${{ matrix.build-mode }}
@@ -87,6 +87,6 @@ jobs:
8787
exit 1
8888
8989
- name: Perform CodeQL Analysis
90-
uses: github/codeql-action/analyze@v3
90+
uses: github/codeql-action/analyze@v4
9191
with:
9292
category: "/language:${{matrix.language}}"

.github/workflows/test.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ jobs:
6969
path: |
7070
data
7171
cutouts
72-
resources/ariadne_database.csv
7372
key: data-cutouts-${{ env.WEEK }}
7473

7574
- uses: conda-incubator/setup-miniconda@v3

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ci:
55

66
repos:
77
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v5.0.0
8+
rev: v6.0.0
99
hooks:
1010
- id: check-merge-conflict
1111
- id: check-added-large-files
@@ -14,7 +14,7 @@ repos:
1414
# Run ruff to lint and format
1515
- repo: https://github.com/astral-sh/ruff-pre-commit
1616
# Ruff version.
17-
rev: v0.12.2
17+
rev: v0.13.3
1818
hooks:
1919
# Run the linter.
2020
- id: ruff
@@ -43,11 +43,11 @@ repos:
4343
rev: v2.15.0
4444
hooks:
4545
- id: pretty-format-yaml
46-
exclude: (pinned\.yaml|\.lock\.yaml)$
46+
exclude: (\.lock\.yaml)$
4747
args: [--autofix, --indent, "2", --preserve-quotes]
4848

4949
# Format Snakemake rule / workflow files
5050
- repo: https://github.com/snakemake/snakefmt
51-
rev: v0.11.0
51+
rev: v0.11.2
5252
hooks:
5353
- id: snakefmt

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22
- Bugfix: Enforce stricter power import limit to avoid that import from one country compensate from exports to another
3+
- Added the IIASA database to the repository and disabled re-downloading it by default.
4+
- Simplified IIASA database download, rename `iiasa_database` config section to `pypsa-de`
5+
- Updated technology-data to v0.13.4
36
- Bugfix: Enforce stricter H2 derivative import limit to avoid that exports of one type of derivative compensate for imports of another
47
- Added an option to source mobility demand from UBA MWMS (Projektionsbericht 2025) for the years 2025-2035
58
- Renamed functions and script for exogenous mobility demand

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ PyPSA-DE is a softfork of PyPSA-EUR. As such, large parts of the functionality a
7777

7878
## New Config Options
7979

80-
- `iiasa_database` - interaction with IIASA database. Specify a database, and `leitmodelle` for demand and co2 emissions data in specific sectors
80+
- `pypsa-de` - interaction with IIASA database. Specify a database, and `leitmodelle` for demand and co2 emissions data in specific sectors
8181
- `wasserstoff_kernnetz` - configure which parts of the Wasserstoff Kernnetz should be included in the model
8282
- `new_decentral_fossil_boiler_ban` - specify in which country and which years to ban fossil boilers
8383
- `coal_generation_ban` - specify in which country and which years to ban electricity generation from coal
@@ -87,6 +87,15 @@ PyPSA-DE is a softfork of PyPSA-EUR. As such, large parts of the functionality a
8787
- `co2_budget_DE_source` specify the carbon trajectory for Germany: Following the projections of the Umweltbundestamt (`UBA`) or targeting net zero with the Klimaschutzgesetz(`KSG`)
8888
- `costs:NEP` and `costs:transmission` - specify which year of the Netzentwicklungsplan should be used as basis for the transmission line costs (`2021,2023`) and if new HVDC links should be built with `overhead` or `underground` cables
8989

90+
## Data sources
91+
92+
`ariadne-data/ariadne-database.csv`
93+
94+
* **Source:** Kopernikus Projekt Ariadne
95+
* **Link:** [Szenarien-Explorer](https://ariadne2.apps.ece.iiasa.ac.at/explorer)
96+
* **License:** CC-BY 4.0
97+
* **Description:** Results from the [Ariadne Report: Die Energiewende kosteneffizient gestalten](https://ariadneprojekt.de/publikation/report-szenarien-zur-klimaneutralitat-2045/)
98+
9099
## License
91100

92101
The code in this repo is MIT licensed, see `./LICENSE.md`.

Snakefile

Lines changed: 76 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -302,33 +302,6 @@ rule clean:
302302
print("Data downloaded to data/ has not been cleaned.")
303303

304304

305-
rule retrieve_egon_data:
306-
output:
307-
spatial="data/egon/demandregio_spatial_2018.json",
308-
mapping="data/egon/mapping_technologies.json",
309-
shell:
310-
"""
311-
mkdir -p data/egon
312-
curl -o {output.spatial} "https://api.opendata.ffe.de/demandregio/demandregio_spatial?id_spatial=5&year=2018"
313-
curl -o {output.mapping} "https://api.opendata.ffe.de/demandregio/demandregio_spatial_description?id_spatial=5"
314-
"""
315-
316-
317-
rule retrieve_ariadne_database:
318-
params:
319-
db_name=config["iiasa_database"]["db_name"],
320-
leitmodelle=config["iiasa_database"]["leitmodelle"],
321-
scenarios=config["iiasa_database"]["scenarios"],
322-
output:
323-
data="resources/ariadne_database.csv",
324-
log:
325-
"logs/retrieve_ariadne_database.log",
326-
resources:
327-
mem_mb=1000,
328-
script:
329-
"scripts/pypsa-de/retrieve_ariadne_database.py"
330-
331-
332305
rule modify_cost_data:
333306
params:
334307
file_path="ariadne-data/costs/",
@@ -354,23 +327,87 @@ rule modify_cost_data:
354327
"scripts/pypsa-de/modify_cost_data.py"
355328

356329

330+
if config["pypsa-de"]["retrieve_ariadne_database"]:
331+
332+
rule retrieve_ariadne_database:
333+
output:
334+
data="data/ariadne_database.csv",
335+
log:
336+
"logs/retrieve_ariadne_database.log",
337+
resources:
338+
mem_mb=1000,
339+
script:
340+
"scripts/pypsa-de/retrieve_ariadne_database.py"
341+
342+
def get_ariadne_database(w):
343+
if config["pypsa-de"]["retrieve_ariadne_database"]:
344+
return "data/ariadne_database.csv"
345+
else:
346+
return "ariadne-data/ariadne_database.csv"
347+
348+
349+
if config["enable"]["retrieve"]:
350+
351+
rule retrieve_ariadne_template:
352+
input:
353+
storage(
354+
"https://github.com/iiasa/ariadne-intern-workflow/raw/main/attachments/2025-01-27_template_Ariadne.xlsx",
355+
keep_local=True,
356+
),
357+
output:
358+
"data/template_ariadne_database.xlsx",
359+
run:
360+
move(input[0], output[0])
361+
362+
363+
if config["enable"]["retrieve"]:
364+
365+
rule retrieve_mastr:
366+
input:
367+
storage(
368+
"https://zenodo.org/records/8225106/files/bnetza_open_mastr_2023-08-08_B.zip",
369+
keep_local=True,
370+
),
371+
params:
372+
"data/mastr",
373+
output:
374+
"data/mastr/bnetza_open_mastr_2023-08-08_B_biomass.csv",
375+
"data/mastr/bnetza_open_mastr_2023-08-08_B_combustion.csv",
376+
run:
377+
unpack_archive(input[0], params[0])
378+
379+
380+
if config["enable"]["retrieve"]:
381+
382+
rule retrieve_egon_data:
383+
output:
384+
spatial="data/egon/demandregio_spatial_2018.json",
385+
mapping="data/egon/mapping_technologies.json",
386+
shell:
387+
"""
388+
mkdir -p data/egon
389+
curl -o {output.spatial} "https://api.opendata.ffe.de/demandregio/demandregio_spatial?id_spatial=5&year=2018"
390+
curl -o {output.mapping} "https://api.opendata.ffe.de/demandregio/demandregio_spatial_description?id_spatial=5"
391+
"""
392+
393+
357394
if config["enable"]["retrieve"] and config["enable"].get("retrieve_cost_data", True):
358395

359396
ruleorder: modify_cost_data > retrieve_cost_data
360397

361398

362399
rule build_exogenous_mobility_data:
363400
params:
364-
reference_scenario=config_provider("iiasa_database", "reference_scenario"),
401+
reference_scenario=config_provider("pypsa-de", "reference_scenario"),
365402
planning_horizons=config_provider("scenario", "planning_horizons"),
366-
leitmodelle=config_provider("iiasa_database", "leitmodelle"),
367-
ageb_for_mobility=config_provider("iiasa_database", "ageb_for_mobility"),
368-
uba_for_mobility=config_provider("iiasa_database", "uba_for_mobility"),
403+
leitmodelle=config_provider("pypsa-de", "leitmodelle"),
404+
ageb_for_mobility=config_provider("pypsa-de", "ageb_for_mobility"),
405+
uba_for_mobility=config_provider("pypsa-de", "uba_for_mobility"),
369406
shipping_oil_share=config_provider("sector", "shipping_oil_share"),
370407
aviation_demand_factor=config_provider("sector", "aviation_demand_factor"),
371408
energy_totals_year=config_provider("energy", "energy_totals_year"),
372409
input:
373-
ariadne="resources/ariadne_database.csv",
410+
ariadne=get_ariadne_database,
374411
energy_totals=resources("energy_totals.csv"),
375412
output:
376413
mobility_data=resources(
@@ -599,11 +636,8 @@ ruleorder: modify_industry_demand > build_industrial_production_per_country_tomo
599636

600637

601638
rule modify_existing_heating:
602-
params:
603-
iiasa_reference_scenario=config_provider("iiasa_database", "reference_scenario"),
604-
leitmodelle=config_provider("iiasa_database", "leitmodelle"),
605639
input:
606-
ariadne="resources/ariadne_database.csv",
640+
ariadne=get_ariadne_database,
607641
existing_heating="data/existing_infrastructure/existing_heating_raw.csv",
608642
output:
609643
existing_heating=resources("existing_heating.csv"),
@@ -615,21 +649,6 @@ rule modify_existing_heating:
615649
"scripts/pypsa-de/modify_existing_heating.py"
616650

617651

618-
rule retrieve_mastr:
619-
input:
620-
storage(
621-
"https://zenodo.org/records/8225106/files/bnetza_open_mastr_2023-08-08_B.zip",
622-
keep_local=True,
623-
),
624-
params:
625-
"data/mastr",
626-
output:
627-
"data/mastr/bnetza_open_mastr_2023-08-08_B_biomass.csv",
628-
"data/mastr/bnetza_open_mastr_2023-08-08_B_combustion.csv",
629-
run:
630-
unpack_archive(input[0], params[0])
631-
632-
633652
rule build_existing_chp_de:
634653
params:
635654
district_heating_subnodes=config_provider(
@@ -658,9 +677,9 @@ rule build_existing_chp_de:
658677

659678
rule modify_industry_demand:
660679
params:
661-
reference_scenario=config_provider("iiasa_database", "reference_scenario"),
680+
reference_scenario=config_provider("pypsa-de", "reference_scenario"),
662681
input:
663-
ariadne="resources/ariadne_database.csv",
682+
ariadne=get_ariadne_database,
664683
industrial_production_per_country_tomorrow=resources(
665684
"industrial_production_per_country_tomorrow_{planning_horizons}.csv"
666685
),
@@ -722,18 +741,6 @@ rule cluster_wasserstoff_kernnetz:
722741
"scripts/pypsa-de/cluster_wasserstoff_kernnetz.py"
723742

724743

725-
rule download_ariadne_template:
726-
input:
727-
storage(
728-
"https://github.com/iiasa/ariadne-intern-workflow/raw/main/attachments/2025-01-27_template_Ariadne.xlsx",
729-
keep_local=True,
730-
),
731-
output:
732-
"data/template_ariadne_database.xlsx",
733-
run:
734-
move(input[0], output[0])
735-
736-
737744
rule export_ariadne_variables:
738745
params:
739746
planning_horizons=config_provider("scenario", "planning_horizons"),
@@ -794,11 +801,10 @@ rule export_ariadne_variables:
794801

795802
rule plot_ariadne_variables:
796803
params:
797-
iiasa_scenario=config_provider("iiasa_database", "reference_scenario"),
798-
reference_scenario=config_provider("iiasa_database", "reference_scenario"),
804+
reference_scenario=config_provider("pypsa-de", "reference_scenario"),
799805
input:
800806
exported_variables_full=RESULTS + "ariadne/exported_variables_full.xlsx",
801-
ariadne_database="resources/ariadne_database.csv",
807+
ariadne_database=get_ariadne_database,
802808
output:
803809
primary_energy=RESULTS + "ariadne/primary_energy.png",
804810
primary_energy_detailed=RESULTS + "ariadne/primary_energy_detailed.png",
@@ -863,9 +869,9 @@ rule ariadne_all:
863869
rule build_scenarios:
864870
params:
865871
scenarios=config["run"]["name"],
866-
leitmodelle=config["iiasa_database"]["leitmodelle"],
872+
leitmodelle=config["pypsa-de"]["leitmodelle"],
867873
input:
868-
ariadne_database="resources/ariadne_database.csv",
874+
ariadne_database=get_ariadne_database,
869875
scenario_yaml=config["run"]["scenarios"]["manual_file"],
870876
output:
871877
scenario_yaml=config["run"]["scenarios"]["file"],

0 commit comments

Comments
 (0)