Project

General

Profile

cdo and time unit without reference date

Added by Fredrik Jansson almost 2 years ago

Our DALES LES code by default makes netCDF files where the time unit is just "s". When processing these with cdo, the time coordinates get converted. Would it be possible to just preserve time in seconds?

The example files I posted at https://code.mpimet.mpg.de/boards/1/topics/12914 show this issue too.


input:
time:units = "s" ;
...
time = 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 
    900, 960, 1020, 1080, 1140, 1200, 1260, 1320, 1380, 1440, 1500, 1560, 
    1620, 1680, 1740, 1800 ;

output:
time:units = "seconds since 1-1-1 00:00:00" ;
...
time = -34387140, -34387080, -34387020, -34386960, -34386900, -34386840, 
    -34386780, -34386720, -34386660, -34386600, -34386540, -34386480, 
    -34386420, -34386360, -34386300, -34386240, -34386180, -34386120, 
    -34386060, -34386000, -34385940, -34385880, -34385820, -34385760, 
    -34385700, -34385640, -34385580, -34385520, -34385460, -34385400 ;

We found that specifying a more proper time unit in the input, e.g. time:units = "seconds since 2020-02-01T00:00:00" works very well with cdo. But sometimes the simulations are abstract and don't have any particular starting time.

Best regards,
Fredrik Jansson


Replies (4)

RE: cdo and time unit without reference date - Added by Uwe Schulzweida over 1 year ago

This issue is solved in the latest CDO release 2.1.0, now.

RE: cdo and time unit without reference date - Added by Fredrik Jansson 3 months ago

Hi,

I'm again seeing an issue when processing netCDF files where the unit is just "s". This is with cdo 2.3.0, I also saw it with cdo 2.2.2.

  • If I don't give the -r option, the time unit is preserved but the time values wrap around to 0 every 24h.
  • If I give the -r option, the time unit becomes "seconds since 1-1-1 00:00:00" and the time values become negative numbers (perhaps an integer overflow).

Is there, or could there be, a way to just preserve the time unit and values?

Best regards,
Fredrik Jansson

Example: tmser.305.nc, produced by DALES.

ncdump tmser.305.nc | less

  float time(time) ;
  time:long_name = "Time" ;
  time:units = "s" ;
  time:_FillValue = -999.f ;
...
time = 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 

cdo -f nc4 selvar,cfrac tmser.305.nc out.nc
cdi  warning (split_timevalue): Reset wrong date/time to 0000-00-01 00:00:00!

ncdump out.nc | less

  float time(time) ;
  time:standard_name = "time" ;
  time:long_name = "Time" ;
  time:units = "s" ;
  time:calendar = "proleptic_gregorian" ;
  time:axis = "T" ;
...
time = 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 
# but wraps around at 86400
cdo -f nc4 -r selvar,cfrac tmser.305.nc out2.nc

cdi  warning (split_timevalue): Reset wrong date/time to 0000-00-01 00:00:00!

ncdump out2.nc | less

  double time(time) ;
  time:standard_name = "time" ;
  time:long_name = "Time" ;
  time:calendar = "proleptic_gregorian" ;
  time:axis = "T" ;
  time:units = "seconds since 1-1-1 00:00:00" ;
...
time = -34387140, -34387080, -34387020, -34386960, -34386900, -34386840, 
tmser.305.nc (6.7 MB) tmser.305.nc time series output from DALES

RE: cdo and time unit without reference date - Added by Estanislao Gavilan 3 months ago

Hi Fredrik,

this is a bug. I can also reproduce the same error in 2.3. The command works fine in older versions (1.9.x). Can you open a post in the issue section and assign it to Uwe, please?

RE: cdo and time unit without reference date - Added by Fredrik Jansson 3 months ago

Thank you Estanislao,

I have filed an issue here: #11740

Best,
Fredrik

    (1-4/4)