[ncl-talk] plot the dot on the grids with significant trends

WUJIE 393069045 at qq.com
Mon Sep 10 05:13:06 MDT 2018


Hi NCL users,


While I get no response, I have finished it by myself after one-day continuous try/test.


What I think useful now is the overlay procedure instead of gsn_coordinates. The basic idea is to draw another plot showing prob only (0-0.05) and then overlay it.
I paste a little bit codes on how I coped with it here, and if someone think it is helpful he/she can search this question via this mail.


Thanks anyways ! It is really good to learn more about NCL ploting.
Jie


  ;=========================For p<0.05, fill using MonoPattern and Monocolor==============================
  res3 = True                                  ; res3 for probability plot
  res3 at gsnDraw             = False       ; Do not draw plot
  res3 at gsnFrame            = False       ; Do not advance frome
  res3 at cnInfoLabelOn       = False       ; turn off info label
  res3 at cnLinesOn           = False       ; do not draw contour lines
  res3 at cnLineLabelsOn      = False       ; do not draw contour labels
  res3 at lbLabelBarOn        = False       ; do not need lable bar for prob 
  res3 at cnLevelSelectionMode = "ExplicitLevels" 
  res3 at cnLevels = (/0.,0.05/) 
  res3 at cnFillOn = True 
  res3 at cnMonoFillPattern = True  ; only one pattern
  res3 at cnFillPattern = 17        ; stipple dot fill pattern
  res3 at cnMonoFillColor = True
  res3 at cnFillColor   = "black"
  res3 at cnFillScaleF  = 0.6     ; default is 1, larger is corse, lower is dense
  
  plot3   = gsn_csm_contour(wks,prob,res3)


  overlay (plot, plot3)

.........


------------------ Original ------------------
From:  "393069045"<393069045 at qq.com>;
Date:  Mon, Sep 10, 2018 00:40 AM
To:  "ncl-talk"<ncl-talk at ucar.edu>;

Subject:  [ncl-talk] plot the dot on the grids with significant trends



Hi NCL users,

I am trying to plot the spatial distribution of the trends in annual evaporation. My plan is to show trends for all grids but cover those grids with dots if its trends are significant (i.e. p<0.05).


I calculate rc using the NCL guide and use rc_sig to show only the sigificant trend. I have tested the way to derive rc is correct. I then tried the procedure gsn_coordinates but I got a very big PDF which shows all black. Does any one can help me on this?


If what I did is not correct, could you please give me some clues for drawing such plots?


Thanks so much


Jie.






;----ATTACH CODES HERE-----
;-----------read data and calculate rc------
  Ea                 = ncfile->Ea  ; mm/month
  Ea_annual      = month_to_annual (Ea, 0)  ; monthly to annaul
  
  Ea_annual!0    = "time"
  Ea_annual&time =(/ispan(1980,2015,1)/)  


  Ea_annual_0  = Ea_annual (lat|:,lon|:,time|:)  ;re-order to make time as rightmost
  
  time         = Ea_annual_0&time 
  rc            = regCoef(time,Ea_annual_0)    ;tends with /plat,plon/


  rc at long_name = "Trend of annual Ea"     ; trend
  rc at units         = "(mm yr~S~-1~N~)"  
  
  printVarSummary(rc)
  printMinMax (rc, True)
  
 ;-----make all data become (plat,plon)------
  tval = onedtond(rc at tval , dimsizes(rc))
  df   = onedtond(rc at nptxy, dimsizes(rc)) - 2   ;The FillValue grid will be =0 for nptxy. So df may<0
  df at _FillValue=-9999
  df   = where(df.le.0,df at _FillValue,df)
  
  b    = tval      ; b must be same size as tval (and df)
  b    = 0.5
  
;----betainc (x,a,b): 0<x<1, a>0,b>0)-----
;----ony if this value<0.05, means p<0.05----
  prob = betainc(df/(df+tval^2), df/2.0, b)    
  copy_VarCoords(Ea_annual_0(:,:,0), prob)


 ;-----only significant rc with p<0.05-------
  rc_sig = new ((/plat,plon/),float)
  rc_sig at _FillValue=-9999
  copy_VarCoords(Ea_annual_0(:,:,0), rc_sig)
  rc_sig= where(prob.lt.0.05,rc,rc_sig at _FillValue)


HERE SKIP SOME LINES




;---plot------------------
   plot=new(1,graphic)
   plot = gsn_csm_contour_map_overlay(wks,rc,Basin,res,res2)
  
   pres                   = True
   pres at gsMarkerSizeF     = 0.007  ; default is 0.007
   gsn_coordinates(wks,plot,rc_sig,pres)



end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180910/1e0bcaaf/attachment.html>


More information about the ncl-talk mailing list