From 5c82c10efd4a6524746e3abdb91a1e5975456c2f Mon Sep 17 00:00:00 2001 From: Karko93 Date: Fri, 22 Dec 2023 09:26:32 +0100 Subject: [PATCH 1/5] Bug fix path --- src/pyflexplot/cli/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pyflexplot/cli/main.py b/src/pyflexplot/cli/main.py index 43a1e302..48e9773d 100644 --- a/src/pyflexplot/cli/main.py +++ b/src/pyflexplot/cli/main.py @@ -514,8 +514,10 @@ def merge_shape_files( merged_files: List[str] = [] n = 0 for i, group in enumerate(grouped_file_paths): - merged = f"""{dest_dir}{relpath(paths_organizer.merge(group), start=tmp_dir)}""" - tmp_zip_name = f"{dest_dir}temp_shape{i}.zip" + merged = ( + f"""{dest_dir}/{relpath(paths_organizer.merge(group), start=tmp_dir)}""" + ) + tmp_zip_name = f"{dest_dir}/temp_shape{i}.zip" if not dry_run: with zipfile.ZipFile(tmp_zip_name, "w") as main_zip: for file in group: From 72c2c669562765c0b7fdff90f582e83835e5163e Mon Sep 17 00:00:00 2001 From: Karko93 Date: Fri, 22 Dec 2023 09:26:57 +0100 Subject: [PATCH 2/5] Add test shape preset file --- .../data/presets/opr/ifs-hres/all_shp.toml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/pyflexplot/data/presets/opr/ifs-hres/all_shp.toml diff --git a/src/pyflexplot/data/presets/opr/ifs-hres/all_shp.toml b/src/pyflexplot/data/presets/opr/ifs-hres/all_shp.toml new file mode 100644 index 00000000..ea57fc54 --- /dev/null +++ b/src/pyflexplot/data/presets/opr/ifs-hres/all_shp.toml @@ -0,0 +1,49 @@ +# PyFlexPlot setup file to create deterministic IFS-HRES-EU plots + +[_base] +# Data source: tsa:/scratch/ruestefa/shared/test/pyflexplot/ +infile = "data/ifs-hres/grid_conc_1000_20200818000000_bushehr_2spec.nc" +model = "IFS-HRES" +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}.shp" +[_base._concentration._integr."_png+"] +outfile = "integrated_concentration_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +[_base._tot_deposition."_png+"] +outfile = "deposition_tot_site-{release_site}_species-{species_id}_domain-{domain}_lang-{lang}_ts-{time_step}.shp" +[_base._affected_area."_png+"] +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 = "cloud" + +["**".zoom] +domain = "release_site" From d8534ee11becd418b3c3c85a454e01b9c8304f91 Mon Sep 17 00:00:00 2001 From: Karko93 Date: Fri, 22 Dec 2023 09:27:28 +0100 Subject: [PATCH 3/5] Bug fix not deleted .shp.xml sub files --- src/pyflexplot/save_data.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pyflexplot/save_data.py b/src/pyflexplot/save_data.py index 7280ac3b..34d2f3ed 100644 --- a/src/pyflexplot/save_data.py +++ b/src/pyflexplot/save_data.py @@ -190,9 +190,7 @@ def save(self, filename: str, plot: BoxedPlot, data: FieldGroup) -> None: def _move_shape_file_to_zip(self, base_file_dir: str, zip_file: zipfile.ZipFile): """Move the generated shapefile components into a ZIP archive.""" - extensions = [".shp", ".shx", ".dbf"] - if "_domain" not in base_file_dir: - extensions += [".shp.xml"] + extensions = [".shp", ".shx", ".dbf", ".shp.xml"] for ext in extensions: file_to_copy = f"{base_file_dir}{ext}" with open(file_to_copy, "rb") as file_in_zip: From 9f191cd77bc71888c6d4056abee9a3a4bb2e2af2 Mon Sep 17 00:00:00 2001 From: Karko93 Date: Fri, 22 Dec 2023 09:41:52 +0100 Subject: [PATCH 4/5] Update python version --- tools/setup_env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/setup_env.sh b/tools/setup_env.sh index 50bd5e80..2c234403 100755 --- a/tools/setup_env.sh +++ b/tools/setup_env.sh @@ -11,7 +11,7 @@ DEFAULT_ENV_NAME="pyflexplot" # Default options ENV_NAME="${DEFAULT_ENV_NAME}" -PYVERSION=3.10 +PYVERSION=3.11 PINNED=true EXPORT=false CONDA=conda From da9617e24619e34a06c298286697870d0ef2be56 Mon Sep 17 00:00:00 2001 From: Karko93 Date: Fri, 22 Dec 2023 09:42:22 +0100 Subject: [PATCH 5/5] Revert function to split path --- src/srutils/paths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/srutils/paths.py b/src/srutils/paths.py index 9f746f64..18e86633 100644 --- a/src/srutils/paths.py +++ b/src/srutils/paths.py @@ -52,7 +52,7 @@ def group_related(self, paths: Sequence[str]) -> list[list[str]]: if rx_numbered.search(path): # Numbered, so not the first continue - path_base = path.split(self._dup_sep)[0] + path_base = path.rstrip(self._suffix) paths.remove(path) grouped_file_paths.append([path]) rx_related = re.compile(