TNO Intern

Fix superobs

Fixes for latest python version. Improved error checking.

Merge request reports

Loading
+8 −5
Changes for doc/source/history.rst: 8 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -119,6 +119,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


  
+4 −1
Changes for src/cso/cso_file.py: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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 = []
+7 −4
Changes for src/cso/cso_mapping.py: 7 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -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
+7 −2
Changes for src/cso/cso_s5p.py: 7 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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
+15 −6
Changes for src/cso/cso_superobs.py: 15 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -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:
Loading
Loading