Project

General

Profile

ow to set the time variables from 0,1,2,3,4,5 into yyyy-mm-dd, hh-mm-ss

Added by Sam United almost 6 years ago

Hi all,

Now I have a nc file with monthly data and the 'time' variable is: "time= 0,1,2,3,4,5 "but I want to change it into a nc file and "time = 1997-01-01 00:00:00, 1997-02-01 00:00:00, 1997-03-01 00:00:00, 1997-01-04 00:00:00, 1997-05-01 00:00:00". How I can do this. perhaps using setdate? but now sure.
Cheers
Sam


Replies (6)

RE: ow to set the time variables from 0,1,2,3,4,5 into yyyy-mm-dd, hh-mm-ss - Added by Ralf Mueller almost 6 years ago

Hi Sam!

check the operator settaxis!

 cdo -settaxis,1997-01-01,00:00:00,1months <ifile> <ofile>
should do it

cheers
ralf

RE: ow to set the time variables from 0,1,2,3,4,5 into yyyy-mm-dd, hh-mm-ss - Added by Ralf Mueller almost 6 years ago

and please update CDO! 1.6.3 is already petrified .... ;-)

RE: ow to set the time variables from 0,1,2,3,4,5 into yyyy-mm-dd, hh-mm-ss - Added by Sam United almost 6 years ago

Hi Ralf,

Thank you for your help, but unfortunately, it failed to do that although the unit of 'time' is changed into 'months from 1997.01.01.00.00.00', the data of 'time' is still like 0,1,2,3,4,... And the picture of the output file is as attachment (file is too large to upload)

Cheers
Sam

RE: ow to set the time variables from 0,1,2,3,4,5 into yyyy-mm-dd, hh-mm-ss - Added by Ralf Mueller almost 6 years ago

and these values are correct. 0,1,2 ... months since 1970-01-01. cf convention does not allow to save time as a string afaik. just like any other variable, time valuea have to be correctly interpreted according to thwir given unit. please, check the file with the infov operator.

RE: ow to set the time variables from 0,1,2,3,4,5 into yyyy-mm-dd, hh-mm-ss - Added by Sam United almost 6 years ago

Hi Ralf,

Thanks, yes the nc file is created by python, are there some ways now to help me to do that?

RE: ow to set the time variables from 0,1,2,3,4,5 into yyyy-mm-dd, hh-mm-ss - Added by Ralf Mueller almost 6 years ago

could you upload the file?

as I said: I might be technically possible to save timesteps as strings ("1997.01.01.00.00.00"), but I really dont recommend that since

hth
ralf

    (1-6/6)