Loading src/cso/cso_file.py +13 −10 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ # # 2025-04, Arjo Segers # Enable zlib compression only for numerical data. # Avoid warnings from packing in case of all-nan values. # ######################################################################## Loading Loading @@ -188,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: Loading Loading @@ -610,13 +618,8 @@ class CSO_File(object): # loop over variables: for vname in self.ds.keys(): # only numerical values: if self.ds[vname].dtype in [ numpy.int16, numpy.int32, numpy.int64, numpy.float32, numpy.float64, ]: 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 Loading Loading
src/cso/cso_file.py +13 −10 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ # # 2025-04, Arjo Segers # Enable zlib compression only for numerical data. # Avoid warnings from packing in case of all-nan values. # ######################################################################## Loading Loading @@ -188,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: Loading Loading @@ -610,13 +618,8 @@ class CSO_File(object): # loop over variables: for vname in self.ds.keys(): # only numerical values: if self.ds[vname].dtype in [ numpy.int16, numpy.int32, numpy.int64, numpy.float32, numpy.float64, ]: 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 Loading