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

Fix/storm fixed global #179

Merged
merged 5 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://data.4tu.nl/ndownloader/files/35110321
https://data.4tu.nl/file/504c838e-2bd8-4d61-85a1-d495bdc560c3/2a3759e8-f4ad-4190-abb3-434ad5c4679b
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://data.4tu.nl/ndownloader/files/35110318
https://data.4tu.nl/file/504c838e-2bd8-4d61-85a1-d495bdc560c3/c460a0c8-f918-4ede-a734-75e77e99b102
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://data.4tu.nl/ndownloader/files/35110312
https://data.4tu.nl/file/504c838e-2bd8-4d61-85a1-d495bdc560c3/304d1441-bd71-47c7-8231-b20253c1cc2a
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://data.4tu.nl/ndownloader/files/35110309
https://data.4tu.nl/file/504c838e-2bd8-4d61-85a1-d495bdc560c3/856f9530-56d7-489e-8005-18ae36db4804
2 changes: 1 addition & 1 deletion config/hazard_resource_locations/storm_fixed_constant.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://data.4tu.nl/ndownloader/files/35423735
https://data.4tu.nl/file/0ea98bdd-5772-4da8-ae97-99735e891aff/0b98c6f5-c7af-45bb-bb6e-dac53e1b8d55
46 changes: 38 additions & 8 deletions workflow/tropical-cyclone/STORM.smk
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,19 @@ rule extract_storm_fixed_future:
STORM_MODEL_UPPER = lambda wildcards: wildcards.STORM_MODEL_FUTURE.upper()
shell:
"""
# first try STORM_MODEL_FUTURE, otherwise fall back to trying the uppercase version
unzip -o {input} STORM_FIXED_RETURN_PERIODS_{wildcards.STORM_MODEL_FUTURE}_{wildcards.STORM_BASIN}_{wildcards.STORM_RP}_YR_RP.tif \
-d {wildcards.OUTPUT_DIR}/input/STORM/fixed/{wildcards.STORM_MODEL_FUTURE}/{wildcards.STORM_BASIN}/ \
|| \
unzip -o {input} STORM_FIXED_RETURN_PERIODS_{params.STORM_MODEL_UPPER}_{wildcards.STORM_BASIN}_{wildcards.STORM_RP}_YR_RP.tif \
-d {wildcards.OUTPUT_DIR}/input/STORM/fixed/{wildcards.STORM_MODEL_FUTURE}/{wildcards.STORM_BASIN}/ \
unpack_dir="{wildcards.OUTPUT_DIR}/input/STORM/fixed/{wildcards.STORM_MODEL_FUTURE}/{wildcards.STORM_BASIN}/"
uppercase_filename="STORM_FIXED_RETURN_PERIODS_{params.STORM_MODEL_UPPER}_{wildcards.STORM_BASIN}_{wildcards.STORM_RP}_YR_RP.tif"
desired_filename="STORM_FIXED_RETURN_PERIODS_{wildcards.STORM_MODEL_FUTURE}_{wildcards.STORM_BASIN}_{wildcards.STORM_RP}_YR_RP.tif"

# try extracting filename with STORM_MODEL_FUTURE, fall back to STORM_MODEL_UPPER
unzip -o {input} $desired_filename -d $unpack_dir || unzip -o {input} $uppercase_filename -d $unpack_dir

# if we unpacked the uppercase version and its different to STORM_MODEL_FUTURE, rename it
pushd $unpack_dir
if [ -f $uppercase_filename ] && [ $uppercase_filename != $desired_filename ]; then
mv $uppercase_filename $desired_filename
fi
popd
"""


Expand All @@ -195,7 +202,7 @@ rule wrap_storm_fixed:
temp("{OUTPUT_DIR}/input/STORM/fixed/{STORM_MODEL}/{STORM_BASIN}/STORM_FIXED_RETURN_PERIODS_{STORM_MODEL}_{STORM_BASIN}_{STORM_RP}_YR_RP.wrapped.tif")
shell:
"""
gdalwarp -te -180 -60 180 60 {input} {output}
gdalwarp -te -179.85 -60.15 180.15 59.95 -co COMPRESS=LZW -co PREDICTOR=2 -co TILED=YES {input} {output}
Copy link
Contributor

@thomas-fred thomas-fred Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason why the changes are 0.15, 0.15, 0.15 and -0.05? I'd naively expect them to be the same in magnitude

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its a little arbitrary in both directions. In the east-west direction, this avoids pulling a column across the antimeridian from WP to EP. In the north-south direction, this should match the maximum extent of the source data, without clipping but avoiding extra no-data rows.

"""


Expand Down Expand Up @@ -223,5 +230,28 @@ rule mosaic_storm_fixed:
-F {input.basin_tif_wp} \
--outfile={output} \
--calc="numpy.max((A,B,C,D,E,F),axis=0)" \
--NoDataValue=0
--NoDataValue=0 \
--creation-option="COMPRESS=LZW" \
--creation-option="PREDICTOR=2" \
--creation-option="TILED=YES"
"""

rule mosaic_storm_fixed_all:
input:
tiffs=expand(
"{{OUTPUT_DIR}}/input/STORM/fixed/{STORM_MODEL}/STORM_FIXED_RETURN_PERIODS_{STORM_MODEL}_{STORM_RP}_YR_RP.tif",
STORM_MODEL=[
"constant",
"CMCC-CM2-VHR4",
"CNRM-CM6-1-HR",
"EC-Earth3P-HR",
"HadGEM3-GC31-HM",
],
STORM_RP=(
list(range(10, 100, 10))
+ list(range(100, 1000, 100))
+ list(range(1000, 10001, 1000))
),
)
output:
touch("{OUTPUT_DIR}/input/STORM/fixed/mosaic.done")
Loading