[ncl-talk] Unable to set explicit levels on contour plot

Nicholas Thomas Luchetti Nicholas.Luchetti at colorado.edu
Thu Mar 15 15:16:49 MDT 2018


Hi all,

I am trying to set explicit contour levels on a vertical cross-section plot
however with no luck....

I've tried both "ExplicitLevels" and "ManualLevels"  settings but neither
seem to work.

I've looked at all sorts of examples online but can't seem to see why mine
won't work

I've attached my script.  As well as two plots from 2 different WRF runs...
I want to be able to compare these, but if I can't set the scale the same
then it's difficult to compare....

Does anyone have any idea as to why I can not set these levels?

Thanks!

Nick Luchetti

-- 
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/20180315/b5a5b41b/attachment.html>
-------------- next part --------------

;----------------------------------------------------------------------
; WRF_cn_4.ncl
;
; Concepts illustrated:
;   - Plotting WRF data
;   - Plotting a cross section
;----------------------------------------------------------------------
; WRF: time-z cross section.
;----------------------------------------------------------------------
; These files are loaded by default in NCL V6.2.0 and newer
 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/WRFUserARW.ncl"

 load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"

begin
;---Open file; substitute your own WRF output file here
  f = addfile ("/Users/nicholasluchetti/Build_WRF/WRFV3/test/em_quarter_ss/wrfout_d01_control.nc","r")
;  f = addfile("/Users/nicholasluchetti/Build_WRF/WRFV3/test/em_quarter_ss/wrfout_d01_simulation_1.nc","r")

;  f  = addfile("/Users/nicholasluchetti/Build_WRF/WRFV3/test/em_quarter_ss/wrfout_d01_simulation_4.nc","r")
;  f = addfile("/Users/nicholasluchetti/Build_WRF/WRFV3/test/em_quarter_ss/wrfout_d01_simulation_3.nc","r")
; f  = addfile("/Users/nicholasluchetti/Build_WRF/WRFV3/test/em_quarter_ss/wrfout_d01_simulation_2.nc","r")

;
; Read character variable Times
; Convert to units of "hours since" for plotting purposes
;
  times = f->Times
  Time   = wrf_times_c(f->Times, 0)  ; convert to "hours since"
  print(Time)
;
; Read W(bottom_top_stag,west_east) at lat
;    index 15, lon index nlon.
; Read associated levels and longitudes
;
  nlat = 85
  nlon = 120
  w       = f->W(:,:,nlat,nlon)             ; W(Time,bottom_top_stag)
  znw     = f->ZNW(0,:)                 ; znw(bottom_top_stag)

print("test3")

  printVarSummary(w)
  w&Time := Time
  printVarSummary(w)
  print(w&Time)

print("test4")

;---Use simple array syntax [like f90] to change units
  w         = w                     ; for demo change units
  w at units   = "m/s"

printVarSummary(w)
printMinMax(w,0)

;---Add/change meta data to conform to netCDF convention standards
  w!0       = "Time"
  w&Time    =  Time
  w!1       = "lev"                     ; name dimensions
  w&lev     =  znw                      ; assign values to named dimensions


;---For plot purposes only, read the specific lat/lon point
  lat       = f->XLAT(0,nlat,nlon)
  lon       = f->XLONG(0,nlat,nlon)
;
; create plots
; (1) A "BlWhRe" is often selected when plus/minus are of interest
; (2) The "symMinMaxPlt" procedure determines contour limits
;     that are symmetric.
; (3) Use the "sprintf" function to format the title
; (4) Because the rightmost dimension will become the "x" axis
;     use NCL's "dimension reordering" to reshape
;
 ; wks = gsn_open_wks("pdf","plt_vv_vertical_sim2.pdf")
  wks = gsn_open_wks("pdf","plt_vv_vertical_control.pdf")
 ; wks = gsn_open_wks("pdf","plt_vv_vertical_sim3.pdf")
;  wks = gsn_open_wks("pdf","plt_vv_vertical_sim1.pdf")
; wks = gsn_open_wks("pdf","plt_vv_vertical_sim4.pdf")
  gsn_define_colormap(wks,"MPL_PRGn")


res                       = True            ; plot mods desired
  ;res at gsnMaximize           = True            ; maximize plot size
  res at cnLevelSelectionMode = "ManualLevels"     ; manually set the contour levels with the following 3 resources
  res at cnMinLevelValF  = -10.                    ; set the minimum contour level
  res at cnMaxLevelValF  = 10.                     ; set the maximum contour level
  res at cnLevelSpacingF = 1.                      ; set the interval between contours

  ;res at cnLevelSelectionMode = "ExplicitLevels"   ; set explicit contour levels
  ;res at cnLevels    = (/ -12, -10.,-8.,-6.,-4.,-2.,-1.,1.,2.,4.,6.,8.,10.,12./)   ; set levels

  res at cnFillOn            =True
  res at cnLinesOn             = False           ; turn off contour lines
  res at lbOrientation         = "vertical"      ; vertical label bar

  res at trYReverse            = True            ; reverse y axis
  res at tiXAxisString         = Time at units      ; label bottom axis with units attribute
  symMinMaxPlt(w, 14, False, res)             ; contributed.ncl

  res at tiMainString          = sprintf("%4.2f", nlat)+ " " \
                            + sprintf("%4.2f", fabs(nlon))
  print("test")
  plot                      = gsn_csm_contour(wks,w(lev|:,Time|:),res)
end
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plt_vv_vertical_control.pdf
Type: application/pdf
Size: 63930 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180315/b5a5b41b/attachment.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plt_vv_vertical_sim1.pdf
Type: application/pdf
Size: 62514 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180315/b5a5b41b/attachment-0001.pdf>


More information about the ncl-talk mailing list