<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Thanks, Mary. &nbsp;I tried using ESMF_regrid (wasn't aware of this function before)</p>
<p>and it seemed to work well. &nbsp;it regrids without interpolation.</p>
<p>Michael</p>
<p><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" 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: (608) 261-1503<br>
</div>
<div>Email: mnotaro@wisc.edu<br>
</div>
</div>
</div>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> ncl-talk-bounces@ucar.edu &lt;ncl-talk-bounces@ucar.edu&gt; on behalf of Mary Haley &lt;haley@ucar.edu&gt;<br>
<b>Sent:</b> Wednesday, December 2, 2015 9:39 AM<br>
<b>To:</b> Michael Notaro<br>
<b>Cc:</b> ncl-talk@ucar.edu<br>
<b>Subject:</b> Re: [ncl-talk] regridding EASE snow data</font>
<div>&nbsp;</div>
</div>
<div>
<div dir="ltr">
<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 &nbsp; &nbsp;= ndtooned(latitude)</font></div>
<div class="gmail_default" style="font-size:small"><font face="monospace, monospace">lon1d &nbsp; &nbsp;= ndtooned(longitude)</font></div>
<div class="gmail_default" style="font-size:small"><font face="monospace, monospace">cover1d &nbsp;= ndtooned(cover)</font></div>
<div class="gmail_default" style="font-size:small"><font face="monospace, monospace">opt &nbsp; &nbsp; &nbsp;= False &nbsp;; 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 &quot;opt&quot; options are available:</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 face="arial, helvetica, sans-serif"><a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/triple2grid.shtml" id="LPlnk581382">http://www.ncl.ucar.edu/Document/Functions/Built-in/triple2grid.shtml</a>
<div id="LPBorder_GT_14490713899610.9890013893600553" style="margin-top: 20px; margin-bottom: 20px; overflow: auto; width: 100%;">
<table id="LPContainer_14490713899600.2751343180425465" 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%; position: relative; overflow: auto; background-color: rgb(255, 255, 255);">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td>
<div id="LPTitle_14490713899600.7759499119129032" style="top: 0px; 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 id="LPDescription_14490713899610.27283724467270076" 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 &gt; Documentation &gt; Functions &gt; Regridding triple2grid. Places unstructured (randomly-spaced) data onto the nearest locations of a rectilinear grid.</div>
<div id="LPUrlContainer_14490713899610.9059307491406798" style="margin: 8px 14px 10px; height: 18px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;">
<a id="LPUrlAnchor_14490713899610.28696489124558866" href="http://www.ncl.ucar.edu/Document/Functions/Built-in/triple2grid.shtml" target="_blank" style="font-size: 11px; font-family: wf_segoe-ui_normal, 'Segoe UI', 'Segoe WP', Tahoma, Arial, sans-serif; text-decoration: none;">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 class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Dec 1, 2015 at 12:02 PM, Michael Notaro <span dir="ltr">
&lt;<a href="mailto:mnotaro@wisc.edu" target="_blank">mnotaro@wisc.edu</a>&gt;</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&nbsp;</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&nbsp;</p>
<p>worth of daily snow cover. &nbsp;</p>
<p><br>
</p>
<p>Thanks, Michael</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p></p>
<p>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;</p>
<p>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl&quot;</p>
<p>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot;</p>
<p>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl&quot;</p>
<p>begin</p>
<p><br>
</p>
<p>cvr=new((/14,12,31,720,720/),float)</p>
<p>cvr@_FillValue=1e&#43;35</p>
<p>cvr=1e&#43;35</p>
<p><br>
</p>
<p>a=addfile(&quot;1999/<a href="http://nhtsd25e2_19990101_v01r01.nc" target="_blank">nhtsd25e2_19990101_v01r01.nc</a>&quot;,&quot;r&quot;)</p>
<p>latitude=a-&gt;latitude ; (rows,cols)</p>
<p>longitude=a-&gt;longitude</p>
<p><br>
</p>
<p>do iyr=0,13</p>
<p>&nbsp; do imn=0,11</p>
<p>&nbsp; &nbsp; do id=0,30</p>
<p>&nbsp; &nbsp; &nbsp; years=iyr&#43;1999</p>
<p>&nbsp; &nbsp; &nbsp; if (imn.le.8) then</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; months=&quot;0&quot;&#43;(imn&#43;1)</p>
<p>&nbsp; &nbsp; &nbsp; else</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; months=&quot;&quot;&#43;(imn&#43;1)</p>
<p>&nbsp; &nbsp; &nbsp; end if</p>
<p>&nbsp; &nbsp; &nbsp; if (id.le.8) then</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; days=&quot;0&quot;&#43;(id&#43;1)</p>
<p>&nbsp; &nbsp; &nbsp; else</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; days=&quot;&quot;&#43;(id&#43;1)</p>
<p>&nbsp; &nbsp; &nbsp; end if</p>
<p>&nbsp; &nbsp; &nbsp; filen=&quot;&quot;&#43;years&#43;&quot;/nhtsd25e2_&quot;&#43;years&#43;&quot;&quot;&#43;months&#43;&quot;&quot;&#43;days&#43;&quot;_<a href="http://v01r01.nc" target="_blank">v01r01.nc</a>&quot;</p>
<p>&nbsp; &nbsp; &nbsp; if (isfilepresent(filen)) then</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; a=addfile(filen,&quot;r&quot;)</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; cvr(iyr,imn,id,:,:)=byte2flt(a-&gt;ims_snow_cover_extent(0,:,:)) ; byte (time, 720 rows, 720 cols) 10=snow covered land; 20=snow free land</p>
<p>&nbsp; &nbsp; &nbsp; end if</p>
<p>&nbsp; &nbsp; end do</p>
<p>&nbsp; end do</p>
<p>end do</p>
<p><br>
</p>
<p>lat=fspan(0.,90.,451)</p>
<p>lat!0=&quot;lat&quot;</p>
<p>lat@units=&quot;degrees_north&quot;</p>
<p>lat&amp;lat=lat</p>
<p><br>
</p>
<p>lon=fspan(0.,180.,901)</p>
<p>lon!0=&quot;lon&quot;</p>
<p>lon@units=&quot;degrees_east&quot;</p>
<p>lon@lon=lon</p>
<p><br>
</p>
<p>grid=new((/14,12,31,451,901/),float)</p>
<p>grid@_FillValue=1e&#43;35</p>
<p>grid=1e&#43;35</p>
<p><br>
</p>
<p>do i=0,450</p>
<p>&nbsp; do j=0,900</p>
<p><br>
</p>
<p>&nbsp; &nbsp; cover=mask(cvr,latitude.ge.lat(i)&#43;0.5,False)</p>
<p>&nbsp; &nbsp; cover=mask(cover,latitude.le.lat(i)-0.5,False)</p>
<p>&nbsp; &nbsp; cover=mask(cover,longitude.ge.lon(j)&#43;0.5,False)</p>
<p>&nbsp; &nbsp; cover=mask(cover,longitude.le.lon(j)-0.5,False)</p>
<p><br>
</p>
<p>&nbsp; &nbsp; do iyr=0,13</p>
<p>&nbsp; &nbsp; &nbsp; do imn=0,11</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; do id=0,30</p>
<p><br>
</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; snow=num(cover(iyr,imn,id,:,:).eq.10)</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nosnow=num(cover(iyr,imn,id,:,:).eq.20)</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; combined=snow&#43;nosnow</p>
<p><br>
</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (combined.gt.0) then</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (snow.ge.nosnow) then</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; grid(iyr,imn,id,i,j)=100.</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; grid(iyr,imn,id,i,j)=0.</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end if</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end if</p>
<p><br>
</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; end do</p>
<p>&nbsp; &nbsp; &nbsp; end do</p>
<p>&nbsp; &nbsp; end do</p>
<p><br>
</p>
<p>&nbsp; end do</p>
<p>end do</p>
<p></p>
<p>year=ispan(1999,2012,1)</p>
<p>year!0=&quot;year&quot;</p>
<p>year&amp;year=year</p>
<p>month=ispan(1,12,1)</p>
<p>month!0=&quot;month&quot;</p>
<p>month&amp;month=month</p>
<p>day=ispan(1,31,1)</p>
<p>day!0=&quot;day&quot;</p>
<p>day&amp;day=day</p>
<p><br>
</p>
<p>grid!0=&quot;year&quot;</p>
<p>grid!1=&quot;month&quot;</p>
<p>grid!2=&quot;day&quot;</p>
<p>grid!3=&quot;lat&quot;</p>
<p>grid!4=&quot;lon&quot;</p>
<p>grid&amp;year=year</p>
<p>grid&amp;month=month</p>
<p>grid&amp;day=day</p>
<p>grid&amp;lat=lat</p>
<p>grid&amp;lon=lon</p>
<p><br>
</p>
<p>system(&quot;rm <a href="http://climo_snowcover_asia.nc" target="_blank">climo_snowcover_asia.nc</a>&quot;)</p>
<p>out=addfile(&quot;<a href="http://climo_snowcover_asia.nc" target="_blank">climo_snowcover_asia.nc</a>&quot;,&quot;c&quot;)</p>
<p>out-&gt;grid=grid</p>
<span class="HOEnZb"><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="&#43;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">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>
</body>
</html>