[ncl-talk] problems about longitude tickmarks

Mary Haley haley at ucar.edu
Thu Jul 24 09:13:23 MDT 2014


Hi Li,

When you set "tmXBValues", these values have to be in the same data space
as your X axes.  If the tickmarks are not showing up, then this is always
the first thing I check for. Since I can't run your script, I don't know
what your X axes values look like and whether they are being set correctly.

To debug this,  I suggest temporarily commenting out all the "tm" resource
settings, so you can see what the default axes labels look like. This will
show you the actual range of your X axes.  I would also draw "contour_dbz"
by itself, before you call wrf_overlays, so you can make sure the overlay
isn't the source of the issue:

contour_dbz = wrf_contour(a,wks,dbz_plane(0:zmax_pos,:),opts_dbz)
draw(contour_dbz)
frame(wks)

If you continue to have problems with this, it would help if you could
provide the data files needed for running this script.

Thanks,

--Mary




On Tue, Jul 22, 2014 at 7:02 PM, Li Qi <liqi123sh at qq.com> wrote:

> Hi!
>
> I referred to this example (
> http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/Examples/CROSS_SECTION/wrf_CrossSection4.htm)
> to plot dbz along an arbitrary cross section, but the longitude tick marks
> didn't show up (as shown below).‍
> this is example:
> I don't know how to fix it. Any advice will be greatly appreciated!
>
> Here's my code:
> ; This script will plot data at a set angle through a specified point
> ; This script adds lon/lat info along X-axis
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>
> begin
> ;
> ; The WRF ARW input file.
> ; This needs to have a ".nc" appended, so just do it.
>   a = addfile("./wrfout_d03_2011-06-13_18_00_00.nc","r")
>
>
> ; We generate plots, but what kind do we prefer?
> ; type = "x11"
> ; type = "pdf"
>  type = "eps"
> ; type = "ncgm"
> wks = gsn_open_wks(type,"cross_dbz_lh")
> gsn_define_colormap(wks, "dbz")
>
>
> ; Set some basic resources
> res = True
> res at NoHeaderFooter           = True            ; Switch headers and
> footers off
>
> pltres = True
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> FirstTime = True
> FirstTimeMap = True
> times = wrf_user_list_times(a) ; get times in the file
> ntimes = dimsizes(times) ; number of times in the file
>
> mdims = getfilevardimsizes(a,"P") ; get some dimension sizes for the file
> nd = dimsizes(mdims)
>
> xlat = wrf_user_getvar(a, "XLAT",0)
> xlon = wrf_user_getvar(a, "XLONG",0)
> ter = wrf_user_getvar(a, "HGT",0)
>
> ;---------------------------------------------------------------
>
> do it = 26,28                  ; TIME LOOP
>
> print("Working on time: " + times(it) )
> res at TimeLabel = times(it) ; Set Valid time to use on plots
>
>
>     dbz = wrf_user_getvar(a,(/"dbz","1","1"/),it)
>     dbz at description = ""
>     dbz at units = ""
>
> z = wrf_user_getvar(a, "z",it) ; grid point height
>
> if ( FirstTime ) then ; get height info for labels
> zmin = 0.
> zmax = 15. ; We are only interested in the first zmax km
> nz = floattoint(zmax + 1)
> end if
>
> ;---------------------------------------------------------------
>
> ;crsa=58.10lat,-140.4lon; crsb=59.15lat,-137.15lon;
> lat = (/27.8,  29.3/)
> lon = (/115.7, 119./) ; user specified coordinate pairs
> nm = getind_latlon2d (xlat,xlon, lat, lon) ; return 2d subscripts
>
> angle=0
> plane = new(4,float)
> plane = (/ nm(0,1),nm(0,0), nm(1,1),nm(1,0) /) ; approx. start x;y and end
> x;y point
> opts = True
>
> X_plane = wrf_user_intrp2d(xlon,plane,0,opts)
> X_desc = "longitude"
>
> dbz_plane = wrf_user_intrp3d(dbz,z,"v",plane,0,opts)
>
>
> ; Find the index where 15km is - only need to do this once
> if ( FirstTime ) then
> zz = wrf_user_intrp3d(z,z,"v",plane,0,opts)
> b = ind(zz(:,0) .gt. zmax*1000. )
> zmax_pos = b(0) - 1
> if ( abs(zz(zmax_pos,0)-zmax*1000.) .lt. abs(zz(zmax_pos+1,0)-zmax*1000.)
> ) then
> zspan = b(0) - 1
> else
> zspan = b(0)
> end if
> delete(zz)
> delete(b)
> FirstTime = False
> end if
>
> ; X-axis lables
> dimsX = dimsizes(X_plane)
> xmin = X_plane(0)
> xmax = X_plane(dimsX(0)-1)
> xspan = dimsX(0)-1
> nx = floattoint( (xmax-xmin)/2 + 1)
>
> ; Options for XY Plots
> opts_xy = res
> opts_xy at tiXAxisString = X_desc
> opts_xy at tiYAxisString = "Height (km)"
> opts_xy at cnMissingValPerimOn = True
> opts_xy at cnMissingValFillColor = 0
> opts_xy at cnMissingValFillPattern = 11
> opts_xy at tmXTOn = False
> opts_xy at tmYROn = False
> opts_xy at tmXBMode = "Explicit"
> opts_xy at tmXBValues = fspan(0,xspan,nx) ; Create tick marks
> opts_xy at tmXBLabels = sprintf("%.1f",fspan(xmin,xmax,nx)) ; Create labels
> opts_xy at tmXBLabelFontHeightF = 0.015
> opts_xy at tmYLMode = "Explicit"
> opts_xy at tmYLValues = fspan(0,zspan,nz) ; Create tick marks
> opts_xy at tmYLLabels = sprintf("%.1f",fspan(zmin,zmax,nz)) ; Create labels
> opts_xy at tiXAxisFontHeightF = 0.020
> opts_xy at tiYAxisFontHeightF = 0.020
> opts_xy at tmXBMajorLengthF = 0.02
> opts_xy at tmYLMajorLengthF = 0.02
> opts_xy at tmYLLabelFontHeightF = 0.015
> opts_xy at PlotOrientation = dbz_plane at Orientation
>
>
>
> ;---------------------------------------------------------------
> ; Plotting options for DBZ
> opts_dbz = opts_xy
> opts_dbz at ContourParameters       = (/ 15., 50., 5. /)
> opts_dbz at pmLabelBarOrthogonalPosF = -0.1
> opts_dbz at cnFillOn                = True
> opts_dbz at lbLabelBarOn = False       ; Turn off individual label bars
>
>
>
>
>
>
>
>
> ; Get the contour info for the dbz
> contour_dbz = wrf_contour(a,wks,dbz_plane(0:zmax_pos,:),opts_dbz)
>
>
> ;---------------------------------------------------------------
>
> ; MAKE PLOTS
>
> plot = wrf_overlays(a,wks,(/contour_dbz/),pltres) ; plot x-section
>
>
> ; Delete options and fields, so we don't have carry over
> delete(opts_xy)
> delete(opts_dbz)
>
> delete(dbz_plane)
>
> delete(X_plane)
>
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> FirstTimeMap = False
> end do ; END OF TIME LOOP
>
> end‍
>
> _______________________________________________
> ncl-talk mailing list
> 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/20140724/5c9f3018/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 33EF6D3E at 58B89F56.A209CF53.jpg
Type: image/jpeg
Size: 66821 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140724/5c9f3018/attachment.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BA8DD705 at 58B89F56.A209CF53.jpg
Type: image/jpeg
Size: 16008 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140724/5c9f3018/attachment-0001.jpg 


More information about the ncl-talk mailing list