<div dir="ltr"><div><div><div><div>Sorry about the late response on this.<br><br></div>If this is categorical data, I suggest ESMF regridding using the nearest neighbor ("neareststod") method.<b><b><br><br></b></b><a href="http://www.ncl.ucar.edu/Applications/ESMF.shtml">http://www.ncl.ucar.edu/Applications/ESMF.shtml</a><b><b><br></b></b></div>See: Example 10 (<a href="http://www.ncl.ucar.edu/Applications/Scripts/ESMF_regrid_neareststod_10.ncl">ESMF_regrid_neareststod_10.ncl</a>)<br><br></div>HTH ... Good Luck<br><br></div>D<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 3, 2015 at 2:03 PM, Mary Haley <span dir="ltr"><<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-size:small">Michael,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I'm not sure what you mean by "it regrids without interpolation". I believe ESMF_regrid *is* always interpolating the data, unless I'm misunderstanding what you mean by interpolation. </div><span class="HOEnZb"><font color="#888888"><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 2, 2015 at 8:50 AM, Michael Notaro <span dir="ltr"><<a href="mailto:mnotaro@wisc.edu" target="_blank">mnotaro@wisc.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Thanks, Mary. I tried using ESMF_regrid (wasn't aware of this function before)</p>
<p>and it seemed to work well. it regrids without interpolation.</p>
<p>Michael</p><span>
<p><br>
</p>
<div>
<div style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif">
Michael Notaro<br>
<div>Associate Director<br>
</div>
<div>Nelson Institute Center for Climatic Research<br>
</div>
<div>University of Wisconsin-Madison<br>
</div>
<div>Phone: <a href="tel:%28608%29%20261-1503" value="+16082611503" target="_blank">(608) 261-1503</a><br>
</div>
<div>Email: <a href="mailto:mnotaro@wisc.edu" target="_blank">mnotaro@wisc.edu</a><br>
</div>
</div>
</div>
<br>
<br>
</span><div style="color:rgb(0,0,0)">
<hr style="display:inline-block;width:98%">
<div dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> <a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.edu</a> <<a href="mailto:ncl-talk-bounces@ucar.edu" target="_blank">ncl-talk-bounces@ucar.edu</a>> on behalf of Mary Haley <<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>><br>
<b>Sent:</b> Wednesday, December 2, 2015 9:39 AM<br>
<b>To:</b> Michael Notaro<br>
<b>Cc:</b> <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
<b>Subject:</b> Re: [ncl-talk] regridding EASE snow data</font>
<div> </div>
</div>
<div>
<div dir="ltr"><span>
<div class="gmail_default" style="font-size:small">Hi Michael,</div>
<div class="gmail_default" style="font-size:small"><br>
</div>
<div class="gmail_default" style="font-size:small">Most of our regridding routines do some sort of interpolation.</div>
<div class="gmail_default" style="font-size:small"><br>
</div>
<div class="gmail_default" style="font-size:small">You could try triple2grid, which *places* values at the nearest locations of a 2D rectilinear grid.</div>
<div class="gmail_default" style="font-size:small"><br>
</div>
<div class="gmail_default" style="font-size:small">You will need to first turn your EASE grid and it's lat/lon values into 1D variables:</div>
<div class="gmail_default" style="font-size:small"><br>
</div>
<div class="gmail_default" style="font-size:small"><font face="monospace, monospace">lat1d = ndtooned(latitude)</font></div>
<div class="gmail_default" style="font-size:small"><font face="monospace, monospace">lon1d = ndtooned(longitude)</font></div>
<div class="gmail_default" style="font-size:small"><font face="monospace, monospace">cover1d = ndtooned(cover)</font></div>
<div class="gmail_default" style="font-size:small"><font face="monospace, monospace">opt = False ; if True, then some options are available</font></div>
<div class="gmail_default" style="font-size:small"><font face="monospace, monospace"><br>
</font></div>
<div class="gmail_default" style="font-size:small"><font face="monospace, monospace">cover_regrid = triple2grid(lon1d,lat1d,cover1d,lon,lat,opt)</font></div>
<div class="gmail_default" style="font-size:small"><font face="monospace, monospace"><br>
</font></div>
<div class="gmail_default" style="font-size:small"><font face="arial, helvetica, sans-serif">I admit I've never tried this, so please let ncl-talk know if this works for you.</font></div>
<div class="gmail_default" style="font-size:small"><font face="arial, helvetica, sans-serif"><br>
</font></div>
<div class="gmail_default" style="font-size:small"><font face="arial, helvetica, sans-serif">You can see what "opt" options are available:</font></div>
<div class="gmail_default" style="font-size:small"><font face="arial, helvetica, sans-serif"><br>
</font></div>
</span><div class="gmail_default"><font face="arial, helvetica, sans-serif"><a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/triple2grid.shtml" target="_blank">http://www.ncl.ucar.edu/Document/Functions/Built-in/triple2grid.shtml</a>
<div style="margin-top:20px;margin-bottom:20px;overflow:auto;width:100%">
<table style="border-top-color:rgb(204,204,204);border-top-width:1px;border-top-style:solid;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204,204,204);width:80%;overflow:auto;background-color:rgb(255,255,255)">
<tbody>
<tr style="border-spacing:0px" valign="top">
<td>
<div style="margin-top:8px;font-size:21px;font-family:wf_segoe-ui_semilight,'Segoe UI Semilight','Segoe WP Semilight','Segoe UI','Segoe WP',Tahoma,Arial,sans-serif;color:rgb(51,51,51);margin-left:14px;margin-right:14px">
triple2grid - University Corporation for Atmospheric Research</div>
<div style="margin-top:8px;font-size:13px;font-family:wf_segoe-ui_normal,'Segoe UI','Segoe WP',Tahoma,Arial,sans-serif;color:rgb(102,102,102);margin-left:14px;margin-right:14px">
NCL Home > Documentation > Functions > Regridding triple2grid. Places unstructured (randomly-spaced) data onto the nearest locations of a rectilinear grid.</div>
<div style="margin:8px 14px 10px;min-height:18px;text-overflow:ellipsis;overflow:hidden;white-space:nowrap">
<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/triple2grid.shtml" style="font-size:11px;font-family:wf_segoe-ui_normal,'Segoe UI','Segoe WP',Tahoma,Arial,sans-serif;text-decoration:none" target="_blank">Read
more...</a></div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
</font></div>
<div class="gmail_default" style="font-size:small"><font face="arial, helvetica, sans-serif"><br>
</font></div>
<div class="gmail_default" style="font-size:small">--Mary</div>
<div class="gmail_default" style="font-size:small"><br>
</div>
</div><div><div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Dec 1, 2015 at 12:02 PM, Michael Notaro <span dir="ltr">
<<a href="mailto:mnotaro@wisc.edu" target="_blank">mnotaro@wisc.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Does anyone have a suggestions for quickly regridding </p>
<p>EASE snow cover data, with the following characteristics,</p>
<p><br>
</p>
<p>latitude(720 rows, 720 columns)</p>
<p>longitude(720 rows, 720 columns)</p>
<p>cover(720 rows, 720 columns)</p>
<p><br>
</p>
<p>to a new 0.2 degree x 0.2 degree grid, with the following</p>
<p>characteristics?</p>
<p><br>
</p>
<p>lat=fspan(0.,90.,451)</p>
<p>lon=fspan(0.,180.,901)</p>
<p>grid(451,901)</p>
<p><br>
</p>
<p>It needs to be regridded, not interpolated, as</p>
<p>the values are 10 for snow covered land and</p>
<p>20 for non-snow covered land.</p>
<p><br>
</p>
<p>I've tried using getind_latlon2d within dual</p>
<p>do loops, but it was extremely slow.</p>
<p><br>
</p>
<p>My latest attempt is below, using mask</p>
<p>to reduce data to only nearby locations.</p>
<p>In this case, I am trying to regrid 14 years </p>
<p>worth of daily snow cover. </p>
<p><br>
</p>
<p>Thanks, Michael</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p></p>
<p>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</p>
<p>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</p>
<p>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</p>
<p>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"</p>
<p>begin</p>
<p><br>
</p>
<p>cvr=new((/14,12,31,720,720/),float)</p>
<p>cvr@_FillValue=1e+35</p>
<p>cvr=1e+35</p>
<p><br>
</p>
<p>a=addfile("1999/<a href="http://nhtsd25e2_19990101_v01r01.nc" target="_blank">nhtsd25e2_19990101_v01r01.nc</a>","r")</p>
<p>latitude=a->latitude ; (rows,cols)</p>
<p>longitude=a->longitude</p>
<p><br>
</p>
<p>do iyr=0,13</p>
<p> do imn=0,11</p>
<p> do id=0,30</p>
<p> years=iyr+1999</p>
<p> if (imn.le.8) then</p>
<p> months="0"+(imn+1)</p>
<p> else</p>
<p> months=""+(imn+1)</p>
<p> end if</p>
<p> if (id.le.8) then</p>
<p> days="0"+(id+1)</p>
<p> else</p>
<p> days=""+(id+1)</p>
<p> end if</p>
<p> filen=""+years+"/nhtsd25e2_"+years+""+months+""+days+"_<a href="http://v01r01.nc" target="_blank">v01r01.nc</a>"</p>
<p> if (isfilepresent(filen)) then</p>
<p> a=addfile(filen,"r")</p>
<p> cvr(iyr,imn,id,:,:)=byte2flt(a->ims_snow_cover_extent(0,:,:)) ; byte (time, 720 rows, 720 cols) 10=snow covered land; 20=snow free land</p>
<p> end if</p>
<p> end do</p>
<p> end do</p>
<p>end do</p>
<p><br>
</p>
<p>lat=fspan(0.,90.,451)</p>
<p>lat!0="lat"</p>
<p>lat@units="degrees_north"</p>
<p>lat&lat=lat</p>
<p><br>
</p>
<p>lon=fspan(0.,180.,901)</p>
<p>lon!0="lon"</p>
<p>lon@units="degrees_east"</p>
<p>lon@lon=lon</p>
<p><br>
</p>
<p>grid=new((/14,12,31,451,901/),float)</p>
<p>grid@_FillValue=1e+35</p>
<p>grid=1e+35</p>
<p><br>
</p>
<p>do i=0,450</p>
<p> do j=0,900</p>
<p><br>
</p>
<p> cover=mask(cvr,latitude.ge.lat(i)+0.5,False)</p>
<p> cover=mask(cover,latitude.le.lat(i)-0.5,False)</p>
<p> cover=mask(cover,longitude.ge.lon(j)+0.5,False)</p>
<p> cover=mask(cover,longitude.le.lon(j)-0.5,False)</p>
<p><br>
</p>
<p> do iyr=0,13</p>
<p> do imn=0,11</p>
<p> do id=0,30</p>
<p><br>
</p>
<p> snow=num(cover(iyr,imn,id,:,:).eq.10)</p>
<p> nosnow=num(cover(iyr,imn,id,:,:).eq.20)</p>
<p> combined=snow+nosnow</p>
<p><br>
</p>
<p> if (combined.gt.0) then</p>
<p> if (snow.ge.nosnow) then</p>
<p> grid(iyr,imn,id,i,j)=100.</p>
<p> else</p>
<p> grid(iyr,imn,id,i,j)=0.</p>
<p> end if</p>
<p> end if</p>
<p><br>
</p>
<p> end do</p>
<p> end do</p>
<p> end do</p>
<p><br>
</p>
<p> end do</p>
<p>end do</p>
<p></p>
<p>year=ispan(1999,2012,1)</p>
<p>year!0="year"</p>
<p>year&year=year</p>
<p>month=ispan(1,12,1)</p>
<p>month!0="month"</p>
<p>month&month=month</p>
<p>day=ispan(1,31,1)</p>
<p>day!0="day"</p>
<p>day&day=day</p>
<p><br>
</p>
<p>grid!0="year"</p>
<p>grid!1="month"</p>
<p>grid!2="day"</p>
<p>grid!3="lat"</p>
<p>grid!4="lon"</p>
<p>grid&year=year</p>
<p>grid&month=month</p>
<p>grid&day=day</p>
<p>grid&lat=lat</p>
<p>grid&lon=lon</p>
<p><br>
</p>
<p>system("rm <a href="http://climo_snowcover_asia.nc" target="_blank">climo_snowcover_asia.nc</a>")</p>
<p>out=addfile("<a href="http://climo_snowcover_asia.nc" target="_blank">climo_snowcover_asia.nc</a>","c")</p>
<p>out->grid=grid</p>
<span><font color="#888888"><br>
<p></p>
<p></p>
<p><br>
</p>
<p><br>
</p>
<div>
<div style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif">
Michael Notaro<br>
<div>Associate Director<br>
</div>
<div>Nelson Institute Center for Climatic Research<br>
</div>
<div>University of Wisconsin-Madison<br>
</div>
<div>Phone: <a href="tel:%28608%29%20261-1503" value="+16082611503" target="_blank">
(608) 261-1503</a><br>
</div>
<div>Email: <a href="mailto:mnotaro@wisc.edu" target="_blank">mnotaro@wisc.edu</a><br>
</div>
</div>
</div>
</font></span></div>
</div>
<br>
_______________________________________________<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><br>
<br>
</blockquote>
</div>
<br>
</div>
</div></div></div>
</div>
</div>
</div>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">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><br>
<br></blockquote></div><br></div>