;***************************************************** ; cru_6.ncl ; ; Concepts illustrated: ; - Plotting CRU (Climate Research Unit) data ; - Drawing filled bars above and below a given reference line ; - Adding text and lines ; - Paneling three plots vertically on a page ; - Changing the width and height of a plot ; - Attaching several plots ; ;***************************************************** 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" ;***************************************************** f = addfile("Tave_18562003.nc","r") year = f->year tnh = f->TAveNhAn ; tnh(:) tsh = f->TAveShAn tgl = f->TAveGlAn ;*************************************** ; Some weights for 'decadal' filter (smoother) ; Other weights could be used ;*************************************** wgts = (/ 1,6,19,42,71,96,106,96,71,42,19,6,1 /)*1.0 wgts = wgts/sum(wgts) TNH = wgt_runave_n_Wrap(tnh, wgts, 1, 0) ; reflective end pts TSH = wgt_runave_n_Wrap(tsh, wgts, 1, 0) TGL = wgt_runave_n_Wrap(tgl, wgts, 1, 0) ;*************************************** ; create plot ;*************************************** wks = gsn_open_wks("ps","cru") ; open ps file plot= new (3,graphic) ; create graphical array res = True ; plot mods desired res@gsnDraw = False ; don't draw yet res@gsnFrame = False ; don't advance frame yet res@vpHeightF = 0.43 ; Changes the aspect ratio res@vpWidthF = 0.90 ; of plots res@trYMinF = -0.75 ; min value on y-axis res@trYMaxF = 0.75 ; max value on y-axis res@trXMinF = 1855 ; min value on x-axis res@trXMaxF = 2005 ; max value on x-axis res@gsnYRefLine = 0. ; reference line res@gsnAboveYRefLineColor = "red" ; above ref line fill red res@gsnBelowYRefLineColor = "blue" ; below ref line fill blue res@gsnXYBarChart = True ; create bar chart res@xyLineColors = (/"red","blue"/) ; line around bar color ; text and line resources txres = True txres@txFontHeightF = 0.02 txres@txJust = "CenterLeft" txres@txFontThicknessF = 2.0 ; default=1.00 txres@txFontHeightF = 0.025 ; default=0.05 plres = True plres@gsLineColor = "black" ; color of lines plres@gsLineThicknessF = 3.0 ; thickness of lines ; create plots; force no default long_name and units labeling via (/ ... /) plot(0) = gsn_csm_xy (wks,year, (/ tnh /),res) text_tnh = gsn_add_text(wks,plot(0),"Northern Hemisphere", 1870, 0.75*res@trYMaxF ,txres) curv_tnh = gsn_add_polyline(wks,plot(0),year, TNH ,plres) res@tiYAxisString = "HadCRUT3: Anomalies (C)" plot(1) = gsn_csm_xy (wks,year, (/ tsh /),res) text_tsh = gsn_add_text(wks,plot(1),"Southern Hemisphere", 1870, 0.75*res@trYMaxF ,txres) curv_tsh = gsn_add_polyline(wks,plot(1),year, TSH ,plres) delete(res@tiYAxisString) plot(2) = gsn_csm_xy (wks,year, (/ tgl /),res) text_tgl = gsn_add_text(wks,plot(2),"Globe", 1870, 0.75*res@trYMaxF ,txres) curv_tgl = gsn_add_polyline(wks,plot(2),year, TGL ,plres) ; create panel plot resP = True ; panel mods desired resP@gsnMaximize = True gsn_panel(wks,plot,(/3,1/),resP) ;******************************************** ; create attached plots ;******************************************** ; Set up resource lists for attaching the plot. ; The res1 will apply to the base plot, and the ; res2 to the plots being attached. These resources ; lists are *not* for changing things like line color, ; but for changing things like whether the plots ; are maximized, and which axis they are attached on. ; res1 = True res2 = True res2@gsnAttachPlotsXAxis = True ; plot(0) will be the base plot. amid = gsn_attach_plots(plot(0),(/plot(1), plot(2)/),res1,res2) draw(plot) frame(wks)