;--------------------------------------------------------------------------- ;--------------------------------------------------------------------------- ; Script to output ERSST for CPC nino-3.4 index ; ; and power spectra. ; ;---------------------------------------------------------- ; There are four region based indices used to monitor the tropical Pacific: ; Nino 1+2 (0-10S, 90W-80W), Nino 3 (5N-5S, 150W-90W), ; Nino 3.4/ONI (5N-5S, 170W-120W) and Nino 4 (5N-5S, 160E-150W) ; ; NOAA's operational definitions of El Nino and La Nina conditions are based ; upon the Oceanic Nino Index [ONI]. The ONI is defined as the 3-month running ; means of SST anomalies in the Nino 3.4 region [5N-5S, 120-170W]. The anomalies ; are derived from the 1971-2000 SST climatology. ;--------------------------------------------------------------------------- load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl" 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 = -5.0 latN = 5.0 lonL = 190.0 lonR = 240.0 nrun = 3 ; length of running average run1 = getenv("MODE") ymStrt = (stringtointeger(getenv("ISYY")))*100+1 ymLast = (stringtointeger(getenv("IEYY")))*100+12 dir = getenv("path") ; dir = "/archive/CMIP6/TaiESM1/"+run1+"/atmos/mon/r1i1p1f1/" ; dir = "/lfs/archive/taiesm_ppost/"+run1+"/v20210908/" model = getenv("model") ;--------------------------------------------------------------------- ifn = systemfunc("ls "+dir+"ts_Amon_*.nc") a = addfiles(ifn,"r") data = a[:]->ts;(:,{latS:latN},{lonL:lonR}) yyyymm = cd_calendar(data&time,-1) yyyymm!0 = "date" yyyymm&date = yyyymm delete(data&time) data&time = yyyymm tStrt = ind(yyyymm.eq.ymStrt) ; indices of selected times tLast = ind(yyyymm.eq.ymLast) ; print(date) x = data(tStrt:tLast,{latS:latN},{lonL:lonR}) printVarSummary(x) ;********************************* ; Climatology and anomalies from base climatology ;********************************* ; xClm = clmMonTLL(data(iClmStrt:iClmLast,{latS:latN},{lonL:lonR})) xClm = clmMonTLL(x) printVarSummary(xClm) xAnom = calcMonAnomTLL (x, xClm ) xAnom@long_name = "SST Anomalies" printVarSummary(xAnom) ;********************************* ; Unweighted areal average anomalies (time series) ; Small latitudinal extent so no need to weight ;********************************* xAnom_avg = wgt_areaave_Wrap(xAnom, 1.0, 1.0, 1) xAnom_avg@long_name = "areal avg anomalies" printVarSummary(xAnom_avg) ;********************************* ; Perform an unweighted 'nrun' month running average ;********************************* xAnom_avg = runave_n_Wrap (xAnom_avg, nrun, 1, 0) ;********************************* ; de-trend ;********************************* dsst = dtrend(xAnom_avg,False) copy_VarCoords(xAnom_avg,dsst) printVarSummary(dsst) ;------------------------------------ ; cal std std = dim_stddev_Wrap(dsst) dsst@std = std ;------------------------------------ ; calculate EOF1 ts power spectra ;------------------------------------ ;------------------------------------ iopt = 0 ; nino3.4 power spectra jave = 0; (7*nyr(ee))/100 val1 = .95 val2 = .99 pct = 0.1 spectra_mvf = False ; missing value flag for nino3.4 ; sdof_cp = specx_anal(xAnom_avg,iopt,jave,pct) sdof_cp = specx_anal(dsst,iopt,jave,pct) splt1_cp = specx_ci(sdof_cp,val1,val2) ;********************************* ; output data ;********************************* ofn = model+"_"+run1+"_nino34_ONI_"+ymStrt+"-"+ymLast+".nc" system("rm -rf "+ofn) odd = addfile(ofn,"c") odd->oni = dsst ;avg odd->sdof_cp = sdof_cp odd->splt1_cp = splt1_cp ;********************************* ; plot graph ;********************************* yrfrac = yyyymm_to_yyyyfrac(yyyymm({ymStrt:ymLast}), 0.0) wks = gsn_open_wks("pdf", model+"_"+run1+"_CPC_ONI_nino34_"+ymStrt+"-"+ymLast) res = True res@gsnMaximize = True res@gsnYRefLine = 0.0 ; create a reference line res@gsnAboveYRefLineColor = "red" ; above ref line fill red res@gsnBelowYRefLineColor = "blue" ; below ref line fill blue res@vpHeightF = 0.4 ; change aspect ratio of plot res@vpWidthF = 0.8 res@vpXF = 0.1 ; start plot at x ndc coord res@trYMinF = -3.0 ; min value on y-axis res@trYMaxF = 3.0 ; max value on y-axis res@tmXTOn = False ;es@tiMainString = "CPC Ocean Nino Index" res@gsnLeftString = model+"_"+run1+" Nino3.4 Index" res@gsnRightString = std res@tiYAxisString = "Anomalies (C)" ; y-axis label ; plot = gsn_csm_xy (wks,yrfrac,xAnom_avg({195001:201012}),res) plot = gsn_csm_xy (wks,yrfrac,dsst,res) ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - pres = True pres@vpXF = 0.07 pres@trYMinF = 0. pres@trXMinF = 0.0 pres@trYMaxF = 300. ;max(splt1_cp) pres@trXMaxF = 0.0832 pres@tiYAxisString = "Power" ; yaxis pres@xyLineColor = "black" pres@tmXBLabelDeltaF = -.8 pres@tmXTLabelDeltaF = -.8 pres@pmLegendDisplayMode = "Never" pres@xyLineThicknesses = (/3.5,2.,1.,1./) pres@xyDashPatterns = (/0,0,0,0/) pres@xyLineColors = (/"foreground","red","blue","green"/) pres@xyLabelMode = "custom" pres@xyLineLabelFontColors = pres@xyLineColors pres@xyExplicitLabels = (/"","",val1*100+"%",val2*100+"%"/) pres@tmXTOn = True pres@tmYROn = False pres@tmXTLabelsOn = True pres@tmXUseBottom = False pres@tmXTMode = "Explicit" pres@tmXBMode = "Explicit" pres@tmXTValues = (/".00167",".00833",".01667",".02778",".0416",".0556",".0832"/) pres@tmXTLabels = (/"50","10","5","3","2","1.5","1"/) pres@tmXBValues = (/".0",".01",".02",".03",".042",".056",".083"/) pres@tmXBLabels = pres@tmXBValues pres@tmXTLabelFontHeightF = 0.018 pres@tmXBLabelFontHeightF = 0.018 pres@tmYLLabelFontHeightF = 0.018 pres@tiYAxisString = "Power (~S~o~N~C~S~2~N~ / cycles mo~S~-1~N~)" ; yaxis pres@tiXAxisString = "Frequency (cycles mo~S~-1~N~)" pres@txFontHeightF = 0.015 pres@xyLineLabelFontHeightF = 0.022 pres@tiXAxisFontHeightF = 0.025 pres@tiYAxisFontHeightF = 0.025 pres@tiMainFontHeightF = 0.03 pres@gsnCenterString = "Period (years)" pres@gsnCenterStringFontHeightF = pres@tiYAxisFontHeightF pres@gsnRightString = "" pres@gsnLeftString = "" pres@tiMainString = model+"_"+run1+" nino3.4" plot = gsn_csm_xy(wks,sdof_cp@frq,splt1_cp,pres) ; print(sdof_cp@frq) print(wks) end