[ncl-talk] X axis tick mark with Explicit Mode

Prasad Kunjeer pskunjeer at gmail.com
Wed Sep 11 00:29:35 MDT 2019


Sir,
I am using the following script to plot U wind from WRF output file. I am
able to plot the figure, but the X-axis tick marks are not appearing. The
script is follow

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/wrf/WRF_contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"

begin

    fName = "/home/emsuser/Build_WRF/wrfprd/results/do3/t/do3.nc"
    f = addfile(fName, "r")

    U1           = f->U
    U            = wrf_user_unstagger(U1,U1 at stagger)
    lat          = f->XLAT(0,:,0)
    lon          = f->XLONG(0,0,:)
    znu          = f->ZNU(0,:) ; eta levels
    lev          = znu*1000 ; [996.9073..5.045747]
    Time         = chartostring( f->Times(:,:) )

    U!1 = "lev"
    lev at units= "hPa"
    U!0 = "Time"
    U!2 = "lat"
    lat at units = "degree_north"
    U!3 = "lon"
    lon at units = "degree_east"

    U&lev = lev
    U&Time = Time
    U&lat = lat
    U&lon = lon

    wgt   = (/ 1., 3., 4., 3., 1./)                  ; wgts for temporal
smooth
    wgt   = wgt/sum(wgt)                             ; normalize

    lat2d          = f->XLAT(0,:,:)
    lon2d          = f->XLONG(0,:,:)

    slice         = U(lev|:,Time|:,lat|:,lon|:)      ; trick to copy meta
data
    slice1        = U(lev|:,Time|1,lat|84:234,lon|175)
    printVarSummary(slice1)


    wks = gsn_open_wks("png" ,"WRF_U_Wind_New_1")       ; open workstation

;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Create resources for cross section(s)
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   resx = True
   resx at gsnMaximize          = True
   resx at cnFillOn             = True            ; turn on color fill
   resx at cnLinesOn            = False           ; turn lines on/off
; True is default
   resx at cnLineLabelsOn       = False           ; turn line labels on/off
; True is default
   resx at cnFillPalette        = "ncl_default"

   nLabels                   = 8               ; arbitrary
   resx at tmXBMode             = "Explicit"
   resx at tmXBLabels           = new(nLabels,"string")
   resx at tmXBValues           := toint(fspan(84,234,nLabels))
   do i=0,nLabels-1
       x = lon2d(resx at tmXBValues(i),176)
       y = lat2d(resx at tmXBValues(i),176)
       resx at tmXBLabels(i) = sprintf("%5.1f", y)+"~C~"+sprintf("%5.1f", x)
       print(resx at tmXBLabels(i))
   end do

   plot  = gsn_csm_pres_hgt(wks, slice1, resx)

end

I have attached the plot for ready reference. Any help is highly
appreciated.

Regards
प्रसाद कुंजीर/ Prasad Kunjeer
वैज्ञानिक - सी / Scientist - C
केन्द्रीय जल और विद्युत अनुसंधान शाला / Central Water and Power Research
Station
पुणे 411 024/ Pune 411 024
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190911/d54686c6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x_wind.png
Type: image/png
Size: 32484 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190911/d54686c6/attachment.png>


More information about the ncl-talk mailing list