Project

General

Profile

which relative and absolute time units are supported by cdo?

Added by Christopher Danek about 4 years ago

Hi

I could not find an information about the possible relative and absolute time units supported by cdo.

In my particular example, I have a monthly time series starting from ~7000 BP towards today. I would like that `ncview in.nc` shows a nice representation of this time series, without strange gaps on the x-axis due to a time format where jumps occur from e.g. month 12 to month 1.

I tried several things and ended up with setting an absolute time in the format `years as %Y.%f` using `ncap2` from the nco package. This throws the error `ERROR: units attribute "years as %Y.%f" is not listed in UDUnits2 SI system database` but the representation of the time series with ncview is nice, just as I want it (I also could not find a list of supported time formats of nco ncap and/or UDunits).

Now, it seems that cdo does not understand this format, as

$ ncdump -c in.nc
time:units = "years as %Y.%f" 
time: -6995.962366,-6995.876437,-6995.795699,-6995.711111, # <-- correct and works for nice ncview representation

$ cdo showdate in.nc 
-6994-01-01 -6993-01-01 -6992-01-01 -6991-01-01 -6990-01-01 # <-- not correct 

Do you have an idea how to show these negative dates without gaps in ncview in a time format that is correct for cdo (and nco)? Example file attached.

Thanks a lot,
Chris


Replies (3)

RE: which relative and absolute time units are supported by cdo? - Added by Uwe Schulzweida about 4 years ago

Hi Chris,

CDO supports the time units second, hour, day for relative time (<timeunits> since YYYY-MM-DD ...). The absolute time units must be "day as %Y%m%d.%f".
Unfortunately years < -4714 are not supported by ncview for relative time:

Error in utCalendar2: year -6994 is out of range of the Gregorian calendar routines; must have year >= -4714
Cheers,
Uwe

RE: which relative and absolute time units are supported by cdo? - Added by Christopher Danek about 4 years ago

Thanks Uwe.

One follow-up question: is there a cdo command to check whether a file has absolute or relative time units, other than interpreting the `time units` (i.e. "... since ..." versus "... as ...")?

RE: which relative and absolute time units are supported by cdo? - Added by Uwe Schulzweida about 4 years ago

The CDO operator sinfon prints an extra line with the reference time, time units and the used calendar of a relative time.
E.g.:

     RefTime =  1970-01-01 00:00:00  Units = hours  Calendar = proleptic_gregorian

    (1-3/3)