[ncl-talk] PDFs to a spatial plot

Melissa Lazenby M.Lazenby at sussex.ac.uk
Wed Mar 25 08:43:01 MDT 2015


Hi all

I am trying to determine the significance of precipitation anomalies at each gridpoint over the Indian Ocean.
I have calculated the pdfs at each gridpoint, in the script attached below and would like to display the spatial map of percentages from the pdfs over the Indian ocean to see how extreme the anomalies are over the chosen domain from 1000-1849AD.
If anyone has advice on how to do this it would be much appreciated.

Kindest Regards
Melissa


Code:
;----------------------------------------------------------------------
; pdf_1.ncl
;----------------------------------------------------------------------
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/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
begin



h=addfile("/mnt/geog/ml382/McGill_Project/pr/Scen2/PDF/pdf_ens_correct.nc", "r")


  latS   =  -70.
  latN   =  50.
  lonL   =  0.
  lonR   =  150.


  pr    = h->pr
  lat   = h->lat
  lon   = h->lon

nlat       = dimsizes(lat)
mlon       = dimsizes(lon)

  opt          = True
  opt at bin_nice = True

   do nl = 0, nlat-1
    do ml = 0, mlon-1

       nbins = 25
       pdf_gridpt = pdfx( pr(:,nl,ml),nbins,opt )
       printVarSummary(pdf_gridpt)


printVarSummary(pdf_gridpt)
print(pdf_gridpt)



;create plot

  res                      = True               ; plot mods desired

  res at cnFillOn             = True               ; turn on color for contours
  res at cnLinesOn            = False              ; turn off contour lines
  res at cnLineLabelsOn       = False              ; turn off contour line labels
  res at gsnScalarContour     = True               ; contours desired
  ;res at cnFillPalette        = cmap(17:,:)        ; subset the color map


  res at lbOrientation            = "Vertical"     ; vertical label bar
  ;res at pmLabelBarOrthogonalPosF = -0.01          ; move label bar closer

; note, when doing a subregion, NCL determines the range of the data from
; the full domain. If you wish to just consider the domain you are plotting,
; you must manually set those levels.

  ;res at cnLevelSelectionMode = "ManualLevels"     ; set manual contour levels
  ;res at cnMinLevelValF       = 24.0               ; set min contour level
  ;res at cnMaxLevelValF       = 29                 ; set max contour level
  ;res at cnLevelSpacingF      = 0.10               ; set contour spacing

  res at vcRefMagnitudeF           = 1.0             ; define vector ref mag
  res at vcRefLengthF              = 0.025           ; define length of vec ref
  ;res at vcRefAnnoOrthogonalPosF   = -1.0            ; move ref vector
  res at vcRefAnnoArrowLineColor   = "black"         ; change ref vector color
  res at vcRefAnnoArrowUseVecColor = False           ; don't use vec color for ref

  res at vcGlyphStyle            = "CurlyVector"     ; turn on curley vectors
  res at vcLineArrowColor        = "black"           ; change vector color
  res at vcLineArrowThicknessF   = 2.0               ; change vector thickness
  res at vcVectorDrawOrder       = "PostDraw"        ; draw vectors last
  res at vcMinDistanceF = 0.02

   ;res at gsnCenterString = "Difference in MME Wind Anomaly for Scen1 for the Non-Monsoon Season"
   res at gsnLeftString   = ""
   res at gsnMainString   = ""
   res at gsnRightString  = ""

  res at mpMinLonF            =  lonL               ; select a subregion
  res at mpMaxLonF            =  lonR
  res at mpMinLatF            =  latS
  res at mpMaxLatF            =  latN


 pres                      = True

  pres at mpFillOn = False
  pres at cnFillOn             = True               ; color on
  pres at cnLinesOn            = False              ; turn off contour lines
  pres at gsnScalarContour     = True               ; vectors over contours
  pres at gsnSpreadColors      = True               ; use full colormap
  ;res at gsnSpreadColorEnd    = -4                 ; last color used
  pres at gsnAddCyclic         = False
  ;pres at gsnDraw             = False              ; do not draw the plot
  ;pres at gsnFrame            = False
  pres at lbLabelBarOn        = True

pres at gsnCenterString = "Difference in MME Wind Anomaly for Scen1 for the Non-Monsoon Season"
   pres at gsnLeftString   = ""
   pres at gsnMainString   = ""
   pres at gsnRightString  = ""

  pres at mpMinLonF            =  lonL               ; select a subregion
  pres at mpMaxLonF            =  lonR
  pres at mpMinLatF            =  latS
  pres at mpMaxLatF            =  latN


 pres at cnLevelSelectionMode= "ManualLevels"  ; manual levels
  pres at cnMinLevelValF      =  0.2           ; min level
  pres at cnMaxLevelValF      =  2.8            ; max level
  pres at cnLevelSpacingF     =  0.2             ; contour spacing


  wks  = gsn_open_wks ("X11","PDF_mounttambora")
  gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")  ; choose colormap

  prres  = True
  prres at gsnCenterString = "Precipitation PDF"


 plot = gsn_csm_xy (wks, pdf_gridpt at bin_center, pdf_gridpt, prres)
 plot1= gsn_csm_contour_map_ce(wks, pdf_gridpt, res)


     end do
    end do
end

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150325/4f945a56/attachment.html 


More information about the ncl-talk mailing list