[ncl-talk] Generating weights using ESMF_regrid_gen_weights
Burakowski, Elizabeth
Elizabeth.Burakowski at unh.edu
Mon Nov 25 14:35:44 MST 2019
I'm attempting to generate weights for regridding a 4 km grid to a 14 km grid using ESMF_regrid_gen_weights.
Source grid:
Univ. Arizon Snow Depth and SWE grids
4 km rectilinear, [lat | 621] x [lon |1405]
Destination grid:
VR-CESM CONUS (already regridded using ESMF)
14 km rectilinear, [lat | 361] x [lon |560]
In the below NCL script, I use rectilinear_to_SCRIP on source and destination grids, then ESMF_regrid_gen_weights to create the weight file. No errors occur, however, when I try to regrid using ncremap, I get a bunch of zeros. I'd like to use the weight file on hundreds of files, hence using ncremap.
When I test the weight file on one source variable using NCL's ESMF_regrid_with_weights, I get an argument type mismatch error, but I can't figure out why. Any ideas how to fix this? Files are on cheyenne.
Script to generate weights:
;======================================================================
; ESMF Regrid: UA-SNOW-4km (rectilinear) to VRCESM-CONUS (rectilinear)
;======================================================================
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/esmf/ESMF_regridding.ncl"
;======================================================================
; The main code
;======================================================================
begin
;---Specify interpolation to be used
method = "patch"
;---Specify weight file name
wgtFileName = "UASnow4km2VRCESMCONUS14km_"+method+".nc"
;---Input file (Source)
srcFileDir = "/glade/work/burakows/plot/validation/UA_Snow_4km/"
srcFileName = "4km_SWE_Depth_WY2014_v01.nc" ; any UA-Snow file
srcGridName = "UASnow_4km_SCRIP.nc"
;---Retrieve a sample variable (used in plot)
sfile = addfile(srcFileDir+srcFileName,"r")
srcVarName = "SWE" ; [lat | 621] x [x | 1405]
var_in = sfile->$srcVarName$
printVarSummary(var_in)
Opt = True
Opt at ForceOverwrite = True
Opt at Title = "UA Snow 4km Grid"
;--- Convert UA Snow 4 km grid to SCRIP convention file
rectilinear_to_SCRIP(srcGridName,var_in&lat,var_in&lon,Opt)
delete(Opt)
;================================================================
;---File that contains the destination file coordinates
dstFileDir = "/glade/scratch/burakows/archive/VR-CESM_FHISTSTUB.1984-2015.CONUS30x4_prod/lnd/remap/"
dstFileName = "VR-CESM_FHISTSTUB.1984-2015.CONUS30x4_prod.clm2.h0.2014-01-01-00000_regrid.nc" ; any VR-CESM file
dstGridName = "VRCESMCONUS_14km_SCRIP.nc"
;---open VR-CESM file that contains the VR-CESM grid coordinates
dfile = addfile(dstFileDir+dstFileName,"r")
dstVarName = "H2OSNO"
dvar_in = dfile->$dstVarName$ ; [lat | 361 ] x [lon | 560]
printVarSummary(dvar_in)
Opt = True
Opt at ForceOverwrite = True
Opt at Title = "VR-CESM CONUS (14 km) grid"
;--- Convert VR-CESM CONUS 14 km to SCRIP convention file
rectilinear_to_SCRIP(dstGridName,dvar_in&lat,dvar_in&lon,Opt)
delete(Opt)
;--- Generate the weights to convert UA Snow 4 km grid to VR-CESM CONUS 14 km grid
Opt = True
Opt at InterpMethod = "patch"
Opt at ForceOverwrite = "True"
ESMF_regrid_gen_weights(srcGridName,dstGridName,wgtFileName,Opt)
delete(Opt)
end
;===============================================================
Dr. Elizabeth A Burakowski
She/Her/Hers
Research Assistant Professor
Earth Systems Research Center &
Institute for the Study of Earth, Oceans, and Space
University of New Hampshire
8 College Road Durham, NH 03824
603-862-1796
elizabeth.burakowski at unh.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191125/dffafcc7/attachment.html>
More information about the ncl-talk
mailing list