;************************************************* ; ce_3.ncl ; ; Concepts illustrated: ; - Drawing color-filled contours over a cylindrical equidistant map ; - Selecting a different color map ; - Changing the contour level spacing ; - Turning off contour lines ; - Comparing styles of map tickmarks labels ; - Changing the stride of the labelbar labels ; - Zooming in on a particular area on the map ; - Turning off the addition of a longitude cyclic point ; ;************************************************ ; ; 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" ; system("export NCARG_RANGS=/Users/zewdu/NCL/lib/ncarg/database/rangs") ;************************************************ begin ;************************************************ ; open file and read in data ;************************************************ yrSlct = 1998 allYrs = ispan(1982, 2023, 1) allYrs := ispan(1998, 2023, 1) var_name = "CMORPH" in = addfile("precJJAS_1982-2023CHIRPS.nc","r") ;in = addfile("../data/cmorph.v2.0.daily.p1WAf.1998.nc","r") in = addfile("./precJJA_1998-2020CMORPH.nc","r") prec = in->prec lonW = -95. lonE = -60. latS = 10 latN = 20 it = ind(allYrs .eq. yrSlct) it = 10 ; lonW = -65. ; lonE = -60. ; latS = 12 ; latN = 15 ;************************************************ ; create plot ;************************************************ wks = gsn_open_wks("x11" ,"prec") ; send graphics to PNG file res = True ; plot mods desired res@gsnMaximize = True ; Make plot fit the frame res@cnFillOn = True ; turn on color fill res@cnLinesOn = False ; turn of contour lines res@cnLevelSpacingF = 0.5 ; contour spacing res@cnFillPalette = "BlAqGrYeOrRe" res@lbOrientation = "Vertical" ;res@cnLevelSpacingF = 20 ;res@cnMaxLevelCount = 10 ;res@cnLevelSelectionMode = "EqualSpacedLevels" res@cnLineLabelsOn = False res@mpFillOn = False res@mpCenterLonF = 180 ;res@lbBoxLinesOn = False res@lbBoxSeparatorLinesOn = False res@cnLevelSelectionMode = "ExplicitLevels" ;res@cnLevels = (/ 0.1, 1., 5., 10., 15., \ ; 20., 25., 30./) res@cnLevels = (/ 0.1, 10., 50., 100., 150., \ 200., 250., 300./) res@cnFillColors = (/"white","cyan", "green","yellow",\ "darkorange","red","magenta","purple",\ "black"/) res@pmLabelBarWidthF = 0.1 res@tiMainFontHeightF = 0.018 res@gsnLeftString = var_name ;res@gsnCenterString = yyyymm res@gsnAddCyclic = False ; data already has cyclic point ; this must also be set for any zoom res@mpDataBaseVersion = "HighRes" ; Use the high-res database res@mpDataBaseVersion = "MediumRes" ; Use the high-res database ;res@mpFillDrawOrder = "PostDraw" res@mpOutlineOn = True res@mpOutlineBoundarySets = "AllBoundaries" res@mpOutlineBoundarySets = "National" res@pmTickMarkDisplayMode = "Always" ; ; Note that the gsn_csm_*map* templates automatically set ; res@mpLimitMode="LatLon" for you. If you are plotting a ; different projection, you may have to set this resource. ; res@mpMinLatF = latS ; range to zoom in on res@mpMaxLatF = latN res@mpMinLonF = lonW res@mpMaxLonF = lonE res@tiMainString = "precip for " + yrSlct res@pmTickMarkDisplayMode = "Always"; use NCL default lat/lon labels res@pmTitleZone = 4 plot = gsn_csm_contour_map(wks,prec(it,0,{latS:latN},{lonW:lonE}), res) printMinMax(prec(it,{latS:latN},{lonW:lonE}),0) end