TNO Intern

Commit e1367e70 authored by Arjo Segers's avatar Arjo Segers
Browse files

Trap case that no pixels are selected.

parent fa713cea
Loading
Loading
Loading
Loading
+15 −6
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: