[ncl-talk] Problem with "cd_calendar"
Alan Brammer
abrammer at albany.edu
Thu Nov 12 10:04:12 MST 2015
I sent a function I wrote to do this kind of parsing to Mary yesterday. Had dropped you off the reply though.
This could replace the multiple lines of string parsing you have with a single function.
I’ve used this function fairly extensively and haven’t run into any issues recently.
Save the attached .ncl file somewhere on your system and use the load statement at the top of the script.
e.g.
load “./cd_inv_string.ncl”
time = "10/05/2014 06:00:00"
time_format = "%N/%D/%Y %H:%M:%S” ;;; same codes as cd_string
time_format at units = "minutes since 2014-10-05 06:00:00”
date = cd_inv_string(time, time_format)
print(cd_calendar(date,0)) ; check that it actually worked properly
Good luck,
Alan.
p.s. I’m not an NCL developer and can not support functions in any official manner. This should work but your luck with it may be different.
> On 12 Nov 2015, at 07:39, Amadou Coulibaly <mpapin24 at gmail.com> wrote:
>
> Hi Mary,
>
> After persing into my time array, I got year, month, day, hour, minute. But what about second since it is not appearing in my timestamp, which is in format mm/dd/yyyy hh:MM? And how to write time at units since my timestamp starts on 10/05/2014 06:00:00? And after persing my time I converted year, day, month, hour, minute into interger as:
>
> month = str_get_field(time,1,"/")
> day = str_get_field(time,2,"/")
> year = str_get_field(time,3,"/ ")
> hour = str_get_field(time,2," :")
> minute = str_get_field(time,3," :")
> second = str_get_field(time,3," :") ????????
>
> yyyy = stringtointeger(year)
> mm = stringtointeger(month)
> dd = stringtointeger(day)
> hh = stringtointeger(hour)
> MM = stringtointeger(minute)
> ss = stringtointeger(second)???????
>
> time at units = "hour since 2014-10-05 06:00:00" ????????
>
> date = cd_inv_calendar(yyyy, mm, dd, hh, MM, ss, time at units, 0)
>
> After this, my variable "date" is just printing out missing values. What's wrong with that?
>
> Best regards
>
>
> On 11 November 2015 at 17:01, Mary Haley <haley at ucar.edu <mailto:haley at ucar.edu>> wrote:
> You need to use cd_inv_calendar:
>
> http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_inv_calendar.shtml <http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_inv_calendar.shtml>
>
> Some of the examples on the above page should help you.
>
> To get the required year, month, day, hour, minutes, and seconds arrays, you will need to parse the "time" array in the same fashion that you parsed the CSV file.
>
> For example:
>
> month = str_get_field(time,1,"/")
> day = str_get_field(time,2,"/")
> year = str_get_field(time,3,"/ ") ; note the use of both '/' and ' ' as delimiters
>
> --Mary
>
> On Wed, Nov 11, 2015 at 8:25 AM, Amadou Coulibaly <mpapin24 at gmail.com <mailto:mpapin24 at gmail.com>> wrote:
> Dear NCL users,
>
> I am trying to use cd_calendar for my dataset to be able to plot daily timeseries. But I have a problem converting my Timstamp, which is in the format 10/05/2014 06:00:00, mm/dd/yyyy hh:MM:ss. I want to use it in the format time at units = "minuts since 2014-10-05 06:00:00" with dates = cd_calendar(Time, 0) as specifying in my script (readcsv.ncl). Please, find attached a sample of my data and script.
>
>
> How to solve this issue?
>
> Best regards
>
> --
> COULIBALY AMADOU
> PhD Student on West African Climate System (WACS)
> FUTA - Federal University of Technology of Akure, Nigeria
>
> Visiting Student - University of Cologne, Germany
> Institute of Geophysics and Meteorology
> Pohligstr. 3 / Office 3.102
> D-50969 Köln
>
> Project: WASCAL (West African Science Service Centre on Climate Change and Adapted Land Use)
> Phone:(+234) 810 795 2836 <tel:%28%2B234%29%20810%20795%202836> /(+223) 65 67 27 57 <tel:%28%2B223%29%2065%2067%2027%2057> /(+226) 64 57 37 27 <tel:%28%2B226%29%2064%2057%2037%2027> /+49 15218352574 <tel:%2B49%2015218352574>
>
> E-mail: mpapin24 at gmail.com <mailto:mpapin24 at gmail.com> / coulibalya68 at yahoo.com <mailto:coulibalya68 at yahoo.com>
>
> "The time is always right to do right": Nelson Mandela
>
> "Character is like a tree and reputation like a shadow. The shadow is what we think of it; the tree is the real thing" : Abraham Lincoln
>
> "Do what you can, with what you have, where you are" Theodore Roosevelt
>
>
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
>
>
>
> --
> COULIBALY AMADOU
> PhD Student on West African Climate System (WACS)
> FUTA - Federal University of Technology of Akure, Nigeria
>
> Visiting Student - University of Cologne, Germany
> Institute of Geophysics and Meteorology
> Pohligstr. 3 / Office 3.102
> D-50969 Köln
>
> Project: WASCAL (West African Science Service Centre on Climate Change and Adapted Land Use)
> Phone:(+234) 810 795 2836 /(+223) 65 67 27 57 /(+226) 64 57 37 27 /+49 15218352574
>
> E-mail: mpapin24 at gmail.com <mailto:mpapin24 at gmail.com> / coulibalya68 at yahoo.com <mailto:coulibalya68 at yahoo.com>
>
> "The time is always right to do right": Nelson Mandela
>
> "Character is like a tree and reputation like a shadow. The shadow is what we think of it; the tree is the real thing" : Abraham Lincoln
>
> "Do what you can, with what you have, where you are" Theodore Roosevelt
>
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151112/707724db/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cd_inv_string.ncl
Type: application/octet-stream
Size: 4268 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151112/707724db/attachment.obj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151112/707724db/attachment-0001.html
More information about the ncl-talk
mailing list