From 9a59fc0cdd16599524a16f72b120d49d67770020 Mon Sep 17 00:00:00 2001 From: Arjo Segers Date: Wed, 21 Jan 2026 13:04:18 +0100 Subject: [PATCH 1/6] Fixed documentation. --- src/utopya/utopya_build.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utopya/utopya_build.py b/src/utopya/utopya_build.py index e5c02e4..7be5b31 100644 --- a/src/utopya/utopya_build.py +++ b/src/utopya/utopya_build.py @@ -222,10 +222,10 @@ class UtopyaCopy(utopya_rc.UtopyaRc): see the initialization of the :py:class:`.UtopyaRc` class for details and the necessary configuration of the logging system. - If the *'new'* flag is present it overwrites the *'\*.copy.new'* flag; - set to '*True'* to remove an existing build directory if present. + If the ``new`` flag is present it overwrites the ``copy.new`` rcfile setting; + set to ``True`` to remove an existing build directory if present. - The following example shows the required settings for an rcbase *'optm'*. + The following example shows the required settings for an rcbase ``optm``. The content of the directories:: sources/model/base/src -- GitLab From 230664b6868020094378536e3badd9e6b79c296c Mon Sep 17 00:00:00 2001 From: Arjo Segers Date: Wed, 21 Jan 2026 13:04:45 +0100 Subject: [PATCH 2/6] Changes following deprication warnings. --- src/cso/cso_file.py | 5 ++++- src/cso/cso_s5p.py | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cso/cso_file.py b/src/cso/cso_file.py index b1f2d85..aa59f5d 100644 --- a/src/cso/cso_file.py +++ b/src/cso/cso_file.py @@ -58,6 +58,9 @@ # 2025-10, Arjo Segers # Replace ' and ' by ' & ' when selecting records. # +# 2026-01, Arjo Segers +# Updated use of Dataset.dims following deprication warning. +# ######################################################################## ### @@ -1128,7 +1131,7 @@ class CSO_File(object): logging.info(indent + "pixel selection ...") # init selection, by default accept all: - selected = numpy.ones((self.ds.dims["pixel"],), "bool") + selected = numpy.ones((self.ds.sizes["pixel"],), "bool") # init history: history = [] diff --git a/src/cso/cso_s5p.py b/src/cso/cso_s5p.py index 602bdf3..c20275d 100644 --- a/src/cso/cso_s5p.py +++ b/src/cso/cso_s5p.py @@ -74,6 +74,10 @@ # Trap multiple selections from inquire table as this might indicate # a problem in the table or the selection. # +# 2026-01, Arjo Segers +# Updated use of Dataset.dims following deprication warning. +# Explicitly defined data type in encoding of time array folowing warning. +# ######################################################################## @@ -223,9 +227,9 @@ class S5p_File(object): self.nscan = ds.sizes["scanline"] self.ngpix = ds.sizes["ground_pixel"] # number 'atmoshpere' layers: - if "layer" in ds.dims.keys(): + if "layer" in ds.dims: self.nlayer = ds.sizes["layer"] - elif "level" in ds.dims.keys(): + elif "level" in ds.dims: self.nlayer = ds.sizes["level"] else: self.nlayer = None @@ -1408,6 +1412,7 @@ class CSO_S5p_File(cso_file.CSO_File): da.attrs["long_name"] = "time" da.encoding["calendar"] = "standard" da.encoding["units"] = f"seconds since {t0.year}-01-01 00:00:000" + da.encoding["dtype"] = "float64" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # pixel corners: for longitudes, need to ensure that also near dateline -- GitLab From fa713cea7944e44903766a5e72a975be401391e1 Mon Sep 17 00:00:00 2001 From: Arjo Segers Date: Wed, 21 Jan 2026 13:05:03 +0100 Subject: [PATCH 3/6] Changed imports for python packaging. --- src/cso/cso_mapping.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cso/cso_mapping.py b/src/cso/cso_mapping.py index e23f3df..fe95bb7 100644 --- a/src/cso/cso_mapping.py +++ b/src/cso/cso_mapping.py @@ -14,6 +14,9 @@ # 2023-08, Arjo Segers # Remove rounding errors when locations are very close. # +# 2026-01, Arjo Segers +# Changed imports for python packaging. +# ######################################################################## ### @@ -89,7 +92,7 @@ def LonLatDistance(lon1, lat1, lon2, lat2): import numpy # tools: - from cso_constants import EarthRadius + from . import cso_constants # convert: delta = lon2 - lon1 @@ -102,7 +105,7 @@ def LonLatDistance(lon1, lat1, lon2, lat2): phi = numpy.arccos(x.clip(-1.0, 1.0)) # radians # in m over the globe: - return phi * EarthRadius # m + return phi * cso_constants.EarthRadius # m # enddef # LonLatDistance @@ -176,7 +179,7 @@ def LonLatTrianglesArea(xx, yy): import numpy # tools: - from cso_constants import EarthRadius + from . import cso_constants # areas: aa = TrianglesArea(numpy.radians(xx), numpy.radians(yy)) # rad2 @@ -186,7 +189,7 @@ def LonLatTrianglesArea(xx, yy): # areas: # rad2 m2 - return aa * numpy.cos(yy_aver) * EarthRadius**2 # m2 + return aa * numpy.cos(yy_aver) * cso_constants.EarthRadius**2 # m2 # enddef LonLatTrianglesArea -- GitLab From e1367e7094a55b394b023f429259cc7001eefae4 Mon Sep 17 00:00:00 2001 From: Arjo Segers Date: Wed, 21 Jan 2026 13:05:22 +0100 Subject: [PATCH 4/6] Trap case that no pixels are selected. --- src/cso/cso_superobs.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/cso/cso_superobs.py b/src/cso/cso_superobs.py index 4e18e4c..aec6d44 100644 --- a/src/cso/cso_superobs.py +++ b/src/cso/cso_superobs.py @@ -24,6 +24,12 @@ # 2025-04, Arjo Segers # Changed imports for python packaging. # +# 2026-01, Arjo Segers +# Explicitly defined data type in encoding of time array folowing warning. +# +# 2026-01, Alessandro D'ausilio +# Trap case that no pixels are selected. +# ######################################################################## @@ -350,18 +356,20 @@ class CSO_SuperObs(utopya.UtopyaRc): source_file = cso_file.CSO_File(filename=source_filename) # filter: - selected, history = source_file.SelectPixels( - self.rcf, rcbase, indent=indent + " " - ) + selected, history = source_file.SelectPixels(self.rcf, rcbase, indent=f"{indent} ") # info .. - logging.info( - indent + " selected %i / %i pixels .." % (selected.sum(), selected.size) - ) + logging.info(f"{indent} selected {selected.sum()} / {selected.size} pixels ..") # selected indices: (iipix,) = numpy.where(selected) # number of selected pixels: npix = len(iipix) + # check .. + if npix == 0: + logging.info(f"{indent} no pixels selected, skip ...") + continue + #endif + # footprint or points? if wtype == "number": # info ... @@ -738,6 +746,7 @@ class CSO_SuperObs(utopya.UtopyaRc): # ensure correct output: outf.ds[vkey].encoding["units"] = tunits outf.ds[vkey].encoding["calendar"] = "standard" + outf.ds[vkey].encoding["dtype"] = "float64" outf.ds[vkey].encoding["_FillValue"] = None else: -- GitLab From 5aca6ba5e06b6e5f1a35cb85d92cbcd88c874d0e Mon Sep 17 00:00:00 2001 From: Arjo Segers Date: Wed, 21 Jan 2026 13:05:58 +0100 Subject: [PATCH 5/6] Added sample script to create or activate virtual environment. --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index a22bda9..5f3c04f 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,39 @@ When finished, leave from the virtual environment using: deactivate +Eventually create the following script that activates the envioronment, +or creates it if not present yet: + + # + # Source this script to setup: + # + # . this_script + # + + # virtual environment exists already? + if [ -f .venv/bin/activate ]; then + + # activate: + source .venv/bin/activate + + else + + # eventually enable latest python version: + #module load python/3.13.1 + + # init virtual environment: + python3 -m venv --prompt cso .venv + + # activate: + source .venv/bin/activate + + # upgrade pip: + pip install --upgrade pip + + # install local codes: + pip install --editable . + + fi -- GitLab From 141dca4f53ab7113dfb7b04db3217dcec8831093 Mon Sep 17 00:00:00 2001 From: Arjo Segers Date: Wed, 21 Jan 2026 13:17:06 +0100 Subject: [PATCH 6/6] Defined v2.13 --- CHANGELOG | 6 ++++++ doc/source/history.rst | 13 ++++++++----- pyproject.toml | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5a0154c..9a5b110 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -533,3 +533,9 @@ v2.12 Support running CSO within a virtual environment. + +v2.13 +----- + +Updates for latest python versions. +Improved error checks. diff --git a/doc/source/history.rst b/doc/source/history.rst index d643e08..9294260 100644 --- a/doc/source/history.rst +++ b/doc/source/history.rst @@ -118,6 +118,9 @@ A summary of the versions and changes. * | *v2.12* | Support running in Python virtual environment. + +* | *v2.13* + | Minor updates to trap errors and support latest Python versions. To be included @@ -159,7 +162,7 @@ A wishlist of developments. How to create a version tag =========================== -Example for tag "v2.12". +Example for tag "v2.13". 1. Update file formatting following conventions. @@ -179,17 +182,17 @@ Example for tag "v2.12". c. Change the release tag that will also be imported to the documenation in the `pyproject.toml <../../../pyproject.toml>`_ file:: - release = "2.12" + release = "2.13" d. Commit and push these changes:: - git commit -m 'Defined v2.12' . + git commit -m 'Defined v2.13' . git push 4. Tag and push the code to the git repository:: - git tag -a 'v2.12' -m 'Tagged v2.12' - git push origin v2.12 + git tag -a 'v2.13' -m 'Tagged v2.13' + git push origin v2.13 diff --git a/pyproject.toml b/pyproject.toml index 42d3905..3ed4cac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "cso" -version = "2.12" +version = "2.13" authors = [ { name = "Arjo Segers" }, { name = "Lewis Blake" }, -- GitLab