[ncl-talk] Sub: cd_calendar help

Alan Brammer abrammer at albany.edu
Sun Oct 8 19:09:46 MDT 2017


Forecast time in your file will be hours since simulation started.  e.g.
0,6,12,18.  Without any guidance the cd_ routines will think this is hours
since 1979-01-01.

I don't want to download a 300MB file just to see if there is another time
variable inside, so working with what I can see in the email, you can grab
the initialisation date from the file name using cd_inv_string() incldued
in 6.4.0 http://www.ncl.ucar.edu/Document/Functions/User_contri
buted/cd_inv_string.shtml


load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_inv_string.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"

fname="tmp2m.2002050100.time.nc"
a = addfile(fname, "r")
init_time = cd_inv_string(fname, "tmp2m.%Y%N%D%H.time.nc" )

;  Then either add the forecast times to the initial_time, or set the
calendar for the forecast times so that it is appropriate.

forecast_hours =  a->forecast_time0
forecast_hours at units = cd_string(init_time, "hours since %Y-%N-%D %H:%M")

total_time = init_time + forecast_hours
total_time at units = init_time at units



Good luck

Alan




On Sun, Oct 8, 2017 at 3:48 PM, dale zuri <dalezuri at gmail.com> wrote:

> Hi ,
> This result is almost similar to cd_calendar result.
> (0)    Forecast for 1 Jan. 1979 at 06:00
> (1)    Forecast for 1 Jan. 1979 at 12:00
> (2)    Forecast for 1 Jan. 1979 at 18:00
> (3)    Forecast for 2 Jan. 1979 at 00:00
> (4)    Forecast for 2 Jan. 1979 at 06:00
> I am confused with 1979 year .
> But the initial_time :    05/31/1995 (00:00)
>
> Thanks
>
> DZ
>
> On Sun, Oct 8, 2017 at 11:24 AM, Guido Cioni <guidocioni at gmail.com> wrote:
>
>> You need this in your preamble:
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl”
>>
>>
>>
>> Il giorno 08 ott 2017, alle ore 21:23, dale zuri <dalezuri at gmail.com> ha
>> scritto:
>>
>> Hi ,
>> Thanks for your reply. I need to create a time array with the actual date
>> associated with each forecast time.
>> fatal:Undefined identifier: (cd_string) is undefined, can't continue error
>> t=cd_string(time, "%H:%M")
>>
>> DZ
>>
>> On Sun, Oct 8, 2017 at 9:32 AM, Guido Cioni <guidocioni at gmail.com> wrote:
>>
>>> You should really take a look at the starting guide of NCL and to the
>>> documentation of the individual functions before posting questions here.
>>>
>>> I’ve just checked your file and it seems that the time variable has the
>>> right attributes.
>>>
>>> Something like this should work (NOT TESTED)
>>>
>>> a=addfile("tmp2m.1995053100.time.grb2","r”)
>>> time=a->forecast_time0
>>>
>>> date_title= "Forecast for "+cd_string(time, "%d %c. %Y")+" at "+
>>> cd_string(time, "%H:%M")+" UTC”
>>>
>>> Cheers
>>>
>>> Il giorno 08 ott 2017, alle ore 11:40, dale zuri <dalezuri at gmail.com>
>>> ha scritto:
>>>
>>> date = cd_calendar(r, -3)
>>>
>>>
>>>
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171008/301a2c0f/attachment.html>


More information about the ncl-talk mailing list