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

Mary Haley haley at ucar.edu
Tue Jun 26 21:14:32 MDT 2018


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"

;---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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180626/37ee3f1e/attachment.html>


More information about the ncl-talk mailing list