var = "prate" yyyy = 1987 diri = "./" fili = var+"."+yyyy+".nc" pthi = diri+fili print(pthi) f1 = addfiles (pthi, "r") ; note the "s" of addfile ListSetType (f1, "cat") ; "cat' is fefault prc = f1[:]->prate ; read variable from all files printVarSummary (prc) delete(prc&x) ; delete so NCL graphics don't get confused delete(prc&y) printVarSummary (prc) printMinMax(prc,0) print("----------") if (var.eq."prate") then prc = where(prc.lt.0.0, 0.0, prc) printMinMax(prc,0) end if print("----------") lon2d = f1[0]->lon ; read NARR longitude from 1st file lat2d = f1[0]->lat ; read NARR latitude printVarSummary (lat2d) ; NARR grid printMinMax(lat2d,0) print("----------") printVarSummary (lon2d) printMinMax(lon2d,0) print("----------") lon2d = where(lon2d.ge.0, lon2d, lon2d+360.) ; not necessary printVarSummary (lon2d) printMinMax(lon2d,0) print("----------") ;---Calculate monthly values from daily values prcMon = calculate_monthly_values (prc, "avg", 0,True) printVarSummary(prcMon) printMinMax(prcMon,0) print("----------") ;---Calculate JJA seasonal values prcJJA = month_to_season (prcMon, "JJA") prcJJA@long_name = "JJA Seasonal Total" printVarSummary(prcJJA) ;---Change units if (var.eq."prate") then ; kg/m^2 => mm ; kg/m^2/s" ==> mm/s prcJJA = prcJJA*86400*92 ; (mm/s)(s/day)(day) prcJJA@units = "mm" ; Seasonal Total end if printVarSummary(prcJJA) printMinMax(prcJJA,0) print("----------") ;---Examine distribution opt_sd = True opt_sd@PrintStat = True statJJA = stat_dispersion(prcJJA, opt_sd ) print("----------") nmsgJJA = num(ismissing(prcJJA)) ; any missing values? print("nmsgJJA="+nmsgJJA) print("----------") yyyymm = cd_calendar(prcJJA&time, -1) ;------------------------------------------ ;---ESMF regrid ;------------------------------------------ ;-- define the destination grid nlat = 190 ;-- number of latitudes nlon = 384 ;-- number of longitudes nlat@double = True nlon@double = True lat = latGlobeFo(nlat, "lat", "latitude", "degrees_north") lon = lonGlobeFo(nlon, "lon", "longitude", "degrees_east") ;;print(lat) ;;print("----------") ;;print(lon) ;;print("----------") ;---Create regrid options InterpMethod = "bilinear" Opt = True Opt@SrcTitle = "NARR grid to Rectilinear: "+InterpMethod ; optional Opt@WgtFileName = "NARR_to_Rect.WgtFile_"+InterpMethod+"."+nlat+"x"+nlon+".nc" ;---Generate the names of the files containing the source and destination grid descriptions ;---Remove after Part A is complete Opt@SrcFileName = "NARR.SCRIP_grid_description.nc" ; Name of source and ;---If source data contains missing values, set the ;---special SrcMask2D option to indicate the missing values if (nmsgJJA.gt.0) then Opt@SrcMask2D = where(ismissing(prcJJA),0,1) end if Opt@SrcGridType = "curvilinear" Opt@SrcGridLat = lat2d Opt@SrcGridLon = lon2d Opt@SrcRegional = True DstDirName = "./" Opt@DstFileName = DstDirName + "Rectilinear.SCRIP_grid_description.nc" Opt@DstGridType = "rectilinear" Opt@DstGridLat = lat Opt@DstGridLon = lon Opt@DstRegional = True ;---Specify other options Opt@ForceOverwrite = True Opt@InterpMethod = InterpMethod Opt@RemoveSrcFile = True ; remove SCRIP grid destination files Opt@RemoveDstFile = True Opt@NoPETLog = True ; 6.2.1 onward ;---Perform the regrid: NARR ==> rectilinear (_reclin) prcJJA_regrid = ESMF_regrid(prcJJA, Opt) ; NARR to rectilinear printVarSummary(prcJJA_regrid) printMinMax(prcJJA_regrid,0) print("-------------------") ;************************************************ ; create plots ;************************************************ wks = gsn_open_wks("png","NARR_JJA_panel") ; send graphics to PNG file plot= new( 2, "graphic") res = True res@gsnDraw = False res@gsnFrame = False res@gsnAddCyclic = False ; regional data res@cnInfoLabelOn = False ; turn off cn info label res@cnFillOn = True ; turn on color res@cnFillMode = "RasterFill" res@cnLinesOn = False res@cnLineLabelsOn = False res@cnLevelSelectionMode = "ExplicitLevels" res@cnLevels = (/25,50,75,100,150,200,250,300,350,400,450,500,750,1000/) res@cnFillPalette = "WhiteBlueGreenYellowRed" res@lbLabelBarOn = False ; turn off individual cb's res@mpFillOn = False res@mpMinLatF = min(lat2d) ; range to zoom in on res@mpMaxLatF = max(lat2d) res@mpMinLonF = min(lon2d) res@mpMaxLonF = max(lon2d) res@mpCenterLonF = 253.0 res@sfXArray = lon2d ; NARR curvilinear grid res@sfYArray = lat2d res@gsnLeftString = "" res@gsnRightString= "" nt = 0 ; first prcJJA yyyy = yyyymm(nt)/100 res@gsnCenterString= "Source NARR" plot(0) = gsn_csm_contour_map(wks,prcJJA(nt,:,:) ,res) delete( [/ res@sfXArray , res@sfYArray /] ) ; next grid is rectilinear res@gsnCenterString= "NARR: Rectilinear Grid: "+InterpMethod+": "+nlat+"x"+nlon plot(1) = gsn_csm_contour_map(wks,prcJJA_regrid(nt,:,:) ,res) resP = True ; modify the panel plot resP@gsnMaximize = True resP@gsnPanelMainString = "JJA ("+yyyy+"): Total Precipitation (mm)" resP@gsnPanelLabelBar = True ; add common colorbar resP@pmLabelBarWidthF = 0.75 resP@lbLabelFontHeightF = 0.0125 gsn_panel(wks,plot,(/2,1/),resP) ; now draw as one plot