netcdf-c
netcdf-c copied to clipboard
ncdump reports unsigned int for negative zstd settings
For example, ncdump for zstandard_level -15:
$ ncdump -hs neg_zstd/zstd_-15/atmf001.nc netcdf atmf001 { dimensions: grid_xt = 3072 ; grid_yt = 1536 ; nchars = 20 ; pfull = 127 ; phalf = 128 ; time = 1 ; variables: . . . float tmp(time, pfull, grid_yt, grid_xt) ; tmp:_QuantizeBitRoundNumberOfSignificantBits = 14 ; tmp:_FillValue = 9.99e+20f ; tmp:cell_methods = "time: point" ; tmp:long_name = "temperature" ; tmp:missing_value = 9.99e+20f ; tmp:output_file = "atm" ; tmp:units = "K" ; tmp:_Storage = "chunked" ; tmp:_ChunkSizes = 1, 1, 1536, 3072 ; tmp:_Shuffle = "true" ; tmp:_Endianness = "little" ; tmp:_Filter = "32015,4294967281" ; tmp:_NoFill = "true" ;
It would be nice to see the '_Filter' attribute written as "32015,-15" instead of the equivalent unsigned integer. Is that possible, or this attribute must be unsigned?
Unfortunately, the HDF5 filter system provides no way to discover the actual types of the parameters to a filter. It only sees a sequence of unsigned integers. The actual types are known (presumably) to the client program and to the filter itself. The simplest solution would be to build knowledge of the parameters of selected filters into ncdump so it can interpret the type of the parameter(s). This would also require modifying ncgen since it is desirable for ncdump output to be usable as input to ncgen. There are some other, more general solutions, but it is not clear if they are worth pursuing.
If it were to be done for any specific filter, it should be the ones we support in the API, szlp, zlib, and zstd. Of these, only zstd has negative numbers as a parameter.
It would be nice if ncdump/ncgen reflected this, but it's certainly not crucial. Everything works, as is.