From 9f12cfff2640ce12732cc3863ebe1c687956b93e Mon Sep 17 00:00:00 2001 From: Pirmin Kaufmann Date: Fri, 19 Jan 2024 09:05:35 +0100 Subject: [PATCH 1/6] Added ICON model names. --- .../presets/opr/cosmo-1e-ctrl/all_pdf.toml | 2 +- .../presets/opr/cosmo-1e-ctrl/all_png.toml | 2 +- .../presets/opr/cosmo-1e-ctrl/all_shp.toml | 49 +++++++ .../data/presets/opr/cosmo-1e/all_pdf.toml | 2 +- .../data/presets/opr/cosmo-1e/all_png.toml | 2 +- .../data/presets/opr/cosmo-1e/all_shp.toml | 4 +- .../data/presets/opr/cosmo-2e/all_pdf.toml | 2 +- .../data/presets/opr/cosmo-2e/all_png.toml | 4 +- .../data/presets/opr/cosmo-2e/all_shp.toml | 51 +++++++ .../presets/opr/icon-ch1-ctrl/all_pdf.toml | 65 +++++++++ .../presets/opr/icon-ch1-ctrl/all_png.toml | 49 +++++++ .../presets/opr/icon-ch1-ctrl/all_shp.toml | 49 +++++++ .../presets/opr/icon-ch2-eps/all_pdf.toml | 133 ++++++++++++++++++ .../presets/opr/icon-ch2-eps/all_png.toml | 110 +++++++++++++++ .../presets/opr/icon-ch2-eps/all_shp.toml | 51 +++++++ .../data/presets/opr/ifs-hres-eu/all_pdf.toml | 2 +- .../data/presets/opr/ifs-hres-eu/all_png.toml | 2 +- .../data/presets/opr/ifs-hres-eu/all_shp.toml | 49 +++++++ .../data/presets/opr/ifs-hres/all_pdf.toml | 2 +- .../data/presets/opr/ifs-hres/all_png.toml | 2 +- .../data/presets/opr/ifs-hres/all_shp.toml | 12 +- src/pyflexplot/input/read_fields.py | 4 + src/pyflexplot/plots.py | 10 +- 23 files changed, 634 insertions(+), 24 deletions(-) create mode 100644 src/pyflexplot/data/presets/opr/cosmo-1e-ctrl/all_shp.toml create mode 100644 src/pyflexplot/data/presets/opr/cosmo-2e/all_shp.toml create mode 100644 src/pyflexplot/data/presets/opr/icon-ch1-ctrl/all_pdf.toml create mode 100644 src/pyflexplot/data/presets/opr/icon-ch1-ctrl/all_png.toml create mode 100644 src/pyflexplot/data/presets/opr/icon-ch1-ctrl/all_shp.toml create mode 100644 src/pyflexplot/data/presets/opr/icon-ch2-eps/all_pdf.toml create mode 100644 src/pyflexplot/data/presets/opr/icon-ch2-eps/all_png.toml create mode 100644 src/pyflexplot/data/presets/opr/icon-ch2-eps/all_shp.toml create mode 100644 src/pyflexplot/data/presets/opr/ifs-hres-eu/all_shp.toml diff --git a/src/pyflexplot/data/presets/opr/cosmo-1e-ctrl/all_pdf.toml b/src/pyflexplot/data/presets/opr/cosmo-1e-ctrl/all_pdf.toml index be3feff7..464ee4d3 100644 --- a/src/pyflexplot/data/presets/opr/cosmo-1e-ctrl/all_pdf.toml +++ b/src/pyflexplot/data/presets/opr/cosmo-1e-ctrl/all_pdf.toml @@ -1,7 +1,7 @@ # PyFlexPlot setup file to create deterministic COSMO-1E-CTRL plots [_base] -# Data source: tsa:/scratch/ruestefa/shared/test/pyflexplot/ +# Test data source: /store/mch/msopr/pyflexplot_testdata/ infile = "data/cosmo-1e-ctrl/grid_conc_0910_20200216000000.nc" model = "COSMO-1E" lang = "de" diff --git a/src/pyflexplot/data/presets/opr/cosmo-1e-ctrl/all_png.toml b/src/pyflexplot/data/presets/opr/cosmo-1e-ctrl/all_png.toml index 9009ef95..4c18dc3a 100644 --- a/src/pyflexplot/data/presets/opr/cosmo-1e-ctrl/all_png.toml +++ b/src/pyflexplot/data/presets/opr/cosmo-1e-ctrl/all_png.toml @@ -1,7 +1,7 @@ # PyFlexPlot setup file to create deterministic COSMO-1E-CTRL plots [_base] -# Data source: tsa:/scratch/ruestefa/shared/test/pyflexplot/ +# Test data source: /store/mch/msopr/pyflexplot_testdata/ infile = "data/cosmo-1e-ctrl/grid_conc_0910_20200216000000.nc" model = "COSMO-1E" lang = "de" diff --git a/src/pyflexplot/data/presets/opr/cosmo-1e-ctrl/all_shp.toml b/src/pyflexplot/data/presets/opr/cosmo-1e-ctrl/all_shp.toml new file mode 100644 index 00000000..be8d7931 --- /dev/null +++ b/src/pyflexplot/data/presets/opr/cosmo-1e-ctrl/all_shp.toml @@ -0,0 +1,49 @@ +# PyFlexPlot setup file to create deterministic COSMO-1E-CTRL shapefiles + +[_base] +# Test data source: /store/mch/msopr/pyflexplot_testdata/ +infile = "data/cosmo-1e-ctrl/grid_conc_0910_20200216000000.nc" +model = "COSMO-1E" +lang = "de" +outfile_time_format = "%Y%m%dT%H%M" +combine_species = false + +[_base._concentration] +plot_variable = "concentration" +level = 0 + +[_base._concentration._integr] +integrate = true +time = -1 + +[_base._tot_deposition] +plot_variable = "tot_deposition" +integrate = true + +[_base._affected_area] +plot_variable = "affected_area" +integrate = true +level = 0 +time = -1 +combine_species = true + +[_base._concentration."_shp+"] +outfile = "concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +[_base._concentration._integr."_shp+"] +outfile = "integrated_concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +[_base._tot_deposition."_shp+"] +outfile = "deposition_tot_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +[_base._affected_area."_shp+"] +outfile = "affected_area_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" + +[_base._concentration."_multipanel_time+"] +outfile = "concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +plot_type = "multipanel" +multipanel_param = "time" +time = [2, 4, 8, -1] + +["**".full] +domain = "full" + +["**".zoom] +domain = "ch" diff --git a/src/pyflexplot/data/presets/opr/cosmo-1e/all_pdf.toml b/src/pyflexplot/data/presets/opr/cosmo-1e/all_pdf.toml index 3d2ee8d4..5f5c198a 100644 --- a/src/pyflexplot/data/presets/opr/cosmo-1e/all_pdf.toml +++ b/src/pyflexplot/data/presets/opr/cosmo-1e/all_pdf.toml @@ -1,7 +1,7 @@ # PyFlexPlot setup file to create ensemble CCOSMO-1E plots [_base] -# Data source: tsa:/scratch/ruestefa/shared/test/pyflexplot/ +# Test data source: /store/mch/msopr/pyflexplot_testdata/ infile = "data/cosmo-1e/2021030503/{ens_member:03}/grid_conc_20210305030000.nc_GOE" ens_member_id = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] model = "COSMO-1E" diff --git a/src/pyflexplot/data/presets/opr/cosmo-1e/all_png.toml b/src/pyflexplot/data/presets/opr/cosmo-1e/all_png.toml index fba13070..bce50e82 100644 --- a/src/pyflexplot/data/presets/opr/cosmo-1e/all_png.toml +++ b/src/pyflexplot/data/presets/opr/cosmo-1e/all_png.toml @@ -1,7 +1,7 @@ # PyFlexPlot setup file to create ensemble CCOSMO-1E plots [_base] -# Data source: tsa:/scratch/ruestefa/shared/test/pyflexplot/ +# Test data source: /store/mch/msopr/pyflexplot_testdata/ infile = "data/cosmo-1e/2021030503/{ens_member:03}/grid_conc_20210305030000.nc_GOE" ens_member_id = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] model = "COSMO-1E" diff --git a/src/pyflexplot/data/presets/opr/cosmo-1e/all_shp.toml b/src/pyflexplot/data/presets/opr/cosmo-1e/all_shp.toml index 68ca1474..5c2d7a5c 100644 --- a/src/pyflexplot/data/presets/opr/cosmo-1e/all_shp.toml +++ b/src/pyflexplot/data/presets/opr/cosmo-1e/all_shp.toml @@ -1,7 +1,7 @@ -# PyFlexPlot setup file to create ensemble CCOSMO-1E plots +# PyFlexPlot setup file to create ensemble COSMO-1E shapefiles [_base] -# Data source: tsa:/scratch/ruestefa/shared/test/pyflexplot/ +# Test data source: /store/mch/msopr/pyflexplot_testdata/ infile = "data/cosmo-1e/2021030503/{ens_member:03}/grid_conc_20210305030000.nc_GOE" ens_member_id = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] model = "COSMO-1E" diff --git a/src/pyflexplot/data/presets/opr/cosmo-2e/all_pdf.toml b/src/pyflexplot/data/presets/opr/cosmo-2e/all_pdf.toml index 3995094a..057bbf87 100644 --- a/src/pyflexplot/data/presets/opr/cosmo-2e/all_pdf.toml +++ b/src/pyflexplot/data/presets/opr/cosmo-2e/all_pdf.toml @@ -1,7 +1,7 @@ # PyFlexPlot setup file to create ensemble COSMO-2E plots [_base] -# Data source: tsa:/scratch/ruestefa/shared/test/pyflexplot/ +# Test data source: /store/mch/msopr/pyflexplot_testdata/ infile = "data/cosmo-2e/2021030503/{ens_member:03}/grid_conc_20210305030000.nc_BUG" ens_member_id = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] model = "COSMO-2E" diff --git a/src/pyflexplot/data/presets/opr/cosmo-2e/all_png.toml b/src/pyflexplot/data/presets/opr/cosmo-2e/all_png.toml index 67cbf5a1..291bf9d9 100644 --- a/src/pyflexplot/data/presets/opr/cosmo-2e/all_png.toml +++ b/src/pyflexplot/data/presets/opr/cosmo-2e/all_png.toml @@ -1,7 +1,7 @@ -# PyFlexPlot setup file to create ensemble CCOSMO-2E plots +# PyFlexPlot setup file to create ensemble COSMO-2E plots [_base] -# Data source: tsa:/scratch/ruestefa/shared/test/pyflexplot/ +# Test data source: /store/mch/msopr/pyflexplot_testdata/ infile = "data/cosmo-2e/2021030503/{ens_member:03}/grid_conc_20210305030000.nc_BUG" ens_member_id = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] model = "COSMO-2E" diff --git a/src/pyflexplot/data/presets/opr/cosmo-2e/all_shp.toml b/src/pyflexplot/data/presets/opr/cosmo-2e/all_shp.toml new file mode 100644 index 00000000..9534a953 --- /dev/null +++ b/src/pyflexplot/data/presets/opr/cosmo-2e/all_shp.toml @@ -0,0 +1,51 @@ +# PyFlexPlot setup file to create ensemble COSMO-2E shapefiles + +[_base] +# Test data source: /store/mch/msopr/pyflexplot_testdata/ +infile = "data/cosmo-2e/2021030503/{ens_member:03}/grid_conc_20210305030000.nc_GOE" +ens_member_id = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] +model = "COSMO-2E" +lang = "de" +outfile_time_format = "%Y%m%dT%H%M" +combine_species = true + +[_base._concentration] +plot_variable = "concentration" +level = 0 +integrate = false +time = "*" + +[_base._concentration._integr] +integrate = true +time = -1 + +[_base._tot_deposition] +plot_variable = "tot_deposition" +integrate = true +time = -1 + +[_base._affected_area] +plot_variable = "affected_area" +integrate = true +level = 0 +time = -1 + +[_base._concentration."_probability+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_probability_{domain}.shp" +ens_variable = "probability" +ens_param_thr = 0 +[_base._concentration._integr."_probability+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_probability_{domain}.shp" +ens_variable = "probability" +ens_param_thr = 0 +[_base._tot_deposition."_probability+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_probability_{domain}.shp" +ens_variable = "probability" +ens_param_thr = 0 +[_base._affected_area."_probability+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_probability_{domain}.shp" +ens_variable = "probability" +ens_param_thr = 0 + +["**".ch] +domain = "ch" diff --git a/src/pyflexplot/data/presets/opr/icon-ch1-ctrl/all_pdf.toml b/src/pyflexplot/data/presets/opr/icon-ch1-ctrl/all_pdf.toml new file mode 100644 index 00000000..d39a3a78 --- /dev/null +++ b/src/pyflexplot/data/presets/opr/icon-ch1-ctrl/all_pdf.toml @@ -0,0 +1,65 @@ +# PyFlexPlot setup file to create deterministic ICON-CH1-CTRL plots + +[_base] +# Test data source: /store_new/mch/msopr/pyflexplot_testdata/ +infile = "data/icon-ch1-ctrl/grid_conc_0910_20200216000000.nc" +model = "ICON-CH1-CTRL" +lang = "de" +outfile_time_format = "%Y%m%dT%H%M" +combine_species = false + +[_base._concentration] +plot_variable = "concentration" +level = 0 + +[_base._concentration._integr] +integrate = true +time = -1 + +[_base._tot_deposition] +plot_variable = "tot_deposition" +integrate = true + +[_base._affected_area] +plot_variable = "affected_area" +integrate = true +level = 0 +time = -1 +combine_species = true + +[_base._concentration._multipanel_time] +plot_type = "multipanel" +multipanel_param = "time" +time = [2, 4, 8, -1] + +[_base._concentration.full] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_Dispersion_Konzentration.pdf" +domain = "full" +[_base._concentration._integr.full] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_Dispersion_integrierte_Luftaktivitaet.pdf" +domain = "full" +[_base._tot_deposition.full] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_Dispersion_Deposition.pdf" +domain = "full" +[_base._affected_area.full] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_Dispersion_beaufschl_Gebiet.pdf" +domain = "full" +[_base._concentration._multipanel_time.full] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_Dispersion_Konzentration.pdf" +domain = "full" + +[_base._concentration.zoom] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_Dispersion_Konzentration_zoom.pdf" +domain = "ch" +[_base._concentration._integr.zoom] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_Dispersion_integrierte_Luftaktivitaet_zoom.pdf" +domain = "ch" +[_base._tot_deposition.zoom] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_Dispersion_Deposition_zoom.pdf" +domain = "ch" +[_base._affected_area.zoom] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_Dispersion_beaufschl_Gebiet_zoom.pdf" +domain = "ch" +[_base._concentration._multipanel_time.zoom] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_Dispersion_Konzentration_zoom.pdf" +domain = "ch" diff --git a/src/pyflexplot/data/presets/opr/icon-ch1-ctrl/all_png.toml b/src/pyflexplot/data/presets/opr/icon-ch1-ctrl/all_png.toml new file mode 100644 index 00000000..2fc980aa --- /dev/null +++ b/src/pyflexplot/data/presets/opr/icon-ch1-ctrl/all_png.toml @@ -0,0 +1,49 @@ +# PyFlexPlot setup file to create deterministic ICON-CH1-CTRL plots + +[_base] +# Test data source: /store_new/mch/msopr/pyflexplot_testdata/ +infile = "data/icon-ch1-ctrl/grid_conc_0910_20200216000000.nc" +model = "ICON-CH1-CTRL" +lang = "de" +outfile_time_format = "%Y%m%dT%H%M" +combine_species = false + +[_base._concentration] +plot_variable = "concentration" +level = 0 + +[_base._concentration._integr] +integrate = true +time = -1 + +[_base._tot_deposition] +plot_variable = "tot_deposition" +integrate = true + +[_base._affected_area] +plot_variable = "affected_area" +integrate = true +level = 0 +time = -1 +combine_species = true + +[_base._concentration."_png+"] +outfile = "concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.png" +[_base._concentration._integr."_png+"] +outfile = "integrated_concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.png" +[_base._tot_deposition."_png+"] +outfile = "deposition_tot_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.png" +[_base._affected_area."_png+"] +outfile = "affected_area_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.png" + +[_base._concentration."_multipanel_time+"] +outfile = "concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.png" +plot_type = "multipanel" +multipanel_param = "time" +time = [2, 4, 8, -1] + +["**".full] +domain = "full" + +["**".zoom] +domain = "ch" diff --git a/src/pyflexplot/data/presets/opr/icon-ch1-ctrl/all_shp.toml b/src/pyflexplot/data/presets/opr/icon-ch1-ctrl/all_shp.toml new file mode 100644 index 00000000..f152bee0 --- /dev/null +++ b/src/pyflexplot/data/presets/opr/icon-ch1-ctrl/all_shp.toml @@ -0,0 +1,49 @@ +# PyFlexPlot setup file to create deterministic ICON-CH1-CTRL shapefiles + +[_base] +# Test data source: /store_new/mch/msopr/pyflexplot_testdata/ +infile = "data/icon-ch1-ctrl/grid_conc_0910_20200216000000.nc" +model = "ICON-CH1-CTRL" +lang = "de" +outfile_time_format = "%Y%m%dT%H%M" +combine_species = false + +[_base._concentration] +plot_variable = "concentration" +level = 0 + +[_base._concentration._integr] +integrate = true +time = -1 + +[_base._tot_deposition] +plot_variable = "tot_deposition" +integrate = true + +[_base._affected_area] +plot_variable = "affected_area" +integrate = true +level = 0 +time = -1 +combine_species = true + +[_base._concentration."_shp+"] +outfile = "concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +[_base._concentration._integr."_shp+"] +outfile = "integrated_concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +[_base._tot_deposition."_shp+"] +outfile = "deposition_tot_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +[_base._affected_area."_shp+"] +outfile = "affected_area_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" + +[_base._concentration."_multipanel_time+"] +outfile = "concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +plot_type = "multipanel" +multipanel_param = "time" +time = [2, 4, 8, -1] + +["**".full] +domain = "full" + +["**".zoom] +domain = "ch" diff --git a/src/pyflexplot/data/presets/opr/icon-ch2-eps/all_pdf.toml b/src/pyflexplot/data/presets/opr/icon-ch2-eps/all_pdf.toml new file mode 100644 index 00000000..1a296a3f --- /dev/null +++ b/src/pyflexplot/data/presets/opr/icon-ch2-eps/all_pdf.toml @@ -0,0 +1,133 @@ +# PyFlexPlot setup file to create ensemble ICON-CH2-EPS plots + +[_base] +# Test data source: /store_new/mch/msopr/pyflexplot_testdata/ +infile = "data/icon-ch2-eps/2021030503/{ens_member:03}/grid_conc_20210305030000.nc_BUG" +ens_member_id = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] +model = "ICON-CH2-EPS" +lang = "de" +outfile_time_format = "%Y%m%dT%H%M" +combine_species = true + +[_base._concentration] +plot_variable = "concentration" +level = 0 +integrate = false +time = "*" + +[_base._concentration._integr] +integrate = true +time = -1 + +[_base._tot_deposition] +plot_variable = "tot_deposition" +integrate = true +time = -1 + +[_base._affected_area] +plot_variable = "affected_area" +integrate = true +level = 0 +time = -1 + +[_base._concentration."_probability+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_probability_{domain}.pdf" +ens_variable = "probability" +ens_param_thr = 0 +[_base._concentration._integr."_probability+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_probability_{domain}.pdf" +ens_variable = "probability" +ens_param_thr = 0 +[_base._tot_deposition."_probability+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_probability_{domain}.pdf" +ens_variable = "probability" +ens_param_thr = 0 +[_base._affected_area."_probability+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_probability_{domain}.pdf" +ens_variable = "probability" +ens_param_thr = 0 + +[_base._concentration."_probability+"."_multipanel_time+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_probability_{domain}.pdf" +plot_type = "multipanel" +multipanel_param = "time" +time = [2, 4, 8, -1] + +[_base._concentration._integr."_pctl95+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_percentile_{domain}.pdf" +ens_variable = "percentile" +ens_param_pctl = 95 +[_base._tot_deposition."_pctl95+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_percentile_{domain}.pdf" +ens_variable = "percentile" +ens_param_pctl = 95 +[_base._affected_area."_pctl95+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_percentile_{domain}.pdf" +ens_variable = "percentile" +ens_param_pctl = 95 + +[_base._concentration._integr."_multipanel_pctl+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_percentile_{domain}.pdf" +plot_type = "multipanel" +multipanel_param = "ens_param_pctl" +ens_variable = "percentile" +ens_param_pctl = [5, 50, 75, 95] + +[_base._tot_deposition."_multipanel_pctl+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_percentile_{domain}.pdf" +plot_type = "multipanel" +multipanel_param = "ens_param_pctl" +ens_variable = "percentile" +ens_param_pctl = [5, 50, 75, 95] + +[_base._concentration._cloud] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_cloud_timing_{domain}.pdf" +ens_param_mem_min = 2 +ens_param_thr = 0.0 +time = 0 +[_base._concentration._cloud."_arrival+"] +ens_variable = "cloud_arrival_time" +[_base._concentration._cloud."_departure+"] +ens_variable = "cloud_departure_time" + +[_base._concentration._integr."_min+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_cloud_statistics_{domain}.pdf" +ens_variable = "minimum" +[_base._tot_deposition."_min+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_cloud_statistics_{domain}.pdf" +ens_variable = "minimum" +[_base._affected_area."_min+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_cloud_statistics_{domain}.pdf" +ens_variable = "minimum" +[_base._concentration._integr."_max+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_cloud_statistics_{domain}.pdf" +ens_variable = "maximum" +[_base._tot_deposition."_max+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_cloud_statistics_{domain}.pdf" +ens_variable = "maximum" +[_base._affected_area."_max+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_cloud_statistics_{domain}.pdf" +ens_variable = "maximum" +[_base._concentration._integr."_mean+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_cloud_statistics_{domain}.pdf" +ens_variable = "mean" +[_base._tot_deposition."_mean+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_cloud_statistics_{domain}.pdf" +ens_variable = "mean" +# [_base._affected_area."_mean+"] +# outfile = "{release_start}_{release_site}_FLEXPART-{model}_cloud_statistics_{domain}.pdf" +# ens_variable = "mean" +[_base._concentration._integr."_median+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_cloud_statistics_{domain}.pdf" +ens_variable = "median" +[_base._tot_deposition."_median+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_cloud_statistics_{domain}.pdf" +ens_variable = "median" +[_base._affected_area."_median+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_cloud_statistics_{domain}.pdf" +ens_variable = "median" + +["**".full] +domain = "full" +["**".ch] +domain = "ch" diff --git a/src/pyflexplot/data/presets/opr/icon-ch2-eps/all_png.toml b/src/pyflexplot/data/presets/opr/icon-ch2-eps/all_png.toml new file mode 100644 index 00000000..04ca29ff --- /dev/null +++ b/src/pyflexplot/data/presets/opr/icon-ch2-eps/all_png.toml @@ -0,0 +1,110 @@ +# PyFlexPlot setup file to create ensemble ICON-CH2-EPS plots + +[_base] +infile = "data/icon-ch2-eps/2021030503/{ens_member:03}/grid_conc_20210305030000.nc_BUG" +ens_member_id = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] +model = "ICON-CH2-EPS" +lang = "de" +outfile_time_format = "%Y%m%dT%H%M" +combine_species = true +outfile = "ensemble_{ens_variable}_{plot_variable}_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.png" + +[_base._concentration] +plot_variable = "concentration" +level = 0 +integrate = false +time = "*" + +[_base._concentration._integr] +integrate = true +time = -1 + +[_base._tot_deposition] +plot_variable = "tot_deposition" +integrate = true +time = -1 + +[_base._affected_area] +plot_variable = "affected_area" +integrate = true +level = 0 +time = -1 + +[_base._concentration."_probability+"] +ens_variable = "probability" +ens_param_thr = 0 +[_base._concentration._integr."_probability+"] +ens_variable = "probability" +ens_param_thr = 0 +[_base._tot_deposition."_probability+"] +ens_variable = "probability" +ens_param_thr = 0 +[_base._affected_area."_probability+"] +ens_variable = "probability" +ens_param_thr = 0 + +[_base._concentration."_probability+"."_multipanel_time+"] +plot_type = "multipanel" +multipanel_param = "time" +time = [2, 4, 8, -1] + +[_base._concentration._integr."_pctl95+"] +ens_variable = "percentile" +ens_param_pctl = 95 +[_base._tot_deposition."_pctl95+"] +ens_variable = "percentile" +ens_param_pctl = 95 +[_base._affected_area."_pctl95+"] +ens_variable = "percentile" +ens_param_pctl = 95 + +[_base._tot_deposition."_multipanel_pctl+"] +plot_type = "multipanel" +multipanel_param = "ens_param_pctl" +ens_variable = "percentile" +ens_param_pctl = [5, 50, 75, 95] + +[_base._concentration._integr."_multipanel_pctl+"] +plot_type = "multipanel" +multipanel_param = "ens_param_pctl" +ens_variable = "percentile" +ens_param_pctl = [5, 50, 75, 95] + +[_base._concentration._cloud] +ens_param_mem_min = 2 +ens_param_thr = 0.0 +time = 0 +[_base._concentration._cloud."_arrival+"] +ens_variable = "cloud_arrival_time" +[_base._concentration._cloud."_departure+"] +ens_variable = "cloud_departure_time" + +[_base._concentration._integr."_min+"] +ens_variable = "minimum" +[_base._tot_deposition."_min+"] +ens_variable = "minimum" +[_base._affected_area."_min+"] +ens_variable = "minimum" +[_base._concentration._integr."_max+"] +ens_variable = "maximum" +[_base._tot_deposition."_max+"] +ens_variable = "maximum" +[_base._affected_area."_max+"] +ens_variable = "maximum" +[_base._concentration._integr."_mean+"] +ens_variable = "mean" +[_base._tot_deposition."_mean+"] +ens_variable = "mean" +# [_base._affected_area."_mean+"] +# ens_variable = "mean" +[_base._concentration._integr."_median+"] +ens_variable = "median" +[_base._tot_deposition."_median+"] +ens_variable = "median" +[_base._affected_area."_median+"] +ens_variable = "median" + +["**".full] +domain = "full" +["**".ch] +domain = "ch" diff --git a/src/pyflexplot/data/presets/opr/icon-ch2-eps/all_shp.toml b/src/pyflexplot/data/presets/opr/icon-ch2-eps/all_shp.toml new file mode 100644 index 00000000..71c309dc --- /dev/null +++ b/src/pyflexplot/data/presets/opr/icon-ch2-eps/all_shp.toml @@ -0,0 +1,51 @@ +# PyFlexPlot setup file to create ensemble ICON-CH2-EPS shapefiles + +[_base] +# Test data source: /store_new/mch/msopr/pyflexplot_testdata/ +infile = "data/icon-ch2-eps/2021030503/{ens_member:03}/grid_conc_20210305030000.nc_GOE" +ens_member_id = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] +model = "ICON-CH2-EPS" +lang = "de" +outfile_time_format = "%Y%m%dT%H%M" +combine_species = true + +[_base._concentration] +plot_variable = "concentration" +level = 0 +integrate = false +time = "*" + +[_base._concentration._integr] +integrate = true +time = -1 + +[_base._tot_deposition] +plot_variable = "tot_deposition" +integrate = true +time = -1 + +[_base._affected_area] +plot_variable = "affected_area" +integrate = true +level = 0 +time = -1 + +[_base._concentration."_probability+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_probability_{domain}.shp" +ens_variable = "probability" +ens_param_thr = 0 +[_base._concentration._integr."_probability+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_probability_{domain}.shp" +ens_variable = "probability" +ens_param_thr = 0 +[_base._tot_deposition."_probability+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_probability_{domain}.shp" +ens_variable = "probability" +ens_param_thr = 0 +[_base._affected_area."_probability+"] +outfile = "{release_start}_{release_site}_FLEXPART-{model}_probability_{domain}.shp" +ens_variable = "probability" +ens_param_thr = 0 + +["**".ch] +domain = "ch" diff --git a/src/pyflexplot/data/presets/opr/ifs-hres-eu/all_pdf.toml b/src/pyflexplot/data/presets/opr/ifs-hres-eu/all_pdf.toml index 5d058002..99604a77 100644 --- a/src/pyflexplot/data/presets/opr/ifs-hres-eu/all_pdf.toml +++ b/src/pyflexplot/data/presets/opr/ifs-hres-eu/all_pdf.toml @@ -1,7 +1,7 @@ # PyFlexPlot setup file to create deterministic IFS-HRES-EU plots [_base] -# Data source: tsa:/scratch/ruestefa/shared/test/pyflexplot/ +# Test data source: /store_new/mch/msopr/pyflexplot_testdata/ infile = "data/ifs-hres-eu/grid_conc_0999_20200818000000_fessenheim_5spec.nc" model = "IFS-HRES-EU" lang = "de" diff --git a/src/pyflexplot/data/presets/opr/ifs-hres-eu/all_png.toml b/src/pyflexplot/data/presets/opr/ifs-hres-eu/all_png.toml index d7c27805..a83fc848 100644 --- a/src/pyflexplot/data/presets/opr/ifs-hres-eu/all_png.toml +++ b/src/pyflexplot/data/presets/opr/ifs-hres-eu/all_png.toml @@ -1,7 +1,7 @@ # PyFlexPlot setup file to create deterministic IFS-HRES-EU plots [_base] -# Data source: tsa:/scratch/ruestefa/shared/test/pyflexplot/ +# Test data source: /store_new/mch/msopr/pyflexplot_testdata/ infile = "data/ifs-hres-eu/grid_conc_0999_20200818000000_fessenheim_5spec.nc" model = "IFS-HRES-EU" lang = "de" diff --git a/src/pyflexplot/data/presets/opr/ifs-hres-eu/all_shp.toml b/src/pyflexplot/data/presets/opr/ifs-hres-eu/all_shp.toml new file mode 100644 index 00000000..297ceea0 --- /dev/null +++ b/src/pyflexplot/data/presets/opr/ifs-hres-eu/all_shp.toml @@ -0,0 +1,49 @@ +# PyFlexPlot setup file to create deterministic IFS-HRES-EU shapefiles + +[_base] +# Test data source: /store_new/mch/msopr/pyflexplot_testdata/ +infile = "data/ifs-hres-eu/grid_conc_0999_20200818000000_fessenheim_5spec.nc" +model = "IFS-HRES-EU" +lang = "de" +outfile_time_format = "%Y%m%dT%H%M" +combine_species = false + +[_base._concentration] +plot_variable = "concentration" +level = 0 + +[_base._concentration._integr] +integrate = true +time = -1 + +[_base._tot_deposition] +plot_variable = "tot_deposition" +integrate = true + +[_base._affected_area] +plot_variable = "affected_area" +integrate = true +level = 0 +time = -1 +combine_species = true + +[_base._concentration."_shp+"] +outfile = "concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +[_base._concentration._integr."_shp+"] +outfile = "integrated_concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +[_base._tot_deposition."_shp+"] +outfile = "deposition_tot_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +[_base._affected_area."_shp+"] +outfile = "affected_area_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" + +[_base._concentration."_multipanel_time+"] +outfile = "concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +plot_type = "multipanel" +multipanel_param = "time" +time = [2, 4, 8, -1] + +["**".full] +domain = "full" + +["**".zoom] +domain = "alps" diff --git a/src/pyflexplot/data/presets/opr/ifs-hres/all_pdf.toml b/src/pyflexplot/data/presets/opr/ifs-hres/all_pdf.toml index 64fe302d..3a9fa943 100644 --- a/src/pyflexplot/data/presets/opr/ifs-hres/all_pdf.toml +++ b/src/pyflexplot/data/presets/opr/ifs-hres/all_pdf.toml @@ -1,7 +1,7 @@ # PyFlexPlot setup file to create deterministic IFS-HRES-EU plots [_base] -# Data source: tsa:/scratch/ruestefa/shared/test/pyflexplot/ +# Test data source: /store_new/mch/msopr/pyflexplot_testdata/ infile = "data/ifs-hres/grid_conc_1000_20200818000000_bushehr_2spec.nc" model = "IFS-HRES" lang = "de" diff --git a/src/pyflexplot/data/presets/opr/ifs-hres/all_png.toml b/src/pyflexplot/data/presets/opr/ifs-hres/all_png.toml index ed4faef8..af1ef996 100644 --- a/src/pyflexplot/data/presets/opr/ifs-hres/all_png.toml +++ b/src/pyflexplot/data/presets/opr/ifs-hres/all_png.toml @@ -1,7 +1,7 @@ # PyFlexPlot setup file to create deterministic IFS-HRES-EU plots [_base] -# Data source: tsa:/scratch/ruestefa/shared/test/pyflexplot/ +# Test data source: /store_new/mch/msopr/pyflexplot_testdata/ infile = "data/ifs-hres/grid_conc_1000_20200818000000_bushehr_2spec.nc" model = "IFS-HRES" lang = "de" diff --git a/src/pyflexplot/data/presets/opr/ifs-hres/all_shp.toml b/src/pyflexplot/data/presets/opr/ifs-hres/all_shp.toml index ea57fc54..59446fc5 100644 --- a/src/pyflexplot/data/presets/opr/ifs-hres/all_shp.toml +++ b/src/pyflexplot/data/presets/opr/ifs-hres/all_shp.toml @@ -1,7 +1,7 @@ -# PyFlexPlot setup file to create deterministic IFS-HRES-EU plots +# PyFlexPlot setup file to create deterministic IFS-HRES shapefiles [_base] -# Data source: tsa:/scratch/ruestefa/shared/test/pyflexplot/ +# Test data source: /store_new/mch/msopr/pyflexplot_testdata/ infile = "data/ifs-hres/grid_conc_1000_20200818000000_bushehr_2spec.nc" model = "IFS-HRES" lang = "de" @@ -27,13 +27,13 @@ level = 0 time = -1 combine_species = true -[_base._concentration."_png+"] +[_base._concentration."_shp+"] outfile = "concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" -[_base._concentration._integr."_png+"] +[_base._concentration._integr."_shp+"] outfile = "integrated_concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" -[_base._tot_deposition."_png+"] +[_base._tot_deposition."_shp+"] outfile = "deposition_tot_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" -[_base._affected_area."_png+"] +[_base._affected_area."_shp+"] outfile = "affected_area_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" [_base._concentration."_multipanel_time+"] diff --git a/src/pyflexplot/input/read_fields.py b/src/pyflexplot/input/read_fields.py index bfbc5f53..132c540a 100644 --- a/src/pyflexplot/input/read_fields.py +++ b/src/pyflexplot/input/read_fields.py @@ -677,6 +677,10 @@ def _renamed_dims(self) -> Dict[str, str]: "COSMO-E", "COSMO-2E", "COSMO-1E", + "ICON-CH1-CTRL", + "ICON-CH2-CTRL", + "ICON-CH1-EPS", + "ICON-CH2-EPS", ]: return { "lat": "rlat", diff --git a/src/pyflexplot/plots.py b/src/pyflexplot/plots.py index bd0ae6d7..370baa8b 100644 --- a/src/pyflexplot/plots.py +++ b/src/pyflexplot/plots.py @@ -230,9 +230,9 @@ def get_domain(field: Field, aspect: float) -> Domain: mask_nz = field.time_props.mask_nz domain: Optional[Domain] = None if domain_type == "full": - if model_name in ["COSMO-1", "COSMO-1E", "COSMO-2", "COSMO-E"]: + if model_name in ["COSMO-1", "COSMO-1E", "COSMO-2", "COSMO-E", "ICON-CH1-CTRL", "ICON-CH2-CTRL"]: domain = Domain(lat, lon, config={"zoom_fact": 1.01}) - elif model_name in ["COSMO-2E"]: + elif model_name in ["COSMO-2E", "ICON-CH1-EPS", "ICON-CH2-EPS"]: domain = Domain(lat, lon, config={"zoom_fact": 1.025}) else: domain = Domain(lat, lon) @@ -270,7 +270,7 @@ def get_domain(field: Field, aspect: float) -> Domain: }, ) elif domain_type == "ch": - if model_name in ["COSMO-1", "COSMO-1E", "COSMO-2E"]: + if model_name in ["COSMO-1", "COSMO-1E", "COSMO-2E", "ICON-CH1-CTRL", "ICON-CH2-CTRL", "ICON-CH1-EPS", "ICON-CH2-EPS"]: domain = Domain( lat, lon, config={"zoom_fact": 3.6, "rel_offset": (-0.02, 0.045)} ) @@ -688,7 +688,7 @@ def create_map_config( }, } if domain_type == "full": - if model_name.startswith("COSMO"): + if model_name.startswith("COSMO") or model_name.startswith("ICON"): config_dct.update(conf_regional_scale) elif model_name == "IFS-HRES-EU": config_dct.update(conf_continental_scale) @@ -1554,7 +1554,7 @@ def format_model_info(model_setup: ModelSetup, words: TranslatedWords) -> str: # SR_TMP > model_info = None if simulation_type == "deterministic": - if model_name in ["COSMO-1", "COSMO-2", "IFS-HRES", "IFS-HRES-EU"]: + if model_name in ["COSMO-1", "COSMO-2", "ICON-CH1-CTRL", "ICON-CH2-CTRL", "ICON-CH1-EPS", "ICON-CH2-EPS", "IFS-HRES", "IFS-HRES-EU"]: model_info = model_name elif model_name in ["COSMO-E", "COSMO-1E", "COSMO-2E"]: model_info = f"{model_name} {words['control_run']}" From d14758b246d9f19120ae3554834e3c4889fc931c Mon Sep 17 00:00:00 2001 From: Pirmin Kaufmann Date: Mon, 22 Jan 2024 16:32:57 +0100 Subject: [PATCH 2/6] Fix bug for FLEXPART-ICON output plotting, increase patch level --- VERSION | 2 +- pyproject.toml | 6 +++--- src/pyflexplot/data/presets/opr/icon-ch2-eps/all_png.toml | 1 + src/pyflexplot/input/fix_nc_input.py | 2 +- src/pyflexplot/input/meta_data.py | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 9084fa2f..524cb552 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.1.1 diff --git a/pyproject.toml b/pyproject.toml index 92b23a9a..7ed081bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,8 +7,8 @@ build-backend = "setuptools.build_meta" [project] name = "pyflexplot" -version = "1.1.0" -description = "Stefan Ruedisuehli's PyFlexPlot" +version = "1.1.1" +description = "PyFlexPlot - Visualize and post-process FLEXPART dispersion simulation results stored in NetCDF format" readme = "README.md" keywords = [ "Dispersion", @@ -22,7 +22,7 @@ classifiers = [ "Intended Audience :: Developers", "Natural Language :: English", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ] requires-python = ">=3.10" authors = [ diff --git a/src/pyflexplot/data/presets/opr/icon-ch2-eps/all_png.toml b/src/pyflexplot/data/presets/opr/icon-ch2-eps/all_png.toml index 04ca29ff..e1355d92 100644 --- a/src/pyflexplot/data/presets/opr/icon-ch2-eps/all_png.toml +++ b/src/pyflexplot/data/presets/opr/icon-ch2-eps/all_png.toml @@ -1,6 +1,7 @@ # PyFlexPlot setup file to create ensemble ICON-CH2-EPS plots [_base] +# Test data source: /store_new/mch/msopr/pyflexplot_testdata/ infile = "data/icon-ch2-eps/2021030503/{ens_member:03}/grid_conc_20210305030000.nc_BUG" ens_member_id = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] model = "ICON-CH2-EPS" diff --git a/src/pyflexplot/input/fix_nc_input.py b/src/pyflexplot/input/fix_nc_input.py index 748b5bca..844e6086 100644 --- a/src/pyflexplot/input/fix_nc_input.py +++ b/src/pyflexplot/input/fix_nc_input.py @@ -16,7 +16,7 @@ class FlexPartDataFixer: """Fix issues with FlexPart NetCDF output.""" - cosmo_models = ["COSMO-2", "COSMO-1", "COSMO-E", "COSMO-1E", "COSMO-2E"] + cosmo_models = ["COSMO-2", "COSMO-1", "COSMO-E", "COSMO-1E", "COSMO-2E", "ICON-CH1-CTRL", "ICON-CH2-CTRL", "ICON-CH1-EPS", "ICON-CH2-EPS"] ifs_models = ["IFS-HRES", "IFS-HRES-EU"] def __init__(self, file_reader): diff --git a/src/pyflexplot/input/meta_data.py b/src/pyflexplot/input/meta_data.py index 8775a476..f99ef644 100644 --- a/src/pyflexplot/input/meta_data.py +++ b/src/pyflexplot/input/meta_data.py @@ -871,7 +871,7 @@ def time_step_idx(self) -> int: def derive_variable_name(model: str, variable: str, species_id: int) -> str: """Derive the NetCDF variable name given some attributes.""" - cosmo_models = ["COSMO-2", "COSMO-1", "COSMO-E", "COSMO-2E", "COSMO-1E"] + cosmo_models = ["COSMO-2", "COSMO-1", "COSMO-E", "COSMO-2E", "COSMO-1E", "ICON-CH1-CTRL", "ICON-CH2-CTRL", "ICON-CH1-EPS", "ICON-CH2-EPS"] ifs_models = ["IFS-HRES", "IFS-HRES-EU"] if variable == "concentration": if model in cosmo_models: From 8280c74a6b0d1c724ceaf36e170736008a4aaf8a Mon Sep 17 00:00:00 2001 From: Pirmin Kaufmann Date: Mon, 22 Jan 2024 16:59:39 +0100 Subject: [PATCH 3/6] Add modifications from black. --- src/pyflexplot/input/fix_nc_input.py | 12 ++++++++++- src/pyflexplot/input/meta_data.py | 12 ++++++++++- src/pyflexplot/plots.py | 30 +++++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/pyflexplot/input/fix_nc_input.py b/src/pyflexplot/input/fix_nc_input.py index 844e6086..00505684 100644 --- a/src/pyflexplot/input/fix_nc_input.py +++ b/src/pyflexplot/input/fix_nc_input.py @@ -16,7 +16,17 @@ class FlexPartDataFixer: """Fix issues with FlexPart NetCDF output.""" - cosmo_models = ["COSMO-2", "COSMO-1", "COSMO-E", "COSMO-1E", "COSMO-2E", "ICON-CH1-CTRL", "ICON-CH2-CTRL", "ICON-CH1-EPS", "ICON-CH2-EPS"] + cosmo_models = [ + "COSMO-2", + "COSMO-1", + "COSMO-E", + "COSMO-1E", + "COSMO-2E", + "ICON-CH1-CTRL", + "ICON-CH2-CTRL", + "ICON-CH1-EPS", + "ICON-CH2-EPS", + ] ifs_models = ["IFS-HRES", "IFS-HRES-EU"] def __init__(self, file_reader): diff --git a/src/pyflexplot/input/meta_data.py b/src/pyflexplot/input/meta_data.py index f99ef644..397ee09d 100644 --- a/src/pyflexplot/input/meta_data.py +++ b/src/pyflexplot/input/meta_data.py @@ -871,7 +871,17 @@ def time_step_idx(self) -> int: def derive_variable_name(model: str, variable: str, species_id: int) -> str: """Derive the NetCDF variable name given some attributes.""" - cosmo_models = ["COSMO-2", "COSMO-1", "COSMO-E", "COSMO-2E", "COSMO-1E", "ICON-CH1-CTRL", "ICON-CH2-CTRL", "ICON-CH1-EPS", "ICON-CH2-EPS"] + cosmo_models = [ + "COSMO-2", + "COSMO-1", + "COSMO-E", + "COSMO-2E", + "COSMO-1E", + "ICON-CH1-CTRL", + "ICON-CH2-CTRL", + "ICON-CH1-EPS", + "ICON-CH2-EPS", + ] ifs_models = ["IFS-HRES", "IFS-HRES-EU"] if variable == "concentration": if model in cosmo_models: diff --git a/src/pyflexplot/plots.py b/src/pyflexplot/plots.py index 370baa8b..c0114cbe 100644 --- a/src/pyflexplot/plots.py +++ b/src/pyflexplot/plots.py @@ -230,7 +230,14 @@ def get_domain(field: Field, aspect: float) -> Domain: mask_nz = field.time_props.mask_nz domain: Optional[Domain] = None if domain_type == "full": - if model_name in ["COSMO-1", "COSMO-1E", "COSMO-2", "COSMO-E", "ICON-CH1-CTRL", "ICON-CH2-CTRL"]: + if model_name in [ + "COSMO-1", + "COSMO-1E", + "COSMO-2", + "COSMO-E", + "ICON-CH1-CTRL", + "ICON-CH2-CTRL", + ]: domain = Domain(lat, lon, config={"zoom_fact": 1.01}) elif model_name in ["COSMO-2E", "ICON-CH1-EPS", "ICON-CH2-EPS"]: domain = Domain(lat, lon, config={"zoom_fact": 1.025}) @@ -270,7 +277,15 @@ def get_domain(field: Field, aspect: float) -> Domain: }, ) elif domain_type == "ch": - if model_name in ["COSMO-1", "COSMO-1E", "COSMO-2E", "ICON-CH1-CTRL", "ICON-CH2-CTRL", "ICON-CH1-EPS", "ICON-CH2-EPS"]: + if model_name in [ + "COSMO-1", + "COSMO-1E", + "COSMO-2E", + "ICON-CH1-CTRL", + "ICON-CH2-CTRL", + "ICON-CH1-EPS", + "ICON-CH2-EPS", + ]: domain = Domain( lat, lon, config={"zoom_fact": 3.6, "rel_offset": (-0.02, 0.045)} ) @@ -1554,7 +1569,16 @@ def format_model_info(model_setup: ModelSetup, words: TranslatedWords) -> str: # SR_TMP > model_info = None if simulation_type == "deterministic": - if model_name in ["COSMO-1", "COSMO-2", "ICON-CH1-CTRL", "ICON-CH2-CTRL", "ICON-CH1-EPS", "ICON-CH2-EPS", "IFS-HRES", "IFS-HRES-EU"]: + if model_name in [ + "COSMO-1", + "COSMO-2", + "ICON-CH1-CTRL", + "ICON-CH2-CTRL", + "ICON-CH1-EPS", + "ICON-CH2-EPS", + "IFS-HRES", + "IFS-HRES-EU", + ]: model_info = model_name elif model_name in ["COSMO-E", "COSMO-1E", "COSMO-2E"]: model_info = f"{model_name} {words['control_run']}" From 3e8cc2291f6a0dd701bfe91faefd119d3fe6061d Mon Sep 17 00:00:00 2001 From: Pirmin Kaufmann Date: Fri, 16 Feb 2024 16:39:40 +0100 Subject: [PATCH 4/6] Update README.md, fix bug that caused species attributes to always have the default values. --- README.md | 125 ++++++++++++++++++++---------- src/pyflexplot/input/meta_data.py | 2 +- src/pyflexplot/input/species.py | 27 ++++--- 3 files changed, 97 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index 9870560d..1104fa49 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # PyFlexPlot + PyFlexPlot is a Python-based tool to visualize/post-process FLEXPART dispersion simulation results stored in NetCDF format. + ## Table of Contents + - [Prerequisites and Cloning the Repository](#prerequisites-and-cloning-the-repository) - [Getting Started](#getting-started) - [Usage](#usage) @@ -16,9 +19,13 @@ PyFlexPlot is a Python-based tool to visualize/post-process FLEXPART dispersion - [Credits](#credits) - [External Links](#external-links) - [License](#license) + ## Prerequisites and Cloning the Repository -Before you get started with this repository, ensure you have the following software/tools installed on your system: Git, Python and conda/mamba. -To get a local copy of this repository, run following commands and naviate into the repository: + +Before you get started with this repository, ensure you have the following software tools installed on your system: Git, Python and Conda. + +To get a local copy of this repository, run the following commands and naviate into the repository: + ```bash git clone https://github.com/MeteoSwiss-APN/pyflexplot cd @@ -28,26 +35,25 @@ cd Once you created or cloned this repository, make sure the installation is running properly. Install the package dependencies with the provided script `setup_env.sh`. Check available options with + ```bash tools/setup_env.sh -h ``` + We distinguish pinned installations based on exported (reproducible) environments and free installations where the installation is based on top-level dependencies listed in `requirements/requirements.yml`. If you start developing, you might want to do an unpinned installation and export the environment: ```bash tools/setup_env.sh -u -e -n ``` -*Hint*: If you are the package administrator, it is a good idea to understand what this script does, you can do everything manually with `conda` instructions. -*Hint*: Use the flag `-m` to speed up the installation using mamba. Of course you will have to install mamba first (we recommend to install mamba into your base -environment `conda install -c conda-forge mamba`. If you install mamba in another (maybe dedicated) environment, environments installed with mamba will be located -in `/envs/mamba/envs`, which is not very practical. +*Hint*: If you are the package administrator, it is a good idea to understand what this script does, you can do everything manually with `conda` instructions. -The package itself is installed with `pip`. For development, install in editable mode: +The package itself is installed with `pip`. As all dependencies have already been installed by Conda, use the `--no-deps` option for pip. For development, install the package in "editable" mode: ```bash conda activate -pip install --editable . +pip install --no-deps --editable . ``` *Warning:* Make sure you use the right pip, i.e. the one from the installed conda environment (`which pip` should point to something like `path/to/miniconda/envs//bin/pip`). @@ -64,62 +70,90 @@ If the tests pass, you are good to go. If not, contact the package administrator every time you add new imports while developing. Check the next section to find some guidance on the development process if you are new to Python and/or SEN. ## Usage + To utilize pyflexplot, first ensure you are in the root directory of the project and have activated the necessary conda environment: + ```bash cd conda activate ``` + The primary command for pyflexplot follows this structure: + ```bash pyflexplot [OPTIONS] CONFIG_FILE_DIRECTORY ``` + To see the available options, run: + ```bash - pyflexplot -h + pyflexplot --help ``` -To utilize all available CPUs for the command, use the option: + +To utilize all available CPUs for the command, add the option: + ```bash ---num-procs=$SLURM_CPUS_PER_TASK + --num-procs=$SLURM_CPUS_PER_TASK ``` ### Usage Example + After you've set up pyflexplot ([Prerequisites and cloning the repository](#prerequisites-and-cloning-the-repository) and [Getting started](#getting-started)), you'll need to specify a configuration file and an output directory. -Create an output directory using: +Define the variable `dest` to contain the name of the output directory, e.g.: + ```bash -dest=test_output/ +dest=plot-test/ ``` + Note: The directory will be automatically created if it doesn't already exist. -There are several default config files available under ```src/pyflexplot/data/presets/opr```. -Furthermore, there are already several default config files available in the directory ```src/pyflexplot/data/presets/opr```. -To run the program for all presets in the PDF graphics format with the default input data, use: +There are several default config files available under [`src/pyflexplot/data/presets/opr`](src/pyflexplot/data/presets/opr/). +To run the program for all presets that produce the graphics in PDF format, define the `preset` variable as: + ```bash preset='opr/*/all_pdf' ``` -Alternatively, select a specific preset from the table below: -| Model | Type | Preset | -|------------------|----------------------|----------------------------------| -| FLEXPART-IFS | Global output: | preset=opr/ifs-hres/all_pdf | -| FLEXPART-IFS | Europe output: | preset=opr/ifs-hres-eu/all_pdf | -| FLEXPART-COSMO | deterministic output:| preset=opr/cosmo-1e-ctrl/all_pdf | -| FLEXPART-COSMO | deterministic output:| preset=opr/cosmo-2e-ctrl/all_pdf | -| FLEXPART-COSMO-1E| ensemble output: | preset=opr/cosmo-1e/all_pdf | -| FLEXPART-COSMO-2E| ensemble output: | preset=opr/cosmo-2e/all_pdf | - -After selecting a preset, run pyflexplot interactively: - ```bash + +This preset however only works for the default (test) input files. + +To produce graphics for a specific FLEXPART output, select the fitting specific preset from the table below and define the `preset` variable accordingly: + +| Model | Type | Define Preset Variable | +|-----------------------|--------------|------------------------------------| +| FLEXPART-IFS | global | `preset=opr/ifs-hres/all_pdf` | +| FLEXPART-IFS | Europe | `preset=opr/ifs-hres-eu/all_pdf` | +| FLEXPART-COSMO-1E-CTRL| deterministic| `preset=opr/cosmo-1e-ctrl/all_pdf` | +| FLEXPART-COSMO-2E-CTRL| deterministic| `preset=opr/cosmo-2e-ctrl/all_pdf` | +| FLEXPART-COSMO-1E | ensemble | `preset=opr/cosmo-1e/all_pdf` | +| FLEXPART-COSMO-2E | ensemble | `preset=opr/cosmo-2e/all_pdf` | +| FLEXPART-ICON-CH1-CTRL| deterministic| `preset=opr/icon-ch1-ctrl/all_pdf` | +| FLEXPART-ICON-CH2-EPS | ensemble | `preset=opr/icon-ch2-eps/all_pdf` | + +After selecting a preset, run pyflexplot interactively for the default test data: + +```bash pyflexplot --preset "$preset" --merge-pdfs --dest=$dest ``` +Alternatively, specify the FLEXPART output file in NetCDF format as input data: + +```bash +pyflexplot --preset "$preset" --merge-pdfs --dest=$dest --setup infile +``` + +For ensemble input, the placeholder `{ens_member:03}` may be used within the path of ``. Instead of `03` for `%03d`, other formats for the ensemble member field can be used. + ## Developer Notes As this package was created with the SEN Python blueprint, it comes with a stack of development tools, which are described in more detail on the [Website](https://meteoswiss-apn.github.io/mch-python-blueprint/). Here, we give a brief overview on what is implemented. ### Implemented Debugging Features + pyflexplot offers several debugging options to assist in troubleshooting and refining your workflow (see ```pyflexplot -h```). Here are some of the key debugging features: + ``` --pdb / --no-pdb Drop into debugger when an exception is raised. [default: no-pdb] --preset-cat PATTERN Show the contents of preset setup files @@ -146,19 +180,19 @@ pytest If you use the tools provided by the blueprint as is, pre-commit will not be triggered locally but only if you push to the main branch (or push to a PR to the main branch). If you consider it useful, you can set up pre-commit to run locally before every commit by initializing it once. In the root directory of -your package, type: +your package, type `pre-commit install`. If you run `pre-commit` without having it installed before, it will fail, and the only way to recover it is to do a forced reinstallation (`conda install --force-reinstall pre-commit`). -```bash -pre-commit install +Alternatively, you can instead run `pre-commit` selectively, without installing and whenever you want, by typing + +``` +pre-commit run --all-files ``` -If you run `pre-commit` without installing it before (line above), it will fail and the only way to recover it, is to do a forced reinstallation (`conda install --force-reinstall pre-commit`). -You can also just run pre-commit selectively, whenever you want by typing (`pre-commit run --all-files`). Note that mypy and pylint take a bit of time, so it is really +Note that mypy and pylint take a bit of time, so it is really up to you, if you want to use pre-commit locally or not. In any case, after running pytest, you can commit and the linters will run at the latest on the GitHub actions server, when you push your changes to the main branch. Note that pytest is currently not invoked by pre-commit, so it will not run automatically. Automated testing can be set up with GitHub Actions or be implemented in a Jenkins pipeline (template for a plan available in `jenkins/`. See the next section for more details. - ### Testing and Coding Standards Testing your code and compliance with the most important Python standards is a requirement for Python software written in SEN. To make the life of package @@ -179,6 +213,7 @@ automatically. If you need to run your tests on CSCS machines, contact DevOps to and exclusively run your tests and checks on GitHub actions. ### Updating the Test References + Pyflexplot includes a set of functionality tests that compare generated output against predefined reference data. These reference files, which are in the .py format, are derived from and stored alongside the original data in the tests/data directory. To update these references, uncomment the lines of code in the test file you wish to update and run the test. @@ -186,28 +221,34 @@ To update these references, uncomment the lines of code in the test file you wis ## Key Features ### PDF and PNG Files + Pyflexplot allows to visualize data on a map plot and save the output in either PDF or PNG format. To utilize this feature, simply adjust the outfile variable with the appropriate file extension. ![Example Image Output](img/integrated_concentration_site-Goesgen_species-1_domain-full_lang-de_ts-20200217T0900.png) + ### Shape File Generation + Furthermore, Pyflexplot provides the functionality to export data into shape files (.shp) to utilize them in GIS programs such as QGIS 3. The output is a ZIP archive containing the essential components of a shapefile: .shp, .dbf, .shx, .prj, and .shp.xml. Key aspects of this feature include: -* __Filtering Zero Values__: The tool initially removes zero values from fields (e.g., concentration) before processing. -* __Logarithmic Transformation__: Field values undergo a log_10 transformation to optimize the visualization of data ranges. -* __Precision Handling__: The transformed field values are recorded with 15 decimal places, accommodating the precision limitations of some GIS software. -* __Metadata Storage__: Information, such as details about released materials, are stored within a .shp.xml file as metadata. +- __Filtering Zero Values__: The tool initially removes zero values from fields (e.g., concentration) before processing. +- __Logarithmic Transformation__: Field values undergo a log_10 transformation to optimize the visualization of data ranges. +- __Precision Handling__: The transformed field values are recorded with 15 decimal places, accommodating the precision limitations of some GIS software. +- __Metadata Storage__: Information, such as details about released materials, are stored within a .shp.xml file as metadata. + ### Scaling the field values + Another feature is to manipulate the field values by scaling with an arbitrary factor. This factor can be set in the preset with the variable `multiplier`. + ## Credits This package was created with [`copier`](https://github.com/copier-org/copier) and the [`MeteoSwiss-APN/mch-python-blueprint`](https://github.com/MeteoSwiss-APN/mch-python-blueprint) project template. ## External Links -* [copier](https://github.com/copier-org/copier) - Based library and CLI app for rendering project templates. -* [mch-python-blueprint](https://github.com/MeteoSwiss-APN/mch-python-blueprint) - Project template embedded in this project based on copier. -* [pyshp](https://github.com/GeospatialPython/pyshp) - Python module to generate Shapefiles - +- [copier](https://github.com/copier-org/copier) - Based library and CLI app for rendering project templates. +- [mch-python-blueprint](https://github.com/MeteoSwiss-APN/mch-python-blueprint) - Project template embedded in this project based on copier. +- [pyshp](https://github.com/GeospatialPython/pyshp) - Python module to generate Shapefiles ## License + This project is licensed under the terms of the MeteoSwiss. The full license text can be found in the [LICENSE](LICENSE) file. In essence, you are free to use, modify, and distribute the software, provided the associated copyright notice and disclaimers are included. diff --git a/src/pyflexplot/input/meta_data.py b/src/pyflexplot/input/meta_data.py index 397ee09d..d6d8124b 100644 --- a/src/pyflexplot/input/meta_data.py +++ b/src/pyflexplot/input/meta_data.py @@ -655,7 +655,7 @@ def from_file( sedimentation_velocity_unit=cast(str, species.sedimentation_velocity.unit), washout_coefficient=species.washout_coefficient.value, washout_coefficient_unit=cast(str, species.washout_coefficient.unit), - washout_exponent=species.washout_exponent.value, + washout_exponent=species.washout_exponent, ) @staticmethod diff --git a/src/pyflexplot/input/species.py b/src/pyflexplot/input/species.py index 40b53902..3bf93fad 100644 --- a/src/pyflexplot/input/species.py +++ b/src/pyflexplot/input/species.py @@ -1,10 +1,11 @@ """Chemical species and their attributes.""" +from __future__ import annotations + # Standard library import dataclasses as dc from dataclasses import dataclass # pylint doesn't understand dc.dataclass from typing import Any from typing import cast -from typing import Dict from typing import List from typing import Optional from typing import overload @@ -55,21 +56,19 @@ class Species: deposition_velocity: SpeciesAttribute = dc.field(default=SpeciesAttribute) # type: ignore # noqa: E501 sedimentation_velocity: SpeciesAttribute = dc.field(default=SpeciesAttribute) # type: ignore # noqa: E501 washout_coefficient: SpeciesAttribute = dc.field(default=SpeciesAttribute) # type: ignore # noqa: E501 - washout_exponent: SpeciesAttribute = dc.field(default=SpeciesAttribute) # type: ignore # noqa: E501 + washout_exponent: float = 0 @classmethod - def create(cls, **params: Any) -> "Species": - params_prep: Dict[str, Any] = {} - fields = cls.__dataclass_fields__ # type: ignore # pylint: disable=E1101 - for param, value in params.items(): - try: - field: dc.Field = fields[param] - except KeyError as e: - raise ValueError(param) from e - if issubclass(field.type, SpeciesAttribute): - value = SpeciesAttribute.create(value) - params_prep[param] = value - return cls(**params_prep) + def create(cls, **params: Any) -> Species: + return_value = cls() + attribute_names = [field.name for field in dc.fields(Species)] + for name, value in params.items(): + if name in attribute_names: + if return_value.__annotations__[name] != "SpeciesAttribute": + return_value.__setattr__(name, value) + else: + return_value.__setattr__(name, SpeciesAttribute(*value)) + return return_value def __post_init__(self): self.weight = SpeciesAttribute(-99.9, "g mol-1") From 6f2f16493bba6eaa150d35ac3cefeb1c5929de5d Mon Sep 17 00:00:00 2001 From: Pirmin Kaufmann Date: Fri, 16 Feb 2024 17:14:47 +0100 Subject: [PATCH 5/6] Make README.md adhere to MD032. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1104fa49..a21e427b 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ pyflexplot offers several debugging options to assist in troubleshooting and refining your workflow (see ```pyflexplot -h```). Here are some of the key debugging features: - ``` + ```text --pdb / --no-pdb Drop into debugger when an exception is raised. [default: no-pdb] --preset-cat PATTERN Show the contents of preset setup files --only N Only create the first N plots based on the given setup. @@ -184,7 +184,7 @@ your package, type `pre-commit install`. If you run `pre-commit` without having Alternatively, you can instead run `pre-commit` selectively, without installing and whenever you want, by typing -``` +```bash pre-commit run --all-files ``` @@ -229,6 +229,7 @@ Pyflexplot allows to visualize data on a map plot and save the output in either Furthermore, Pyflexplot provides the functionality to export data into shape files (.shp) to utilize them in GIS programs such as QGIS 3. The output is a ZIP archive containing the essential components of a shapefile: .shp, .dbf, .shx, .prj, and .shp.xml. Key aspects of this feature include: + - __Filtering Zero Values__: The tool initially removes zero values from fields (e.g., concentration) before processing. - __Logarithmic Transformation__: Field values undergo a log_10 transformation to optimize the visualization of data ranges. - __Precision Handling__: The transformed field values are recorded with 15 decimal places, accommodating the precision limitations of some GIS software. From 8b99ce74365f5aeebf4e5d88a580bacee536a635 Mon Sep 17 00:00:00 2001 From: Pirmin Kaufmann Date: Fri, 16 Feb 2024 17:45:30 +0100 Subject: [PATCH 6/6] Use pinned environment for gihub actions. --- .github/workflows/pre-commit.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 071e0f93..62b77fe8 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,4 +1,4 @@ -name: Run pre-commit in blueprint +name: Run pre-commit in pyflexplot on: push: @@ -9,7 +9,7 @@ on: - main jobs: - blueprint-pre-commit: + pyflexplot-pre-commit: runs-on: ubuntu-latest defaults: run: @@ -26,9 +26,9 @@ jobs: channels: conda-forge channel-priority: flexible show-channel-urls: true - - name: Create env from unpinned reqs + - name: Create env from pinned reqs run: | - conda env create --name dev_env --file requirements/requirements.yml + conda env create --name dev_env --file requirements/environment.yml - name: Install project into env run: | conda run --name dev_env pip install --no-deps .