;************************************************* ; dev_1.ncl ; ; Concepts illustrated: ; - Calculating deviation from zonal mean ; - Drawing zonal average plots ; - Moving the contour informational label into the plot ; - Changing the background color of the contour line labels ; - Spanning part of a color map for contour fill ; - Making the labelbar be vertical ; - Paneling two plots vertically on a page ; - Drawing color-filled contours over a cylindrical equidistant map ; - Using a blue-white-red color map ; ;************************************************ 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 ;************************************************ ; variable and file handling ;************************************************ fn = "83.nc" ; define filename in = addfile(fn,"r") ; open netcdf file ts = in->TS ; select variable to ave ;************************************************ ; calculate deviation from zonal mean ;************************************************ anom = ts ; trick to copy cv's and atts anom = dim_rmvmean(ts) ;************************************************ ; plot parameters ;************************************************ wks = gsn_open_wks("x11","dev") ; Opens a ps file plot = new(2,graphic) ; create graphical array res = True ; plot mods desired ;************************************************ ; original data ;************************************************ res@gsnDraw = False ; don't draw yet res@gsnFrame = False ; don't advance frame yet res@gsnZonalMean = True ; add zonal plot res@mpFillOn = False ; no grey continents res@cnInfoLabelOrthogonalPosF = -0.17 ; move info label up res@cnLineLabelFontHeightF = .012 ; increase font size res@cnLabelDrawOrder = "PostDraw" ; labels on top of lines res@cnLineLabelBackgroundColor = "white" ; white background on labels res@gsnCenterString = "Original Data" ; panel expects plots to be of the same size. Since these two plots are ; very different, we are forcing them to be the same size by setting the ; width. res@vpWidthF = 0.7 plot(0) = gsn_csm_contour_map_ce(wks,ts(0,:,:),res) delete(res@gsnZonalMean) ; delete zonal plot ;************************************************ ; anomaly data ;************************************************ gsn_define_colormap(wks,"BlWhRe") ; choose colormap res@gsnCenterString = "Deviation from zonal ave" res@lbOrientation = "Vertical" ; vertical label bar res@cnFillOn = True ; color plot res@gsnSpreadColors = True ; subset color map res@gsnSpreadColorStart = 24 ; choose starting color res@gsnSpreadColorEnd = -26 ; choose ending color plot(1) = gsn_csm_contour_map_ce(wks,anom(0,:,:),res) ; panel the two plots together gsn_panel(wks,plot,(/2,1/),False) end