Error in shiftime
Added by Daniela Faggiani Dias over 11 years ago
Dear all,
I need to change the date of some files, for minus one day. I try to do it using the following command:
cdo shifttime,-1day test.nc test1.nc
But it doesn't work well...the date of my file "test.nc" is 2011-04-02 and the date of the file "test1.nc" should be 2011-04-01, but in fact it becomes 2147-05-08. Actually, if I go forward, for example "cdo shifttime,1day test.nc test1.nc", it works well, or if I go backward, but using month instead of days, for example "cdo shifttime,-1month test.nc test1.nc" it also works well.
I have no ideia why...
Can anyone help me with this?
Thank you!
PS: The file "test.nc" is attached and my cdo version is 1.6.0
Replies (5)
RE: Error in shiftime - Added by Uwe Schulzweida over 11 years ago
Thanks for this information. This Bug is already fixed in the latest CDO version 1.6.1.
RE: Error in shiftime - Added by joao ferreira over 3 years ago
I think there is still a bug in shifttime...
Just try to subtract 1 min to this file...
Thanks
rain_temp2.nc (282 KB) rain_temp2.nc |
RE: Error in shiftime - Added by Uwe Schulzweida over 3 years ago
Your time variable has the unit minutes and stores the value in 32bit floats.
float XTIME(XTIME) ; XTIME:units = "minutes since 1979-01-01 00:00:00" ;The accuracy (resolution) is therefore only 2 minutes. For a higher accuracy the time variable must be stored in 64bit floats. This can be done with the NCO tool ncap2:
ncap2 -s 'XTIME=double(XTIME)' rain_temp2.nc
RE: Error in shiftime - Added by joao ferreira over 3 years ago
Hi
How do you get 2 min resolution?
The funny thing is that I'm doing 1 min shifttime every hour since 1979 and the first timestep that this happened was 2010-11-24 at 21:00.
I know that the number of minutes is pretty big at this date/time but still very much smaller than 2^32...
RE: Error in shiftime - Added by Uwe Schulzweida over 3 years ago
You are right, my answer was a bit inaccurate. 32-bit floats use 23-bits to store the decimal number. The precision depends on the value of the number. Values greater than 2^24 (16777216) have a fixed interval > 1. See section "Precision limitations" in https://en.wikipedia.org/wiki/Single-precision_floating-point_format.
In your example file the time value (number of minutes) is 16777260 and if you subtract one you get the number 16777259. This number cannot be represented as a 32-bit float and is therefore stored as the value 16777260.