load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" begin ;---Read data filename = "chamba_tmean_fldmean.nc" a = addfile(filename,"r") temp = a->t dims = dimsizes(temp) ntim = dims(0) nlat = dims(1) nlon = dims(1) ntim5 = ntim/5 ; ; Reshape temperature array so we can easily average groupings of ; five years at a time. ; temp_5year_avg_1d = dim_avg_n(reshape(temp,(/ntim5,5,nlat,nlon/)),(/1,2,3/)) copy_VarAtts(temp,temp_5year_avg_1d) ;---Get just the years out of the time array for plotting purposes. newtime = cd_calendar(temp&time,0) ; Convert to N x 6 array (year,month,...,second) years = newtime(:,0) year5 = reshape(years,(/ntim5,5/)) ; This is for labels on the X axis wks = gsn_open_wks("png","chamba") xyres = True xyres@vpWidthF = 0.8 xyres@vpHeightF = 0.3 xyres@gsnMaximize = True ; maximize plot in frame xyres@xyLineColor = "blue" xyres@xyLineThicknessF = 2.5 xyres@tmXBMode = "Explicit" xyres@tmXBValues = years(::5) xyres@tmXBLabels = year5(:,0) + "~C~ to~C~" + year5(:,4) xyres@tmXBLabelFontHeightF = 0.015 xyres@tmYLLabelFontHeightF = 0.015 ; xyres@tmXBLabelAngleF = -90. plot = gsn_csm_xy(wks,years(::5),temp_5year_avg_1d,xyres) end