[ncl-talk] cd_calendar bug

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Wed Feb 17 15:14:08 MST 2016


Sitan,

No, your time values are wrong.  They should start at zero, not 1, for what
you want.

Also please note, a unit string of "months since" is bad practice because
"months" is variable length in the noleap calendar, ranging from 28 to 31
days.  This usage is known to produce inconsistent results between
different calendar libraries.

This might not matter while you are working exclusively inside NCL.  But it
will matter as soon as you start trading data between applications or other
people.

Just use a fixed base unit of time, such as "days since" or "hours since".
Use a calendar routine such as cd_inv_calendar to compute the correct
offsets for the time variable.

--Dave


On Wed, Feb 17, 2016 at 2:55 PM, Sitan Heyl <heylsitan at gmail.com> wrote:

> Hi,
>    when I use below code, I found the return yyyy is wrong. the time value
> is 1, 2, 3... its unit is month since 2006-01, but the return value from
> cd_calendar is 200602, not 200601. Please check cd_calendar function.
>
> Best,
> Yongli
>
>
> f=addfile("rcp45/BCC-CSM1.1/tas_Amon_bcc-csm1-1_rcp45_r1i1p1_200601_210012.nc","r")
> time=f->time
> yyyy=cd_calendar(time,-1)
> print(yyyy(0:13))
>
> ====================
> Variable: yyyy (subsection)
>
> Type: integer
> Total Size: 56 bytes
>             14 values
> Number of Dimensions: 1
> Dimensions and sizes:   [14]
> Coordinates:
> Number Of Attributes: 1
>   calendar :    noleap
> (0)     200602
> (1)     200603
> (2)     200604
> (3)     200605
> (4)     200606
> (5)     200607
> (6)     200608
> (7)     200609
> (8)     200610
> (9)     200611
> (10)    200612
> (11)    200701
> (12)    200702
> (13)    200703
>
> the time variable in file is as below:
>
> float time ( time )
>          units :        month since 2006-01
>          calendar :     noleap
>          axis : T
>          long_name :    time
>          standard_name :        time
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160217/62d79a39/attachment.html 


More information about the ncl-talk mailing list