;====================================================================== ; Regridding NARR Data to Rectilinear Grid ; This script only generate ESMF weight files ; Two methods are available (bilinear and conserve) ;====================================================================== ; ; Load any files here load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" begin ;====================================================================== ; Generate NARR to Rectilinear regrid weights ; Note: The NARR has grid points with missing values ;====================================================================== InterpMethod = "conserve" ; "bilinear", "conserve" plvl = 700 ; arbitrary pressure level ;---Input file srcDirName = "./" srcFileName = "uwnd.mon.mean.nc" srcFilePath = srcDirName + srcFileName ;---Get the variable to be regridded; only need one level to generate the weight ;---Also, the grid coordinates sfile = addfile(srcFilePath,"r") x = sfile->uwnd(0,{plvl},:,:) ; time, level, y, x lat2d = sfile->lat(:,:) lon2d = sfile->lon(:,:) ;---Select time period narrtime = sfile->time narrTIME = ut_calendar(narrtime,0) narryear = floattointeger(narrTIME(:,0)) nddd = ind(narryear.ge.2000.and.narryear.le.2001) x@lat2d = lat2d ; These attributes will be used by x@lon2d = lon2d ; ESMF_regrid for the source grid ;---Create the destination rectilinear lat[*]/lon[*] arrays. ;---Create rectilinear coordinates; monotonically increasing nlat = 337 nlon = 831 lat = fspan(1.0, 85.0 ,nlat) lon = fspan( 150.0,358.5 ,nlon) ;---Create regrid options Opt = True Opt@SrcTitle = "NARR grid" ; optional Opt@WgtFileName = "NARR_to_Rect.WgtFile_"+InterpMethod+".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_description2.nc" ; Name of source and Opt@SrcRegional = True ;---If source data contains missing values, set the ;---special SrcMask2D option to indicate the missing values Opt@SrcMask2D = where(ismissing(x),0,1) DstDirName = "./" Opt@DstFileName = DstDirName + "NARR.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) x_reclin = ESMF_regrid(x, Opt) ; Do the regridding for x end