NCL use the units "hours since 1800-01-01 00:00" for all grib files.
The units reference start time is entirely arbitrary.
f = addfile("foo.grb", "r")
time = f->initial_time0_hours
date0 = cd_calendar(time,0)
print(date0)
date3 = cd_calendar(time, -3)
print(date3)
will return the actual dates.
Also, see
times = f->initial_time0 ; string: mm/dd/yyyy (hh:mm)
timef = f->initial_time0_encoded ; double: yyyymmddhh.hh_frac
print(times+" "+timef)
===
My *speculation* is that the CDO use the 1st time on the file
as the reference start time. Again ... this is arbitrary.
===
An advantage of NCL's approach is that if you have multiple
grib files with different start times,
f1 =
f2 =
f3 =
NCL's time variable is consistent. If the initial time is
relative to the 1st time on the different files, they will
all start at 0.
===
If you want you could use
TIME = cd_calendar(time, 0)
year = tointeger(TIME(:,0))
month = tointeger(TIME(:,1))
day = tointeger(TIME(:,2))
hour = tointeger(TIME(:,3))
minute = tointeger(TIME(:,4))
second = TIME(:,5)
tunits_new = "hours since "+year(0,0) \
+ "-"+sprinti("%0.2i%,month(0,0)) \
+ "-"+sprinti("%0.2i%,day(0,0)) \
+ "-"+sprinti("%0.2i%,hour(0,0)) + "00:00"
time_new = cd_inv_calendar(year,month,day,hour,minute,second \
,tunits_new, 0)
print(time_new)
On 4/25/13 6:30 AM, Marston Johnston wrote:
> Hi,
>
> I'm converting some grib files from my regional climate model. There seem
> to be a bug in NCL's translation of the time array as it give the incorrect
> reference date. Here's a
> CDO sinfo output from the grib file:
>
> File format: GRIB
> -1 : Institut Source Ttype Levels Num Gridsize Num Dtype :
> Parameter ID
> 1 : unknown unknown instant 40 1 42160 1 P12 : 71.1
>
> 2 : unknown unknown instant 40 1 42160 1 P12 : 72.1
>
> 3 : unknown unknown instant 40 1 42160 1 P12 : 76.1
>
> 4 : unknown unknown instant 40 1 42160 1 P12 : 11.1
>
> Grid coordinates :
> 1 : lonlat > size : dim = 42160 nx = 310 ny = 136
> rlon : first = 142.24 last = 278.2 inc =
> 0.44 degrees
> rlat : first = -29.7 last = 29.7 inc = 0.44
> degrees
> northpole : lon = -180 lat = 90
> Vertical coordinates :
> 1 : hybrid level : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
> 17 18 19
> 20 21 22 23 24 25 26 27 28 29 30 31 32
> 33 34 35
> 36 37 38 39 40
> Time coordinate : unlimited steps
> RefTime = 2007-01-01 00:00:00 Units = hours Calendar =
> proleptic_gregorian
> YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD
> hh:mm:ss
> 2007-01-01 00:00:00 2007-01-01 03:00:00 2007-01-01 06:00:00 2007-01-01
> 09:00:00
>
> snip....
>
> But NCL interprets the file with the following output:
>
> double initial_time0_hours ( initial_time0_hours )
> long_name : initial time
> units : hours since 1800-01-01 00:00
>
> The year is off by 207 years. This is probably not a bug in NCL or maybe it
> is.
>
> I used the script "Efficient approach":
> http://www.ncl.ucar.edu/Applications/gribeff.shtml
>
> /Marston
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Apr 25 07:39:51 2013
This archive was generated by hypermail 2.1.8 : Fri Apr 26 2013 - 17:10:25 MDT