TNO Intern

Fixes for colocated output.

Minor changes to ensure proper creation of colocated timeseries.

Merge request reports

Loading
+85 −69

File changed.

Preview size limit exceeded, changes collapsed.

+15
Changes for src/cso/cso_file.py: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -36,6 +36,10 @@
#   - added GetValue method
#   Removed usage of undefined filename in error messages.
#
# 2025-04, Arjo Segers
#   Enable zlib compression only for numerical data.
#   Avoid warnings from packing in case of all-nan values.
#

########################################################################
###
@@ -185,9 +189,16 @@ def Pack_DataArray(da, dtype="i2"):

    # only floats ...
    if da.dtype in [numpy.float32, numpy.float64]:
        # should have some values ..
        if numpy.any( ~ numpy.isnan(da.values) ):
            # value range, ignore nan's:
            vmin = numpy.nanmin(da.values)
            vmax = numpy.nanmax(da.values)
        else:
            # dummy range:
            vmin = 0.0
            vmax = 0.0
        #end if
        # target data type could be integer or float:
        if dtype.startswith("i"):
            # use absolute minimum to represent nans:
@@ -606,9 +617,13 @@ class CSO_File(object):
        if complevel > 0:
            # loop over variables:
            for vname in self.ds.keys():
                # only numerical values:
                dtype = self.ds[vname].dtype
                if numpy.issubdtype(dtype,numpy.integer) or numpy.issubdtype(dtype,numpy.floating):
                    # enable zlib compression and set level:
                    self.ds[vname].encoding["zlib"] = True
                    self.ds[vname].encoding["complevel"] = complevel
                # endif
            # endfor # variables
        # endif # comppress

Loading