[ncl-talk] Transform "Times" variable in WRF to local time

Alan Brammer abrammer at albany.edu
Wed Sep 21 12:36:03 MDT 2016


http://www.ncl.ucar.edu/Document/Functions/User_contributed/cd_inv_string.shtml

I wrote the above function a while back to better handle string times.   You can download my version (I think it’s the same as the future 6.4.0 version) here:
https://bitbucket.org/a1brammer/ncl_functions/raw/78dea35d95946425e9054cdc9286ae3db88d9585/cd_inv_string.ncl
Save that function, then load at the top of your script from where ever you saved it. 


You need to convert times to a numeric format, apply the offset, then convert back to a nicely formatted string. 
Formats applied below are likely not correct for your version, check the documentation and adjust as necessary. 


e.g. 

time_numeric = cd_inv_string( times(it), “%Y%N%D%H%M”)  ;; will return in hours since 1800-01-01 unless specified otherwise
offset = -8    ; hours
time_numeric = time_numeric - offset

pnlres at txstring = cd_string( time_numeric, “%Y%N%D%H%M” )

HTH,

Alan





##############################
Alan Brammer,
Post-Doc Researcher

Department of Atmospheric and Environmental Sciences,
University at Albany, State University of New York, Albany, NY, 12222
abrammer at albany.edu
##############################

> On 21 Sep 2016, at 12:08, Tabish Ansari <tabishumaransari at gmail.com> wrote:
> 
> Hi
> 
> I'm creating lots of instantaneous panelplots for WRF data with the appropriate time-stamp on each panel. I'm doing this by simply using pnlres at txstring = times(it) where:
> 
> times = wrf_user_getvar(a,"times",-1) 
> and "it" is the standard increment variable in the loop.
> 
> This is the standard method and works fine but the times are obviously in UTC. I want to print local time (in my case UTC + 8) instead, but I'm not sure how to do this in a clean way as times is a string variable.
> 
> Please suggest a nice way to go about this issue.
> 
> Thanks
> 
> Tabish
> 
> Tabish U Ansari
> PhD student, Lancaster Environment Center
> Lancaster Univeristy
> Bailrigg, Lancaster, 
> LA1 4YW, United Kingdom
> _______________________________________________
> 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/20160921/9899158f/attachment.html 


More information about the ncl-talk mailing list