;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Script to output ERA40 T2m for remove 9-year running ; ; mean with DJF varances. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;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" ;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl" ; ;--------------------------------------------------------------------------- ; 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. ;--------------------------------------------------------------------------- begin ; latS = -3.3 latN = 3.3 lonL = 130.0 lonR = 280.0 nrun = 3 run1 = getenv("MODE") ymStrt = stringtointeger(getenv("ISYY"))*100+1 ymLast = stringtointeger(getenv("IEYY"))*100+12 ;; /lfs/archive/CMIP6/TaiESM1/amip/atmos/mon/r1i1p1f1 dir = getenv("path") model = getenv("model") ;dir = "/lfs/archive/taiesm_ppost/"+run1+"/v20210908/" ;--------------------------------------------------------------------- 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}) delete([/ifn,a,data/]) ;--------------------------------------------------------------------- ; reading case time dis = dimsizes(x) ny = dis(1) nx = dis(2) printVarSummary(x) ifn = systemfunc("ls "+dir+"rsds_Amon_*.nc") a = addfiles(ifn,"r") data = a[:]->rsds(:,{latS:latN},{lonL:lonR}) delete(data&time) data&time = yyyymm u10 = data(tStrt:tLast,:,:) ;********************************* ; Climatology and anomalies from base climatology ;********************************* xClm = clmMonTLL(x) printVarSummary(xClm) xAnom = calcMonAnomTLL (x, xClm ) xAnom@long_name = "TEMP Anomalies" printVarSummary(xAnom) xAnom = dtrend_msg_n(ispan(0,dimsizes(xAnom&time)-1,1),xAnom,False,False,0) ;------------------------------- uClm = clmMonTLL(u10) printVarSummary(xClm) uAnom = calcMonAnomTLL (u10,uClm ) uAnom@long_name = "U10 Anomalies" printVarSummary(uAnom) uAnom = dtrend_msg_n(ispan(0,dimsizes(uAnom&time)-1,1),uAnom,False,False,0) ;********************************* ; Perform an unweighted 'nrun' month running average ;********************************* xAnom_avg = dim_avg_n_Wrap (xAnom(:,{latS:latN},{lonL:lonR}) , 1) uAnom_avg = dim_avg_n_Wrap (uAnom(:,{latS:latN},{lonL:lonR}) , 1) ; printVarSummary(xAnom_avg) ; printVarSummary(uAnom_avg) ;exit ;--------------------------------------------------------------------------- ; ca = addfile("CAM5.3_"+ymStrt+"-"+ymLast+"_case.nc","r")o isy = ymStrt/100 iey = (ymLast/100)-2 ;--------------------------------------------------------------------------- ca = addfile(model+"_"+run1+"_nino_case_"+ymStrt+"-"+ymLast+".nc","r") casST = ca->highyr/100;2:5) cashi = casST(ind(casST.ge.isy .and. casST.lt.iey)) delete(casST) casST = ca->lowyr/100;2:5) caslo = casST(ind(casST.ge.isy .and. casST.lt.iey)) ;--------------------------------------------------------------------------- ;--------------------------------------------------------------------------- CA = new((/dimsizes(cashi),29,dimsizes(xAnom_avg(0,:))/),"float") ;CA(case,time,lon) CU = new((/dimsizes(cashi),29,dimsizes(xAnom_avg(0,:))/),"float") ;CA(case,time,lon) Clo= new((/dimsizes(caslo),29,dimsizes(xAnom_avg(0,:))/),"float") ;CA(case,time,lon) Ulo= new((/dimsizes(caslo),29,dimsizes(xAnom_avg(0,:))/),"float") ;CA(case,time,lon) printVarSummary(CA) do i = 0 ,dimsizes(cashi)-1 nois =cashi(i)*100+1 noet =(cashi(i)+2)*100+5 print("st="+nois+" / et="+noet) printVarSummary(xAnom_avg({nois:noet},:)) CA(i,:,:) = (/xAnom_avg({nois:noet},:)/) CU(i,:,:) = (/uAnom_avg({nois:noet},:)/) delete(nois) delete(noet) end do do i = 0 ,dimsizes(caslo)-1 nois =caslo(i)*100+1 noet =(caslo(i)+2)*100+5 print("st="+nois+" / et="+noet) Clo(i,:,:) = (/xAnom_avg({nois:noet},:)/) Ulo(i,:,:) = (/uAnom_avg({nois:noet},:)/) delete(nois) delete(noet) end do CopNino = dim_avg_n_Wrap(CA,0) CopNino!0 = "time" CopNino!1 = "lon" CopNino&lon = xAnom_avg&lon u10Nino = dim_avg_n_Wrap(CU,0) u10Nino!0 = "time" u10Nino!1 = "lon" u10Nino&lon = xAnom_avg&lon CopNina = dim_avg_n_Wrap(Clo,0) CopNina!0 = "time" CopNina!1 = "lon" CopNina&lon = xAnom_avg&lon u10Nina = dim_avg_n_Wrap(Ulo,0) u10Nina!0 = "time" u10Nina!1 = "lon" u10Nina&lon = xAnom_avg&lon printVarSummary(CopNino) ; ------------------------ ofn = model+"_"+run1+"_TS_rsds_x-t_"+isy+"-"+iey+".nc" system("rm -rf "+ofn) odd = addfile(ofn,"c") odd->t_nino = CopNino odd->u_nino = u10Nino odd->t_nina = CopNina odd->u_nina = u10Nina ;************************************************ ; plot the correlations ;************************************************ wks = gsn_open_wks("pdf",model+"_"+run1+"_TS_rsds_x-t_"+isy+"-"+iey) ; open a ps plot ; gsn_define_colormap(wks,"ncl_default") ;;;;;;;;;;;;;;;;;; gsn_define_colormap(wks,"BlAqGrYeOrReVi200") res = True ; make plot mods res@gsnDraw = False res@gsnFrame = False res@cnFillOn = True ; turn on color res@cnLinesOn = False res@gsnAddCyclic = False res@vpWidthF = 0.4 res@vpHeightF = 0.6 res@gsnLeftStringFontHeightF = 0.017 res@gsnStringFont = 21 res@tiMainFont = 21 res@tiMainFontHeightF = 0.018 res@txPosYF = 0.45 res@tmXBLabelFontHeightF = 0.014 res@tmXBLabelFont = 21 ; res@trYReverse = True ; reverses y-axis res@tmYLLabelFontHeightF = 0.014 res@tmYLLabelFont = 21 res@tmYLOn = True res@tmYLMode = "Explicit" ;exit res@tmYLValues = (/ 0 , 4 , 8 , 12 , 16 , 20 , 24 , 28/) res@tmYLLabels = (/"Jan~S~0~N~","May~S~0~N~","Sep~S~0~N~","Jan~S~1~N~","May~S~1~N~","Sep~S~1~N~","Jan~S~2~N~","May~S~2~N~"/) ; res@tiYAxisString = "Depth (m)" res@tmXTOn = False res@tmYROn = False res@lbLabelsOn = True res@lbLabelBarOn = True res@lbOrientation = "vertical" res@lbLabelStride = 2 res@pmLabelBarWidthF = 0.08 res@pmLabelBarHeightF = 0.55 res@lbLabelFontHeightF = 0.012 res@lbLabelFontThicknessF = 3. res@cnInfoLabelOn = False ; res@cnLineLabelsOn = False ; res@cnLevelSelectionMode = "ExplicitLevels" ; set explicit contour levels ; res@cnLevels = (/-4.8,-3.6,-2.4,-1.2,-.6,-0.3,-.1,0,.1,0.3,.6,1.2,2.4,3.6,4.8/) ; set levels res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels res@cnMinLevelValF = -40. ; set min contour level res@cnMaxLevelValF = 40. ; set max contour level res@cnLevelSpacingF = 5. res@gsnContourZeroLineThicknessF = 3. ; doubles thickness of zero contour res@gsnContourNegLineDashPattern = 14 ; sets negative contours to dash pattern 1 ; ############################################################ pnlres = True pnlres@gsnMaximize = True ; Maximize in frame pnlres@gsnPanelBottom = 0.13 ; Leave room for labelbar pnlres@txFontThicknessF = 3. pnlres@txFont = 21 pnlres@gsnPanelLabelBar = True ; add common colorbar pnlres@lbLabelStride = 2 pnlres@pmLabelBarWidthF = 0.65 pnlres@pmLabelBarHeightF = 0.05 pnlres@lbLabelFontHeightF = 0.012 pnlres@lbLabelFontThicknessF = 3. pnlres@mpFillOn = True pnlres@mpFillColors = "black" ; pnlres@txString = run1 ; gsn_panel(wks,plot(:),(/5,1/),pnlres) ; =========================================================================== plot = new((/2/),graphic) uplot = new((/2/),graphic) res2 = res res2@cnFillOn = False ; turn on color res2@cnLinesOn = True res2@cnMinLevelValF = -4. ; set min contour level res2@cnMaxLevelValF = 4. ; set max contour level res2@cnLevelSpacingF = 0.5 ncs = dimsizes(cashi) res@tiMainString = run1 res@gsnLeftString = isy+"-"+iey+" Nino("+ncs+")" res@cnLinesOn = True res@cnLineColor = "white" res@gsnContourZeroLineThicknessF = 4.5 ; doubles thickness of zero contour plot(0) = gsn_csm_contour(wks,CopNino,res2) uplot(0) = gsn_csm_contour(wks,u10Nino,res) overlay(uplot(0),plot(0)) draw(uplot(0)) frame(wks) ; nas = dimsizes(caslo) ; res@gsnLeftString = isy+"-"+isy+" Nina("+nas+")" ; plot(1) = gsn_csm_contour(wks,CopNina,res) ; uplot(1) = gsn_csm_contour(wks,u10Nina,res2) ; overlay(plot(1),uplot(1)) ; draw(plot(1)) ; frame(wks) ; gsn_panel(wks,plot,(/1,2/),pnlres) print(wks) end