;---------------------------------------------------------------------- ; panel_trilbar_18.ncl ; ; Concepts illustrated: ; - Combining two sets of paneled plots on one page ; - Using cnFillPalette to assign a color palette to contours ; - Using lbBoxEndCapStyle to draw triangles at the end of a labelbar ;---------------------------------------------------------------------- ; You must download panel_two_sets.ncl for this script to run. ;---------------------------------------------------------------------- load "./panel_two_sets.ncl" ; ; 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" begin ;---Read data fl_mdl = addfile("TS.cam3.toga_ENS.1950-2000.nc","r") yr0 = fl_mdl->TS(12,:,:) yr1 = fl_mdl->TS(600,:,:) yr0 = yr0-273.15 ; convert to degrees C yr1 = yr1-273.15 ; convert to degrees C yr0@units = "C" yr1@units = "C" ;---Calculate difference diff = yr1 ; trick to create array with coordinate info diff = yr1 - yr0 ; over write values with differences diff@long_name = "1999-1951 TS field differences" print("========================================") printVarSummary(diff) print(" min="+min(diff)+" max="+max(diff)) ;---Plot wks = gsn_open_wks("png","panel_trilbar") ; send graphics to PNG file res = True res@gsnDraw = False res@gsnFrame = False res@mpFillOn = False ; no need res@cnLevelSelectionMode= "ExplicitLevels" ; manual set levels res@cnLevels = ispan(-30,270,15) * 0.1 res@lbLabelStrings = sprintf("%5.1f",res@cnLevels) res@cnFillOn = True ; color fill plot res@cnFillPalette = "BlAqGrYeOrRe" res@cnLinesOn = False res@cnLineLabelsOn = False res@cnInfoLabelOn = False res@lbLabelBarOn = False ; turn off individual label bars plot = new(2,graphic) res@gsnLeftString = "TS" res@gsnRightString = "~S~o~N~C" res@gsnCenterString = "Jan. 1999" plot(0) = gsn_csm_contour_map(wks,yr1,res) res@gsnCenterString = "Jan. 1951" plot(1) = gsn_csm_contour_map(wks,yr0,res) res@cnLevels := ispan(-4,4,1) res@lbLabelStrings := sprintf("%5.1f",res@cnLevels) res@cnFillPalette = "BlueWhiteOrangeRed" ; select a color map with white in the middle res@gsnCenterString = "Difference: Jan 1999 - Jan 1951" res@lbBoxEndCapStyle = "TriangleBothEnds" ; Added in NCL V6.4.0 plot2 = gsn_csm_contour_map(wks, diff ,res) ;---Panel the two sets of plots. Note no special resources need to be set. pres1 = True pres2 = True pres = True panel_two_sets(wks,plot,plot2,(/2,1/),(/1,1/),pres1,pres2,pres) end