[ncl-talk] Question about adding stipples on contour map

Adam Phillips asphilli at ucar.edu
Wed Jul 19 10:14:47 MDT 2017


Hi Jiali,
ShadeGtContour will shade everything starting with the first contour less
than the given input contour (in your case, 4). However, as you are not
setting the contours and letting NCL select them, NCL is choosing contours
to go from 40 to 400 by 40. Thus, I think the solution is to set the
contour levels yourself when you call wrf_contour.

Try this:

opts = res

  opts at cnFillOn        = False

  opts at cnLinesOn       = False

  opts at cnLineLabelsOn  = False
opts at cnLevelSelectionMode = "ExplicitLevels"
opts at cnLevels = (/2.,4./)    ; note that a contour level of 4 is not really
necessary

  contour_sgl = wrf_contour(c,wks,alpha,opts)

  contour_sgl = ShadeGtContour(contour_sgl,2.1,17)

  delete(opts)


If that does not give you what you expect I would take a close look at your
contour_sgl array (if you have not done so already) to make sure the values
are what you think they are.


Finally, note that ShadeGtContour is deprecated. It is suggested you use
gsn_contour_shade instead:

https://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_contour_shade.shtml


If you have any further questions please respond to the ncl-talk email list.

Adam


On Tue, Jul 18, 2017 at 4:22 PM, Wang, Jiali <jialiwang at anl.gov> wrote:

> Dear NCL experts,
>
>
>
> I am trying to add stipples (or hatchings, doesn’t matter) on a contour
> map when my “alpha >2”. I plot alpha, which is not always larger than 2,
> meaning that I should have some places where I don’t have stipples.
> However, I get stipples everywhere even when I set the threshold to 4.
> Attached are two maps, one is alpha, and the other is something else but
> with sitpples when alpha>2.
>
>
>
> Here is my script. Can you please take a look and advice what happens?
> Thank you very much!
>
> =============================================
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>
>
>
> begin
>
>
>
>    files1  = systemfunc("ls ./T2_IV_DJF_50_rs*.nc")
>
>    a       = addfiles(files1,"r")
>
>
>
>    f = addfile("T2_IV_DJF_12to50_16m.nc","r")
>
>    c = addfile("/global/cscratch1/sd/wangjl/RCP85_IV_RUNS/50km_
> 1995_IV_runs/wrfout_d01_1996-03-01_00_00_00"+".nc","r")
>
>
>
>   lat = c->XLAT(0,:,:)
>
>   lon = c->XLONG(0,:,:)
>
>
>
>   ListSetType (a, "join")
>
>   IV_10 = a[:]->IV
>
>   IV_16 = f->IV
>
>
>
>   rain  = new(dimsizes(IV_10),typeof(IV_10))
>
> do r = 0, 199
>
>   rain(r,:,:)  = IV_10(r,:,:) - IV_16(:,:)
>
> end do
>
>   printVarSummary (rain)
>
>
>
>   std_r  = dim_stddev_n(rain,0)
>
>   avg_r  = dim_avg_n(rain,0)
>
>   alpha  = abs(avg_r/(std_r+0.00001))
>
> ; printMinMax(alpha,0)
>
>
>
> ff   = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/landsea.nc","r")
>
> lsdata = ff->LSMASK
>
> lsm    = landsea_mask(lsdata,lat,lon)
>
> avg_r  = mask(avg_r, lsm .eq.0 .or. lsm.eq.2, False)
>
> alpha  = mask(alpha, lsm .eq.0 .or. lsm.eq.2, False)
>
>
>
> ;;;;;;;;;;;;;;;;;;;;;;contour plot
>
>   type = "ps"
>
>   wks = gsn_open_wks(type,"T2_IV_DJF_50_vs_12_1995")  ;;;no 1983 for sum,
> aut, win
>
>   gsn_define_colormap(wks,"ViBlGrWhYeOrRe")
>
>
>
>   res = True
>
>   pltres = True
>
>   mpres = True
>
>
>
>   mpres at mpGeophysicalLineColor = "Black"
>
>   mpres at mpNationalLineColor    = "Black"
>
>   mpres at mpUSStateLineColor     = "Black"
>
>   mpres at mpGridAndLimbOn        = False
>
>   mpres at tiMainString           = "IV 50 vs. 12"
>
>   mpres at tiMainFontHeightF      = 0.015
>
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
>
>
>   ; Plotting options for Precipitation
>
>   opts_r = res
>
>   opts_r at cnFillMode = "RasterFill"
>
> opts_r at cnLevelSelectionMode = "ManualLevels"      ; set manual contour
> levels
>
> opts_r at cnMinLevelValF       = -3.      ; set min contour level
>
> opts_r at cnMaxLevelValF       = 3.         ; set max contour level
>
> opts_r at cnLevelSpacingF      = .3           ; set contour spacing
>
>   opts_r at cnInfoLabelOn        = False
>
>   opts_r at cnConstFLabelOn      = False
>
>   opts_r at cnFillOn             = True
>
>   opts_r at lbLabelFont = 25
>
>   opts_r at pmLabelBarOrthogonalPosF= -0.012
>
>   contour_tot = wrf_contour(c,wks,avg_r,opts_r)
>
>   delete(opts_r)
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> ; Plotting options for Significant level
>
>   opts = res
>
>   opts at cnFillOn        = False
>
>   opts at cnLinesOn       = False
>
>   opts at cnLineLabelsOn  = False
>
>   contour_sgl = wrf_contour(c,wks,alpha,opts)
>
>   contour_sgl = ShadeGtContour(contour_sgl,4.,17)
>
>   delete(opts)
>
>
>
>   ; MAKE PLOTS
>
>   plot = wrf_map_overlays(c,wks,(/contour_tot,contour_sgl/),pltres,mpres)
>
>
>
> end
>
> =======================
>
> Jiali Wang, Ph. D
>
> Environmental Science Division
>
> Argonne National Laboratory
>
> Tel: 630-252-2848 <(630)%20252-2848>
>
> http://www.evs.anl.gov/about-evs/staff/detail/index.cfm?/Wang/Jiali
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>


-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170719/9f1c580c/attachment.html 


More information about the ncl-talk mailing list