[ncl-talk] time_to_newtime vs. cd_convert

Alan Brammer abrammer at albany.edu
Tue Oct 7 07:20:38 MDT 2014


I agree it seems like they could be combined and if one wants to
change/keep the calendar it could be attached to the units string as an
attribute. As neither version handles this at the moment it shouldn't
affect compatibility.

Alan.
 On 7 Oct 2014 06:59, "Carl Schreck" <cjschrec at ncsu.edu> wrote:

> Related question... What's the difference between cd_convert and
> time_to_newtime?
>
> Looking at the code, I think they just handle the metadata a little
> differently. Notably, time_to_newtime updates the coordinate variable
> (something I forgot to do when I originally wrote ut_convert).
>
> Perhaps they should be reconciled into one function and the other one
> marked as deprecated or as an alias on the website?
>
>     Carl
>
> On Mon, Oct 6, 2014 at 10:55 PM, Lam Hoang <lamhpvn at gmail.com> wrote:
>
>> Hi Alan,
>> I'm using NCL 6.1.2 and your code works perfectly.
>>
>> Variable: t
>> Type: double
>> Total Size: 20440 bytes
>>             2555 values
>> Number of Dimensions: 1
>> Dimensions and sizes:    [time | 2555]
>> Coordinates:
>>             time: [ 0.5..2554.5]
>> Number Of Attributes: 6
>>   bounds :    time_bnds
>>   units :    days since 2006-01-01 00:00:00
>>   calendar :    noleap
>>   axis :    T
>>   long_name :    time
>>   standard_name :    time
>>
>> Variable: t
>> Type: double
>> Total Size: 20440 bytes
>>             2555 values
>> Number of Dimensions: 1
>> Dimensions and sizes:    [time | 2555]
>> Coordinates:
>>             time: [56940.5..59494.5]
>> Number Of Attributes: 6
>>   calendar :    noleap
>>   units :    days since 1850-01-01 00:00:00
>>   bounds :    time_bnds
>>   axis :    T
>>   long_name :    time
>>   standard_name :    time
>>
>> Best regards,
>> Lam
>>
>> On Tue, Oct 7, 2014 at 5:07 AM, Alan Brammer <abrammer at albany.edu> wrote:
>>
>>> What version of ncl are you using? I just tested a similar few lines of
>>> code in 6.1.1 and 6.2.0 and they both copied the calendar attribute as
>>> expected. Also have you tried cd_convert() seems to do the same thing?
>>>
>>> However in these tests and looking around I have a strong suspicion
>>> there is a significant bug in this function.  In that the code copies the
>>> calendar attribute but does not actually make use of it and thus returns
>>> the wrong answer disguised as the correct one.
>>>
>>>
>>> Attached is my edited code.  load this below a load "....contibuted.ncl"
>>> line if you have one and this version of the code will replace the stock
>>> version.  A developer will hopefully weigh in with more insight in this.
>>>
>>>
>>> Good luck,
>>>
>>> Alan
>>>
>>>
>>>
>>>
>>>
>>> On Fri, Oct 3, 2014 at 10:08 PM, Lam Hoang <lamhpvn at gmail.com> wrote:
>>>
>>>> Dear NCL supporting team,
>>>> I want to convert the time units from a CMIP5 model to make them unique.
>>>> I try to use time_to_newtime function but unfortunately after convert
>>>> the time units, the calendar attribute changes to "gregorian" as well.
>>>> What should I do if I want to keep the calendar attribute as the
>>>> original time variable?
>>>>
>>>> Regards,
>>>> Lam
>>>>
>>>>
>>>> f =
>>>> addfile("./oldtime_psl_day_NorESM1-M_historicalExt_r3i1p1_20060101-20121231.nc","r")
>>>> temp = f->psl
>>>> t = f->time
>>>>
>>>> printVarSummary(t)
>>>>
>>>> *** Variable: t
>>>>
>>>> *** Type: double
>>>>
>>>> *** Total Size: 20440 bytes
>>>>
>>>> ***             2555 values
>>>>
>>>> *** Number of Dimensions: 1
>>>>
>>>> *** Dimensions and sizes: [time | 2555]
>>>>
>>>> *** Coordinates:
>>>>
>>>> ***             time: [ 0.5..2554.5]
>>>>
>>>> *** Number Of Attributes: 6
>>>>
>>>> ***   bounds : time_bnds
>>>>
>>>> ***   units : days since 2006-01-01 00:00:00
>>>>
>>>> ***   calendar : noleap
>>>>
>>>> ***   axis : T
>>>>
>>>> ***   long_name : time
>>>>
>>>> ***   standard_name : time
>>>>
>>>> t = time_to_newtime(t, "days since 1850-01-01 00:00:00")
>>>>
>>>> printVarSummary(t)
>>>>
>>>> *** Variable: t
>>>>
>>>> *** Type: double
>>>>
>>>> *** Total Size: 20440 bytes
>>>>
>>>> ***             2555 values
>>>>
>>>> *** Number of Dimensions: 1
>>>>
>>>> *** Dimensions and sizes: [time | 2555]
>>>>
>>>> *** Coordinates:
>>>>
>>>> ***             time: [56978.5..59534.5]
>>>>
>>>> *** Number Of Attributes: 6
>>>>
>>>> ***   calendar : gregorian
>>>>
>>>> ***   units : days since 1850-01-01 00:00:00
>>>>
>>>> ***   bounds : time_bnds
>>>>
>>>> ***   axis : T
>>>>
>>>> ***   long_name : time
>>>>
>>>> ***   standard_name : time
>>>>
>>>>
>>>> --
>>>> Hoang Phuc Lam
>>>> Viet Nam National Center of Hydro-Meteorology Forecasting
>>>> National Hydro-Meteorological Services of Vietnam
>>>> Mob: +84 12 1616 5258
>>>> Tel:   +844 38247002
>>>> Fax:  +844 38254278
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>>
>>>
>>
>>
>> --
>> Hoang Phuc Lam
>> Viet Nam National Center of Hydro-Meteorology Forecasting
>> National Hydro-Meteorological Services of Vietnam
>> Mob: +84 12 1616 5258
>> Tel:   +844 38247002
>> Fax:  +844 38254278
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
>
> --
>
> <http://www.cicsnc.org/>
> <http://www.researcherid.com/rid/B-8711-2011>
> * Cyclone <http://www.cyclonecenter.org/>*Center.org
> <http://www.cyclonecenter.org/>  *Carl J. Schreck III, PhD*
> *Research Associate*
> Cooperative Institute for Climate and Satellites NC
> <http://www.cicsnc.org/>
> North Carolina State University <http://ncsu.edu/>
> NOAA's National Climatic Data Center <http://ncdc.noaa.gov/>
> 151 Patton Ave, Asheville, NC 28801
> e: cjschrec at ncsu.edu
> o: +1 828 257 3140
> Publications
> <http://scholar.google.com/citations?hl=en&user=th8ONEcAAAAJ&view_op=list_works&sortby=pubdate>
> monitor.cicsnc.org/mjo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141007/49c42557/attachment.html 


More information about the ncl-talk mailing list