load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" ;************************************************ ; Conduct EOF analysis and make plots by YM Cheng ;************************************************ ; Descriptiosn: ; Calculate EOFs of filtered data with period and season of interest ; Generate the associated PCs for the entire length of the dataset ; Output the EOFs and PCs in a nc file ; Plot the EOFs begin ;;============================================= ;;=========== beginning of settings =========== ;;============================================= neval = 8; number of EOFs to retain latRange=(/-10,35/); domain to conduct EOF analysis lonRange=(/-40,40/); domain to conduct EOF analysis diri="."; input directory ; fin="EOF.v.700.nc"; input file ; fin="EOF.v.200.nc"; input file fin="EOF.Tb.nc"; input file ; varname="vwnd" ; variable name of EOF, for the title varname="Tb" ; variable name of EOF, for the title diro="."; output directory wksType="x11"; "png" wksName=diro+"/"+"eof"; output fig name ;;============================================= ;;============== end of settings ============== ;;========== can leave the rest unchanged====== ;;============================================= print("varname = "+varname) print("EOF file = "+diri+"/"+fin) print("reading data...") inf=addfile(diri+"/"+fin,"r") eof=inf->eof pc =inf->eof_ts; eof_ts is the varname for the pcs ;******************************************* ; ============ plotting EOF ============ ;******************************************* plot = new((/neval,2/),graphic) wks = gsn_open_wks(wksType,wksName) ; resources for maps mapres = True mapres@gsnDraw = False mapres@gsnFrame = False mapres@tmXBLabelFontHeightF = 0.014 mapres@tmYLLabelFontHeightF = 0.014 mapres@mpMaxLatF = latRange(1) mapres@mpMinLatF = latRange(0) mapres@mpMaxLonF = lonRange(1) mapres@mpMinLonF = lonRange(0) mapres@mpOutlineOn = True mapres@mpGridAndLimbOn = True ; default is every 15 deg mapres@mpGeophysicalLineThicknessF = 5 mapres@mpOutlineDrawOrder = "PostDraw" mapres@mpGridLineDashPattern = 2 ; lat/lon lines dashed mapres@mpGridLatSpacingF = 10 mapres@mpGridLonSpacingF = 15 ; resources for shadings xyres=True xyres@gsnFrame = False xyres@gsnDraw = False xyres@cnLineLabelPlacementMode = "Constant" xyres@cnFillOn = True xyres@cnFillPalette = "BlWhRe" xyres@cnLinesOn = False ; turn off contour line xyres@cnInfoLabelOn = False xyres@lbLabelBarOn = False ; turn off individual lb's symMinMaxPlt(eof, 16, False, xyres); set symmetric plot min/max ; resources for panelling resP = True ; modify the panel plot resP@gsnMaximize = True ; large format resP@gsnPanelLabelBar = True ; add common colorbar resP@lbLabelAutoStride = True ; auto stride on labels resP@lbLabelFontHeightF = 0.012 resP@txString=varname +" EOF" ;; plotting the maps! do n=0,neval-1 xyres@gsnLeftString = "EOF "+(n+1) xyres@gsnRightString = sprintf("%5.1f", eof@pcvar(n)) +"%" plot(n,0) = gsn_csm_map(wks,mapres) plot(n,1) = gsn_csm_contour(wks,eof(n,:,:),xyres) overlay(plot(n,0),plot(n,1)) end do gsn_panel(wks,plot(:,0),(/4,2/),resP) ; draw all eofs as one plot end