; ============================================================== ; Calculate EOFs of the Sea Level Pressure ; ============================================================== 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" begin latS = 20. yrStrt = 1979 yrLast = 2008 neof = 1 optEOF = True optEOF@jopt = 0 optETS = False ; ============================================================== ; Open the file: Read only the user specified period ; ============================================================== in = "d:/slp.mon.mean.nc" f = addfile(in,"r") lat = f->lat lon = f->lon TIME = f->time YYYY = ut_calendar(TIME,-1)/100 iYYYY = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast) PSL = f->slp(iYYYY,:,:) psl = short2flt(PSL) SLPclm = clmMonTLL(psl) SLPcla = calcMonAnomTLL (psl,SLPclm) time_slp = SLPcla&time yyyy = ut_calendar(time_slp,-1)/100 YYYYMM = ut_calendar(time_slp,-2)/100 ; entire file MM = YYYYMM - yyyy*100 iMM = ind(MM.ge.11 .or. MM.le.4) SLP = SLPcla(4:177,:,:) printVarSummary(SLP) ; ================================================================= ; create weights: sqrt(cos(lat)) [or sqrt(gw) ] ; ================================================================= rad = 4.*atan(1.)/180. clat = lat clat = sqrt( cos(rad*lat) ) ; gw for gaussian grid clat!0 ="lat" clat&lat=lat ; ================================================================= ; weight all observations ; ================================================================= wSLP = SLP ; copy meta data wSLP = SLP*conform(SLP,clat,1) wSLP!0 = "time" wSLP!1 = "lat" wSLP!2 = "lon" wSLP@long_name = "Wgt: "+wSLP@long_name a = wSLP(lat|:,lon|:,time|:) a&lat = lat a&lon = lon x = a({lat|87.5:20},lon|:,time|:) eof = eofunc_Wrap(x, neof, optEOF) eof_ts = eofunc_ts_Wrap (x, eof, optETS) printVarSummary( eof ) printVarSummary( eof_ts ) ; ================================================================= ; Normalize time series: Sum spatial weights over the area of used ; ================================================================= dimx = dimsizes( x ) mln = dimx(1) sumWgt = mln*sum( clat({lat|87.5:20}) ) eof_ts = eof_ts/sumWgt eof_tsstd =dim_standardize_Wrap(eof_ts, 1) eof_tsstd!1 = "time" eof_tsstd&time = x&time printVarSummary( eof_tsstd ) ;============================================================ ; PLOTS ;============================================================ wks_type = "pdf" wks = gsn_open_wks(wks_type ,"question11-4") gsn_define_colormap(wks,"BlWhRe") plot = new(neof,graphic) res = True res@gsnPolar = "NH" res@gsnDraw = False res@gsnFrame = False res@gsnSpreadColors = True res@mpGridAndLimbOn = False res@gsnTickMarksOn = False res@lbOrientation = "Vertical" res@mpMinLatF = latS res@tiMainString = "Departure Pattern" res@cnFillOn = True res@cnLineLabelsOn = False symMinMaxPlt(eof, 16, False, res) resP = True ; modify the panel plot resP@gsnMaximize = True ; large format ;resP@gsnPanelLabelBar = True ; add common colorbar resP@lbLabelAutoStride = True ; auto stride on labels ;******************************************* ; first plot ;******************************************* do n=0,neof-1 res@gsnLeftString = "EOF "+(n+1) res@gsnRightString = sprintf("%5.1f", eof@pcvar(n)) +"%" plot(n)=gsn_csm_contour_map_polar(wks,eof(n,:,:),res) end do gsn_panel(wks,plot,(/neof,1/),resP) ; now draw as one plot ;******************************************* ; second plot ;******************************************* ; EOF time series rts = True rts@gsnDraw = False ; don't draw yet rts@gsnFrame = False ; don't advance frame yet rts@gsnScale = True ; force text scaling rts@vpHeightF = 0.40 ; Changes the aspect ratio rts@vpWidthF = 0.85 rts@vpXF = 0.10 ; change start locations rts@vpYF = 0.75 ; the plot rts@gsnYRefLine = 0. ; reference line rtsP = True ; modify the panel plot rtsP@gsnMaximize = True ; large format eof_time = eof_tsstd&time yyyymm = ut_calendar(eof_time,-2)/100 year = yyyymm/100 printVarSummary(year) ;year = ispan(1,174,1) do n=0,neof-1 rts@gsnLeftString = "EOF "+(n+1) rts@gsnRightString = sprintf("%5.1f", eof@pcvar(n)) +"%" plot(n) = gsn_csm_xy (wks,year,eof_tsstd(n,:),rts) end do gsn_panel(wks,plot,(/neof,1/),rtsP) ; now draw as one plot end