[ncl-talk] Struggle to convert WRF times to UTC for simple XY plot

Nicholas Thomas Luchetti Nicholas.Luchetti at colorado.edu
Wed Jun 27 11:18:51 MDT 2018


Mary,

Thanks so much for this quick fix! I can't believe i missed the library
load for this function! That did the trick!

Many thanks,


Nick Luchetti

On Tue, Jun 26, 2018 at 9:14 PM, Mary Haley <haley at ucar.edu> wrote:

> Hi Nick,
>
> If you read the documentation for time_axis_labels:
>
> http://www.ncl.ucar.edu/Document/Functions/User_
> contributed/time_axis_labels.shtml
>
> You'll see that you have to load a script to get access to this function:
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl
> ​"
>
> Here's a simple script that uses this function with WRF data. Note that I
> also used wrf_times_c to convert from the WRF Times array to a numeric
> array of "hours since":
>>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
>
> fname = "../cdf_files/wrfout_d01_000000_25time.nc
> <http://secure-web.cisco.com/1HtojnyvB7YZD0tepNfHd-hJsQirLkMCCiIL81zZ3bx_QKti8TlWx5pBJbZgmavvm1I0LQLElAzNVVqso5S1cnHUUCrWzCWAIQF2s05SlezEqQlWDydso5cDFnSIRuJxKzJGMlXQy-CFpgsn0Ojzv-T4MOenHCQP1wPMlEIuLIJtXhe4lBepYM2VgrzcGGSnseVyDiWutwuUoC0Ux_iKSjiuwl_Bm6k_OgJHiyYyWO8M8YlurBmvMze6zuC-07pfsHdmHh98QScf3zK9HUTlCYdavppnWGm1ebdQqpmo6Fdgg905caEXmlPV9XXaa7-BzewasCSFXFeFDV8hjosxBfAmpb_UN_eq4Z47chXTOMNv7uiSiK6kuxt6iRXCZcZE3dc7XjnorBIi9mBJ9oYL51t4rdzo9sfQ0MsWRRdhq6T8hqFmlZ5Qk7ghPF2oNv6r7/http%3A%2F%2Fwrfout_d01_000000_25time.nc>
> "
>
> ;---Convert WRF times to an "hours since" format
>
> f = addfile(fname,"r")
> Times = f->Times            ; Times(Time, DateStrLen)(type character)
>
>
> Time_1 = wrf_times_c( Times, 1 )    ; "hours since 1901-01-01 00:00:00"
> ;---Read some variable that has Time as a dimension
>   pres = f->P
> printVarSummary(pres)
>
> ;---Set some
> ​plot options​
>>
>
> res = True
> res at xyLineColor      = "NavyBlue"
> res at xyLineThicknessF = 2.0
>
> ​;--Use time_axis_labels for nice time labels​
> restick           = True
> restick at ttmFormat = "%N/%D~C~%H:%M"
> restick at ttmAxis   = "XB"
> time_axis_labels( Time_1,  res, restick )
>
> wks = gsn_open_wks("x11","wrf_times")
> plot = gsn_csm_xy( wks, Time_1, pres(:,0,0,0), res )
>
>
> On Mon, Jun 25, 2018 at 12:44 PM, Nicholas Thomas Luchetti <
> Nicholas.Luchetti at colorado.edu> wrote:
>
>> Hi all,
>>
>> I am struggling to convert my x-axis time labels to UTC when plotting WRF
>> output...
>>
>> I've tried following the time_labels_3.ncl example: https://www.ncl.ucar.
>> edu/Applications/Scripts/time_labels_3.ncl
>>
>> but can't seem to get it to even recognize the time_axis_labels function.
>> It gives an error (screenshot attached) before even starting the script...
>>
>> Additionally, my WRF simulations output every 5 minutes, so when I use
>> the wrf_times_c function for hours since the beginning of the simulation,
>> the times are listed as decimals (see attached screenshot)... Could this be
>> an issue considering the example script displays a perfect 60 minute output
>> from a WRF simulation?
>>
>> I've also attached my script. Does anyone know of a quick fix for this?
>> Or do I need to figure out a better way to convert the times to a useable
>> format?
>>
>> Thanks,
>>
>> Nick Luchetti
>>
>> --
>> Nicholas Luchetti
>> Graduate Student
>> Department of Atmospheric and Oceanic Sciences (ATOC)
>> CU Boulder
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>


-- 
Nicholas Luchetti
Graduate Student
Department of Atmospheric and Oceanic Sciences (ATOC)
CU Boulder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180627/a32ff8ed/attachment.html>


More information about the ncl-talk mailing list