time format
Added by Liubov Tupikina over 11 years ago
Hi!
There is one question about converting time formats:
I have in netcdf file time format like %Y%M%D and I need to have time in "HOURS since for example 1500.1.1." or from "0000.1.1.".
Are there any possibilities to do it with CDO-functions?
Something like "cdo -r copy net1.nc net2.nc"
or I can do it only with netcdf4-package for python?
p.s.
I searched it in CDO-manual and googled already pretty much, but I didn't found it.
Will be very happy to hear aby feedback!
Thank yoooou!!
Bests!
Liubov
Replies (4)
RE: time format - Added by Jaison-Thomas Ambadan over 11 years ago
Hi,
try "setreftime" operator.
For more info:
cdo -h setreftime
OR
https://code.zmaw.de/embedded/cdo/1.5.9/cdo.html#x1-1490002.6.2
Cheers,
J
RE: time format - Added by Liubov Tupikina over 11 years ago
Thank you very much, Jaison!
Yes, as I've understood correctly, I just need to write smth like
setreftime,date,time[,units] file.nc fileout.nc
But then what do I need to write into "date" and "time" and to [units]?
Maybe first I need to use this settunits to define relative time axis?
Danke im Voraus!)
Liuba
RE: time format - Added by Jaison-Thomas Ambadan over 11 years ago
But then what do I need to write into "date" and "time" and to [units]?
It depends on what you want:
From the docs:
_date_ STRING Date (format: YYYY-MM-DD) _time_ STRING Time (format: hh:mm:ss) _units_ STRING Base units of the time axis (seconds, minutes, hours, days, months, years)
just try it ...
Cheers,
J
RE: time format - Added by Liubov Tupikina over 11 years ago
Dear Jaison!
Thank you very-very much for quick answer!
I tried it and it works:
Just I had:
double time(time) ;
time:standard_name = "time" ;
time:units = "day as %Y%m%d.%f" ;
time:calendar = "proleptic_gregorian" ;
But after I changed settaxis and setunits to "hours"
I have:
double time(time) ;
time:standard_name = "time" ;
time:units = "hours since 1515-01-01 18:00:00" ;
time:calendar = "proleptic_gregorian"
So, I hope, it means, that now in my new .nc file I have time in hours since 1515-01-01,
so just numbers, not in a date-format.
p.s. am I right?)