<div dir="ltr"><div>I have not looked carefully at this.</div><div><br></div><div>[1] <b><br></b></div><div><b>The SWE variable is type short. </b><br></div><div><br></div><div> <span style="color:rgb(0,0,255)"><b>short </b></span>SWE(time, lat, lon) ;<br> SWE:_FillValue = -999s ;<br> SWE:long_name = "Snow Water Equivalent" ;<br> SWE:grid_mapping = "crs" ;<br> SWE:units = "millimeters h20" ;<br></div><div><br></div><div><b>You *must* unpack before use.</b></div><div><pre></pre></div><div>swe =<a href="https://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml"> <b>short2flt</b></a>(sfile->SWE)</div><div>or, for a focused regional subset<br></div><div>swe = <b>short2flt</b>(sfile->SWE({latS:latN},{lonW:lonE}))</div><div><br></div><div>===</div><div>[2] <b><br></b></div><div><b>ncremap</b> is a netCDF Operator. It looks like you want the weights generated by NCL's <b>ESMF </b>regrid package.</div><div>Are the weight files compatible?</div><div><br></div><div>===</div><div><br></div><div>D<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 25, 2019 at 2:35 PM Burakowski, Elizabeth via ncl-talk <<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I'm attempting to generate weights for regridding a 4 km grid to a 14 km grid using ESMF_regrid_gen_weights.
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Source grid:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Univ. Arizon Snow Depth and SWE grids<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
4 km rectilinear, [lat | 621] x [lon |1405]</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Destination grid:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
VR-CESM CONUS (already regridded using ESMF)</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
14 km rectilinear, [lat | 361] x [lon |560]</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
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. <br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
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.
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Script to generate weights:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span>;======================================================================<br>
</span>
<div>; ESMF Regrid: UA-SNOW-4km (rectilinear) to VRCESM-CONUS (rectilinear)<br>
</div>
<div>;======================================================================<br>
</div>
<div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>
</div>
<div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>
</div>
<div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br>
</div>
<div>load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl"<br>
</div>
<div><br>
</div>
<div>;======================================================================<br>
</div>
<div>; The main code<br>
</div>
<div>;======================================================================<br>
</div>
<div><br>
</div>
<div>begin<br>
</div>
<div>;---Specify interpolation to be used<br>
</div>
<div> method = "patch"<br>
</div>
<div><br>
</div>
<div>;---Specify weight file name<br>
</div>
<div> wgtFileName = "UASnow4km2VRCESMCONUS14km_"+method+".nc"<br>
</div>
<div><br>
</div>
<div>;---Input file (Source)<br>
</div>
<div> srcFileDir = "/glade/work/burakows/plot/validation/UA_Snow_4km/"<br>
</div>
<div> srcFileName = "4km_SWE_Depth_WY2014_v01.nc" ; any UA-Snow file<br>
</div>
<div> srcGridName = "UASnow_4km_SCRIP.nc"<br>
</div>
<div><br>
</div>
<div>;---Retrieve a sample variable (used in plot)<br>
</div>
<div> sfile = addfile(srcFileDir+srcFileName,"r")<br>
</div>
<div> srcVarName = "SWE" ; [lat | 621] x [x | 1405]<br>
</div>
<div> var_in = sfile->$srcVarName$<br>
</div>
<div> printVarSummary(var_in)<br>
</div>
<div><br>
</div>
<div> Opt = True<br>
</div>
<div> Opt@ForceOverwrite = True<br>
</div>
<div> Opt@Title = "UA Snow 4km Grid"<br>
</div>
<div><br>
</div>
<div>;--- Convert UA Snow 4 km grid to SCRIP convention file<br>
</div>
<div> rectilinear_to_SCRIP(srcGridName,var_in&lat,var_in&lon,Opt)<br>
</div>
<div> delete(Opt)<br>
</div>
<div><br>
</div>
<div>;================================================================<br>
</div>
<div><br>
</div>
<div>;---File that contains the destination file coordinates<br>
</div>
<div> dstFileDir = "/glade/scratch/burakows/archive/VR-CESM_FHISTSTUB.1984-2015.CONUS30x4_prod/lnd/remap/"<br>
</div>
<div> dstFileName = "<a href="http://VR-CESM_FHISTSTUB.1984-2015.CONUS30x4_prod.clm2.h0.2014-01-01-00000_regrid.nc" target="_blank">VR-CESM_FHISTSTUB.1984-2015.CONUS30x4_prod.clm2.h0.2014-01-01-00000_regrid.nc</a>" ; any VR-CESM file<br>
</div>
<div> dstGridName = "VRCESMCONUS_14km_SCRIP.nc"<br>
</div>
<span></span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span><br>
</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span>;---open VR-CESM file that contains the VR-CESM grid coordinates<br>
</span>
<div> dfile = addfile(dstFileDir+dstFileName,"r")<br>
</div>
<div> dstVarName = "H2OSNO"<br>
</div>
<div> dvar_in = dfile->$dstVarName$ ; [lat | 361 ] x [lon | 560]<br>
</div>
<div> printVarSummary(dvar_in)<br>
</div>
<div><br>
</div>
<div> Opt = True<br>
</div>
<div> Opt@ForceOverwrite = True<br>
</div>
<div> Opt@Title = "VR-CESM CONUS (14 km) grid"<br>
</div>
<div><br>
</div>
<div>;--- Convert VR-CESM CONUS 14 km to SCRIP convention file<br>
</div>
<div> rectilinear_to_SCRIP(dstGridName,dvar_in&lat,dvar_in&lon,Opt)<br>
</div>
<div> delete(Opt)<br>
</div>
<div><br>
</div>
<div><span>;--- Generate the weights to convert UA Snow 4 km grid to VR-CESM CONUS 14 km grid<br>
</span>
<div><br>
</div>
<div> Opt = True<br>
</div>
<div> Opt@InterpMethod = "patch"<br>
</div>
<div> Opt@ForceOverwrite = "True"<br>
</div>
<div><br>
</div>
<div> ESMF_regrid_gen_weights(srcGridName,dstGridName,wgtFileName,Opt)<br>
</div>
<div> delete(Opt)<br>
</div>
<span></span>end</div>
<div><br>
</div>
<span>;===============================================================</span><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div id="gmail-m_-3375074179553437793Signature">
<div></div>
<div name="divtagdefaultwrapper">
<font face="Corbel, sans-serif">Dr. Elizabeth A Burakowski</font></div>
<div name="divtagdefaultwrapper">
<font face="Corbel, sans-serif">She/Her/Hers<br>
</font>
<div><font face="Corbel, sans-serif">Research Assistant Professor</font></div>
<div><font face="Corbel, sans-serif">Earth Systems Research Center & </font></div>
<div><font face="Corbel, sans-serif">Institute for the Study of Earth, Oceans, and Space</font></div>
<div><font face="Corbel, sans-serif">University of New Hampshire</font></div>
<div><font face="Corbel, sans-serif">8 College Road Durham, NH 03824</font></div>
<div><font face="Corbel, sans-serif">603-862-1796</font></div>
<div><font face="Corbel, sans-serif"><a href="mailto:elizabeth.burakowski@unh.edu" target="_blank">elizabeth.burakowski@unh.edu</a></font></div>
</div>
</div>
</div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>