[ncl-talk] WRF Time labels - repost

Prasad Kunjeer pskunjeer at gmail.com
Wed Oct 2 09:34:14 MDT 2019


Sir,

I am trying to plot a simple graph from a WRF output. The X axis of the
plot is time  and i want to print the time table for the same. I am using
the function 'time_axis_labels'. I have attached the script:

load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
; This file still has to be loaded manually
load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"

    srcDirName  = "/home/prasad/res/"
    srcFileName = "newdo3.nc"
    srcFilePath =  srcDirName + srcFileName
;---Retrieve either one level, or all levels. Use '-1' for all.
    sfile = addfile(srcFilePath,"r")

    ua   = wrf_user_getvar(sfile,"ua",-1)    ; On mass grid
    va   = wrf_user_getvar(sfile,"va",-1)
    printVarSummary(ua)                      ;
(Time,bottom_top,south_north,west_east)
    printVarSummary(va)                      ;
(Time,bottom_top,south_north,west_east)

    Times        = sfile->Times
    Time_0       = wrf_times_c(Times, 0)

    printVarSummary(Times)
    printVarSummary(Time_0)
    print(Time_0)

    wks = gsn_open_wks("png","time_labels") ; send graphics to PNG file
;--------------------------------------------------
; The time_axis_label function adds additional
; resources to "res" to produce nicely-formatted
; time labels on X axis. This function only works
; if you have a time "units" recognized by the
; cd_calendar function.
;--------------------------------------------------
  pltres = True
  restime           = True
  restick           = True
  restick at ttmFormat = "%N/%D %H:%M"
  time_axis_labels(Time_0,restime,restick)

  contour_vor  = wrf_contour(sfile,wks,ua(:,:,100,100),restime)
  plot = wrf_overlays(sfile,wks,(/contour_vor/),pltres)


The WRF file contains the 25 time steps at 3 hour interval. I have attached
the output of printvarSummary and print of the time varibale.

Variable: Time_0
Type: double
Total Size: 200 bytes
            25 values
Number of Dimensions: 1
Dimensions and sizes: [Time | 25]
Coordinates:
            Time: [   0..  72]
Number Of Attributes: 4
  units : hours since 2018-09-22 12:00:00
  calendar : standard
  long_name : Time
  description : Time

Variable: Time_0
Type: double
Total Size: 200 bytes
            25 values
Number of Dimensions: 1
Dimensions and sizes: [Time | 25]
Coordinates:
            Time: [   0..  72]
Number Of Attributes: 4
  units : hours since 2018-09-22 12:00:00
  calendar : standard
  long_name : Time
  description : Time
(0)   0
(1)   3
(2)   6
(3)   9
(4)  12 etc.

But when I plot the figure, the output takes 1 hour interval rather than 3
hour interval.

The time interval for WRF file is 3 hour and there are 25 time steps. The
first time steps is 22/09/2018 1200. The time should start from 22/09/2018
and end at 25/09/2018 with 25 time steps (22/09/2018 1200, 22/09/2018 1500
etc upto 25/09/2018  1200).  But the graph ends at 23/09/2018 1200 which
correspond to 25 time steps at 1 hour interval. I want graph to end at
25/09/2018 1200.

Please guide in correcting the output of graph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191002/7c79502d/attachment.html>


More information about the ncl-talk mailing list