Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement climate projections #929

Open
wants to merge 56 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
73601f9
Initial commit
ekatef Nov 19, 2023
c68abbe
Move a projection script into script directory
ekatef Nov 28, 2023
2beb879
Restructure into Snakemake workflow
ekatef Nov 29, 2023
1a24bad
Organize code
ekatef Nov 29, 2023
174b0b1
Add inputs
ekatef Nov 30, 2023
4594541
Fix Snakemake inputs
ekatef Nov 30, 2023
83c6b0b
Improve documenting
ekatef Nov 30, 2023
b196e5a
Code clean-up
ekatef Nov 30, 2023
369bc9b
Remove hardcoding and add debug plotting
ekatef Nov 30, 2023
d1fd454
Add parameters to the tacked configs
ekatef Nov 30, 2023
21a1751
Merge branch 'main' into implement_climate_projections
ekatef Nov 30, 2023
33225c7
Merge branch 'main' into implement_climate_projections
ekatef Dec 26, 2023
72272d5
Fix wildcards for the projection
ekatef Dec 26, 2023
b288ce7
Merge branch 'pypsa-meets-earth:main' into implement_climate_projections
ekatef Dec 26, 2023
7d3de0f
Merge branch 'implement_climate_projections' of https://github.com/ek…
ekatef Dec 26, 2023
bc5575f
Adjust inputs-outputs in the script docstring
ekatef Dec 26, 2023
d77af95
Add methodology
ekatef Dec 26, 2023
51c8a09
Add docstrings
ekatef Dec 26, 2023
cebf6a3
Add TODOs
ekatef Dec 26, 2023
0d7ec1d
Fix format
ekatef Dec 26, 2023
0e507c1
Fix input
ekatef Dec 27, 2023
47c628a
Remove hardcoding for a parameter name in a projection dataset
ekatef Dec 27, 2023
dc735ba
Remove hardcoding for a parameter name in a cutout dataset
ekatef Dec 27, 2023
4500f45
Wrap plots into functions
ekatef Dec 27, 2023
7d8e17e
Update docstrings
ekatef Dec 27, 2023
42da0b8
Draft stretch implementation
ekatef Dec 27, 2023
e4780a9
Remove a TODO
ekatef Dec 28, 2023
dbe81ac
Use numpy functions
ekatef Dec 28, 2023
5fa9712
Clarify a docstring
ekatef Dec 28, 2023
b4e1893
Improve inputs
ekatef Dec 28, 2023
a292e14
Fix names of the inputs
ekatef Dec 28, 2023
3715f9f
Improve naming
ekatef Dec 28, 2023
a33b9ec
Add a stretch-reference to the docstring
ekatef Dec 28, 2023
d061ef3
Wrap preparation of cmip6-xarrays into a function
ekatef Dec 28, 2023
1c46763
Add stretch
ekatef Dec 28, 2023
f3825f2
Implement stretch
ekatef Dec 28, 2023
989ae50
Fix names
ekatef Dec 28, 2023
f68bf21
Test stretch
ekatef Dec 28, 2023
ba3d1a7
Fix plot parameters
ekatef Dec 28, 2023
c1bfe0c
Improve comments to the config parameters
ekatef Jan 20, 2024
9d21fde
Add comments to the projection calculations
ekatef Jan 20, 2024
58ec438
Merge branch 'main' into implement_climate_projections
ekatef Mar 8, 2024
a8f8636
Fix formatting
ekatef Mar 8, 2024
33d90d2
Enhance docstrings
ekatef Mar 8, 2024
f5cb70e
Improve naming
ekatef Mar 8, 2024
2177bb1
Fix parameters in a function call
ekatef Mar 8, 2024
49117f2
Merge branch 'main' into implement_climate_projections
ekatef Mar 8, 2024
19b65fc
Improve explanation for stretch calculations
ekatef Mar 8, 2024
7ca6216
Improve naming and add enable parameters to the configs
ekatef Mar 9, 2024
39fd2d1
Fix typo
ekatef Mar 9, 2024
517e422
Replace hard-coding
ekatef Mar 9, 2024
1f3520d
Improve naming
ekatef Mar 9, 2024
dd4b060
Add a check for time match
ekatef Mar 9, 2024
f71390f
Fix typo
ekatef Mar 9, 2024
14707c8
Update the docstring
ekatef Mar 9, 2024
47e7946
Remove TODOs
ekatef Mar 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ wildcard_constraints:
ll="(v|c)([0-9\.]+|opt|all)|all",
opts="[-+a-zA-Z0-9\.]*",
unc="[-+a-zA-Z0-9\.]*",
# "^proj-" is reserved for projections, negative lookbehind assertion used in the regexp
cutout=".+(?<!proj-)",


if config["custom_rules"] is not []:
Expand Down Expand Up @@ -363,6 +365,33 @@ if config["enable"].get("build_cutout", False):
"scripts/build_cutout.py"


if config["enable"].get("climate_projection_cutout", False):

rule build_climate_projections:
params:
snapshots=config["snapshots"],
climate_scenario=config["projection"]["climate_scenario"],
base_year=config["projection"]["base_year"],
future_year=config["projection"]["future_year"],
years_window=config["projection"]["years_window"],
cmip6_nn_fl=config["projection"]["cmip6_nn_fl"],
cmip6_xx_fl=config["projection"]["cmip6_xx_fl"],
input:
cutout="cutouts/" + CDIR + "{cutout}.nc",
cmip6_avr="data/cmip6/t_CMIP6_ssp245_mon_201501-210012.nc",
output:
"cutouts/" + CDIR + "proj-{cutout}.nc",
log:
"logs/" + RDIR + "build_climate_projections/proj-{cutout}.log",
benchmark:
"benchmarks/" + RDIR + "proj-{cutout}"
threads: ATLITE_NPROCESSES
resources:
mem_mb=ATLITE_NPROCESSES * 1000,
script:
"scripts/build_climate_projections.py"


if config["enable"].get("build_natura_raster", False):

rule build_natura_raster:
Expand Down
11 changes: 11 additions & 0 deletions config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enable:
# If "build_cutout" : true, then environmental data is extracted according to `snapshots` date range and `countries`
# requires cds API key https://cds.climate.copernicus.eu/api-how-to
# More information https://atlite.readthedocs.io/en/latest/introduction.html#datasets
climate_projection_cutout: false

custom_rules: [] # Default empty [] or link to custom rule file e.g. ["my_folder/my_rules.smk"] that add rules to Snakefile

Expand Down Expand Up @@ -203,6 +204,16 @@ atlite:
# y: [33., 72] # manual set cutout range


projection:
climate_scenario: ssp245
base_year: 2020
future_year: 2050
years_window: 5 # a half of width currently
gcm_selection: false # false to use all the available global climate models
cmip6_nn_fl: data/cmip6/tnn_CMIP6_ssp245_mon_201501-210012.nc # false or names of min-extremal files of climate inputs
cmip6_xx_fl: data/cmip6/txx_CMIP6_ssp245_mon_201501-210012.nc # false or names of max-extremal files of climate inputs


renewable:
onwind:
cutout: cutout-2013-era5
Expand Down
12 changes: 12 additions & 0 deletions config.tutorial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enable:
# If "build_cutout" : true # requires cds API key https://cds.climate.copernicus.eu/api-how-to
# More information https://atlite.readthedocs.io/en/latest/introduction.html#datasets
build_cutout: false
climate_projection_cutout: false
build_natura_raster: true # If True, then build_natura_raster can be run

custom_rules: [] # Default empty [] or link to custom rule file e.g. ["my_folder/my_rules.smk"] that add rules to Snakefile
Expand Down Expand Up @@ -217,6 +218,17 @@ atlite:
# x: [-12., 35.] # set cutout range manual, instead of automatic by boundaries of country
# y: [33., 72] # manual set cutout range


projection:
climate_scenario: ssp245
base_year: 2020
future_year: 2050
years_window: 5 # a half of width currently
gcm_selection: false # false to use all the available global climate models
cmip6_nn_fl: data/cmip6/tnn_CMIP6_ssp245_mon_201501-210012.nc # false or names of min-extremal files of climate inputs
cmip6_xx_fl: data/cmip6/txx_CMIP6_ssp245_mon_201501-210012.nc # false or names of max-extremal files of climate inputs


renewable:
onwind:
cutout: cutout-2013-era5-tutorial
Expand Down
Loading
Loading