-
Notifications
You must be signed in to change notification settings - Fork 0
Plot meteograms #74
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
base: main
Are you sure you want to change the base?
Plot meteograms #74
Changes from all commits
53657ca
b8c6440
4759a30
4db180e
db9d4db
7faa37b
82e0a2c
0b29429
bc34ec0
6cb8bc0
9ab55d8
12ed14c
89b3ae8
87596a1
206bc07
4c57ffd
193cb25
a6fcea6
6c5188d
73544e0
aefe77b
b7642cc
69f3dc9
b109eaa
7262e32
77b3893
8fa6c67
98b9ac9
4dd752e
421b478
61b871e
d2be5ca
9df35a6
257c748
ef00ccc
7306694
4b56b35
e50e6b2
bf07cf7
a20ae75
d018591
d6fd3e3
b841d19
dd36d53
e8e0f0c
b7a9ab1
36f36f2
a1e36b7
e24707f
f670d25
d1ed4da
35ac830
bd24df9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why leave away precipitation? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,9 +57,16 @@ rule showcase_all: | |
| / "showcases/{run_id}/{init_time}/{init_time}_{param}_{region}.gif", | ||
| init_time=[t.strftime("%Y%m%d%H%M") for t in REFTIMES], | ||
| run_id=collect_all_candidates(), | ||
| param=["TOT_PREC", "T_2M", "SP_10M"], | ||
| param=["T_2M", "SP_10M"], | ||
| region=["globe", "europe", "switzerland"], | ||
| ), | ||
| expand( | ||
| OUT_ROOT / "showcases/{run_id}/{init_time}/{init_time}_{param}_{sta}.png", | ||
| init_time=[t.strftime("%Y%m%d%H%M") for t in REFTIMES], | ||
| run_id=collect_all_candidates(), | ||
| param=["T_2M", "SP_10M"], | ||
| sta=["GVE", "KLO", "LUG"], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parameters and stations should probably be added to the config.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment still stands. I suggest to make parameters and stations configurable for the meteogram. Could also do this for the other showcase plots (i.e. use the same parameters). |
||
| ), | ||
| expand( | ||
| OUT_ROOT / "data/runs/{run_id}/summary.md", | ||
| run_id=collect_all_candidates(), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,3 +56,14 @@ if "extract_cosmo1e" in config.get("include-optional-rules", []): | |
| --steps {params.steps} \ | ||
| > {log} 2>&1 | ||
| """ | ||
|
|
||
|
|
||
| rule download_obs_from_peakweather: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be more future-proof to download obs from OGD? |
||
| localrule: True | ||
| output: | ||
| peakweather=directory(OUT_ROOT / "data/observations/peakweather"), | ||
| run: | ||
| from peakweather.dataset import PeakWeatherDataset | ||
|
|
||
| # Download the data from Huggingface | ||
| ds = PeakWeatherDataset(root=output.peakweather) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,52 @@ include: "common.smk" | |
| import pandas as pd | ||
|
|
||
|
|
||
| def _use_first_baseline_zarr(wc): | ||
| """Get the first available baseline zarr for the given init time.""" | ||
| for baseline_id in BASELINE_CONFIGS: | ||
| root = BASELINE_CONFIGS[baseline_id].get("root") | ||
| year = wc.init_time[2:4] | ||
| baseline_zarr = f"{root}/FCST{year}.zarr" | ||
| if Path(baseline_zarr).exists(): | ||
| return baseline_zarr | ||
| raise ValueError(f"No baseline zarr found for init time {wc.init_time}") | ||
|
|
||
|
|
||
| rule plot_meteogram: | ||
| input: | ||
| script="workflow/scripts/plot_meteogram.mo.py", | ||
| inference_okfile=rules.execute_inference.output.okfile, | ||
| analysis_zarr=config["analysis"].get("analysis_zarr"), | ||
| baseline_zarr=lambda wc: _use_first_baseline_zarr(wc), | ||
| peakweather_dir=rules.download_obs_from_peakweather.output.peakweather, | ||
| output: | ||
| OUT_ROOT / "showcases/{run_id}/{init_time}/{init_time}_{param}_{sta}.png", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a concious decision to produce meteogram plots per run_id? I can see that this ties in nicely with the showcases, but in this case, I would argue we do the meteograms only for an individual run (without a baseline). Otherwise, we should strive to support an arbitrary number of run_ids and baselines in the same (multi-panel) plot. |
||
| # localrule: True | ||
| resources: | ||
| slurm_partition="postproc", | ||
| cpus_per_task=1, | ||
| runtime="5m", | ||
| params: | ||
| grib_out_dir=lambda wc: ( | ||
| Path(OUT_ROOT) / f"data/runs/{wc.run_id}/{wc.init_time}/grib" | ||
| ).resolve(), | ||
| shell: | ||
| """ | ||
| export ECCODES_DEFINITION_PATH=$(realpath .venv/share/eccodes-cosmo-resources/definitions) | ||
| python {input.script} \ | ||
| --forecast {params.grib_out_dir} --analysis {input.analysis_zarr} \ | ||
| --baseline {input.baseline_zarr} --peakweather {input.peakweather_dir} \ | ||
| --date {wildcards.init_time} --outfn {output[0]} \ | ||
| --param {wildcards.param} --station {wildcards.sta} | ||
| # interactive editing (needs to set localrule: True and use only one core) | ||
| # marimo edit {input.script} -- \ | ||
| # --forecast {params.grib_out_dir} --analysis {input.analysis_zarr} \ | ||
| # --baseline {input.baseline_zarr} --peakweather {input.peakweather_dir} \ | ||
| # --date {wildcards.init_time} --outfn {output[0]} \ | ||
| # --param {wildcards.param} --station {wildcards.sta} | ||
| """ | ||
|
|
||
|
|
||
| rule plot_forecast_frame: | ||
| input: | ||
| script="workflow/scripts/plot_forecast_frame.mo.py", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To what extent is the model output comparable to station observations? (Effective model resolution vs. point-scale observations, elevation difference, ...). Would a later integration with the MEC make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess for most (all) parameters the MEC doesn't do anything more sophisticated than just nearest-neighbour / representative grid point + altitude correction. But true, maybe at least the constant lapse-rate correction would be useful.