Project

General

Profile

mergetime -- NC_SHORT -- values out of range

Added by Thorsten Simon over 3 years ago

Hi all,
sorry for dublicating, if this has been discussed elsewhere.

I would like to merge files by time. Within the files I have a variable of type short with attributes scale_factor and add_offset. When I try

cdo mergetime test-03a.nc test-03b.nc test-03.nc

However, this leads to values outside the valid range of the type's precision. It seems to me that cdo tries to re-scale the variable of the second input file, and then coerce it back to a short integer by using scale_factor and add_offset of the first file.

Is there anything I miss. Is there an option to tell cdo to do the scaling considering min and max values over all files?

Thanks a lot,
Thorsten


Replies (6)

RE: mergetime -- NC_SHORT -- values out of range - Added by Karin Meier-Fleischer over 3 years ago

Hi Thorsten,

the error message which says that the values are outside the value range points to the wrong data type. In your case you should use 32-bit integer.

cdo -b I32 -mergetime test-03a.nc test-03b.nc test-03.nc

-Karin

RE: mergetime -- NC_SHORT -- values out of range - Added by Thorsten Simon over 3 years ago

Hi Karin,

thank you for your response. Though, using 32-bit integer is not what I want. In my real case I would have to double the quota of storage, just because the overall maximum slightly exceeds the maximum of my first file in the list.

Maybe it is possible to merge the files with input and output at 32-bit precision (Sure it is), and then do the scaling afterwards. But is there a cdo function that would apply the scaling as proposed unidata (https://www.unidata.ucar.edu/software/netcdf/documentation/NUG/_best_practices.html) ?

-Thorsten

RE: mergetime -- NC_SHORT -- values out of range - Added by Uwe Schulzweida over 3 years ago

Hi Thorsten,

you can try the undocumented operator pack, this operator will repack your data. The status of this operator is experimental but it works quite stable.

cdo pack -mergetime test-03a.nc test-03b.nc test-03.nc
Cheers,
Uwe

RE: mergetime -- NC_SHORT -- values out of range - Added by Thorsten Simon over 3 years ago

Hi Uwe,

Thanks a lot. That's what I was looking for. It worked on a test case.

Is there a option to set the _FillValue/missing_value?

Best,
Thorsten

RE: mergetime -- NC_SHORT -- values out of range - Added by Uwe Schulzweida over 3 years ago

The operator setmissval sets the missing value. Here an example:

cdo pack -setmissval,-999 -mergetime test-03a.nc test-03b.nc test-03.nc

RE: mergetime -- NC_SHORT -- values out of range - Added by Thorsten Simon over 3 years ago

Thanks a lot for the quick help. That's closes the thread.

Cheers,
Thorsten

    (1-6/6)