Project

General

Profile

Dates matlab vs Cdo

Added by Maria Perez about 5 years ago

I have the attached file which I created in matlab from Era-Interim to have 3hourly atmospheric fields in the units that my model wants. The file time is May 2014 every 3 hours.

I'm trying to cut the file in a time range of 2 days (10:12): cdo seldate,${t0:0:4}-${t0:5:2}-${t0:8:2}T00:00:00,${t1:0:4}-${t1:5:2}-${t1:8:2}T21:00:00 ${afil_temp} era_model2.nc

However I get:
cdo seldate,2014-05-10T00:00:00,2014-05-12T21:00:00 /u5/roms/Data_4ROMS_Forcings/Atmospheric/Era_interim/Era_cut_and_every3h/EI_201405.nc era_model2.nc
cdo seldate (Warning): Date between 20140510.0000 and 20140512.2100 not found!

So I try to understand what happenend by runing cdo -infov and I get
-1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter name
1 : 0000-00-00 00:00:00 1 4216 0 : -20.156 -0.88775 16.001 : u10 (m s-1)
2 : 0000-00-00 00:00:00 2 4216 0 : -19.594 -0.88954 15.088 : u10 (m s-1)
3 : 0000-00-00 00:00:00 3 4216 0 : -19.399 -0.80161 13.701 : u10 (m s-1)
4 : 0000-00-00 00:00:00 4 4216 0 : -18.754 -0.84390 12.695 : u10 (m s-1)
5 : 0000-00-00 00:00:00 5 4216 0 : -18.185 -0.92565 12.171 : u10 (m s-1)
6 : 0000-00-00 00:00:00 6 4216 0 : -17.671 -1.0084 12.336 : u10 (m s-1)

How do I fix this? Would be really great to use a simple code like cdo seldate,${t0:0:4}-${t0:5:2}-${t0:8:2}T00:00:00,${t1:0:4}-${t1:5:2}-${t1:8:2}T21:00:00 ${afil_temp} era_model2.n to cut my file
I tried saving the dates in broken variables (year, month, day, hour) to settaxis but still..
Thanks for the help!
M


Replies (3)

RE: Dates matlab vs Cdo - Added by Karin Meier-Fleischer about 5 years ago

Hi Maria,

the variables of your netcdf file do not have any attribute defining the units etc..

ncdump -v time EI_201405.nc

netcdf EI_201405 {
dimensions:
    dim1 = 248 ;
    dim2 = 17 ;
    dim3 = 49 ;
variables:
    double u10\ \(m\ s-1\)(dim3, dim2, dim1) ;
    double v10\ \(m\ s-1\)(dim3, dim2, dim1) ;
    double tp\ \(kg\ m-2\ s-1\)(dim3, dim2, dim1) ;
    double t2m\ \(c\)(dim3, dim2, dim1) ;
    double q2m\ \(kg\ kg-1\)(dim3, dim2, dim1) ;
    double msl\ \(hPa\)(dim3, dim2, dim1) ;
    double tcc\ \(0-1\)(dim3, dim2, dim1) ;
    double time(dim1) ;
    double year(dim1) ;
    double day(dim1) ;
    double month(dim1) ;
    double hour(dim1) ;
    double lon(dim3) ;
    double lat(dim2) ;
data:

 time = 735720, 735720.125, 735720.25, 735720.375, 735720.5, 735720.625, 
    735720.75, 735720.875, 735721, 735721.125, 735721.25, 735721.375, 
    735721.5, 735721.625, 735721.75, 735721.875, 735722, 735722.125, 
...

CDO is not able to identify the time units.

You need time units like "hours since 1850-1-1 00:00:00".

-Karin

RE: Dates matlab vs Cdo - Added by Karin Meier-Fleischer about 5 years ago

You can use CDO's settaxis operator to do this if you know the depending start date.

cdo settaxis,1850-01-01,03:00:00,3hour infile outfile

-Karin

RE: Dates matlab vs Cdo - Added by Maria Perez about 5 years ago

Great help thanks!

    (1-3/3)