CDO changing date/time format
Added by James Doss-Gollin over 2 years ago
I'm new to CDO, coming to it from the xarray/python world. I am using CDO to convert a grib2 file to netcdf. An example of the grib2 file I wish to convert is available at https://mtarchive.geol.iastate.edu/2017/08/05/mrms/ncep/GaugeCorr_QPE_01H/GaugeCorr_QPE_01H_00.00_20170805-170000.grib2.gz.
If I download this data and read it in using xarray, it has no trouble recognizing that the data is a datetime, and it gets everything right
numpy.datetime64('2017-08-25T21:00:00.000000000')
However, when I use CDO to convert to netcdf
"cdo -f nc4 -z zip_1 setctomiss,-3 -copy {input} {output}"
it converts the time to a different format
<xarray.DataArray 'time' (time: 1)>
array([20170821.333333])
Coordinates:
* time (time) float64 2.017e+07
Attributes:
standard_name: time
units: day as %Y%m%d.%f
calendar: proleptic_gregorian
axis: T
is there a way to make CDO leave the time variable alone?
Replies (2)
RE: CDO changing date/time format - Added by Karin Meier-Fleischer over 2 years ago
Hi James,
use the -r option to generate a relative time axis.
cdo -r -f nc4 -z zip_1 setctomiss,-3 infile outfile
-Karin
RE: CDO changing date/time format - Added by James Doss-Gollin over 2 years ago
Thank you Karin
I'd seen the `-r` option but didn't realize it would generate the relative time axis in this manner.
Best,
James