<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>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 class="p1">load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;</p>
<p class="p1">load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl&quot;</p>
<p class="p1">load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot;</p>
<p class="p1">load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl&quot;</p>
<p class="p1">begin</p>
<p class="p2"><br>
</p>
<p class="p1">cvr=new((/14,12,31,720,720/),float)</p>
<p class="p1">cvr@_FillValue=1e&#43;35</p>
<p class="p1">cvr=1e&#43;35</p>
<p class="p2"><br>
</p>
<p class="p1">a=addfile(&quot;1999/nhtsd25e2_19990101_v01r01.nc&quot;,&quot;r&quot;)</p>
<p class="p1">latitude=a-&gt;latitude ; (rows,cols)</p>
<p class="p1">longitude=a-&gt;longitude</p>
<p class="p2"><br>
</p>
<p class="p1">do iyr=0,13</p>
<p class="p1">&nbsp; do imn=0,11</p>
<p class="p1">&nbsp; &nbsp; do id=0,30</p>
<p class="p1">&nbsp; &nbsp; &nbsp; years=iyr&#43;1999</p>
<p class="p1">&nbsp; &nbsp; &nbsp; if (imn.le.8) then</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; months=&quot;0&quot;&#43;(imn&#43;1)</p>
<p class="p1">&nbsp; &nbsp; &nbsp; else</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; months=&quot;&quot;&#43;(imn&#43;1)</p>
<p class="p1">&nbsp; &nbsp; &nbsp; end if</p>
<p class="p1">&nbsp; &nbsp; &nbsp; if (id.le.8) then</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; days=&quot;0&quot;&#43;(id&#43;1)</p>
<p class="p1">&nbsp; &nbsp; &nbsp; else</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; days=&quot;&quot;&#43;(id&#43;1)</p>
<p class="p1">&nbsp; &nbsp; &nbsp; end if</p>
<p class="p1">&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;_v01r01.nc&quot;</p>
<p class="p1">&nbsp; &nbsp; &nbsp; if (isfilepresent(filen)) then</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; a=addfile(filen,&quot;r&quot;)</p>
<p class="p1">&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 class="p1">&nbsp; &nbsp; &nbsp; end if</p>
<p class="p1">&nbsp; &nbsp; end do</p>
<p class="p1">&nbsp; end do</p>
<p class="p1">end do</p>
<p class="p2"><br>
</p>
<p class="p1">lat=fspan(0.,90.,451)</p>
<p class="p1">lat!0=&quot;lat&quot;</p>
<p class="p1">lat@units=&quot;degrees_north&quot;</p>
<p class="p1">lat&amp;lat=lat</p>
<p class="p2"><br>
</p>
<p class="p1">lon=fspan(0.,180.,901)</p>
<p class="p1">lon!0=&quot;lon&quot;</p>
<p class="p1">lon@units=&quot;degrees_east&quot;</p>
<p class="p1">lon@lon=lon</p>
<p class="p2"><br>
</p>
<p class="p1">grid=new((/14,12,31,451,901/),float)</p>
<p class="p1">grid@_FillValue=1e&#43;35</p>
<p class="p1">grid=1e&#43;35</p>
<p class="p2"><br>
</p>
<p class="p1">do i=0,450</p>
<p class="p1">&nbsp; do j=0,900</p>
<p class="p2"><br>
</p>
<p class="p1">&nbsp; &nbsp; cover=mask(cvr,latitude.ge.lat(i)&#43;0.5,False)</p>
<p class="p1">&nbsp; &nbsp; cover=mask(cover,latitude.le.lat(i)-0.5,False)</p>
<p class="p1">&nbsp; &nbsp; cover=mask(cover,longitude.ge.lon(j)&#43;0.5,False)</p>
<p class="p1">&nbsp; &nbsp; cover=mask(cover,longitude.le.lon(j)-0.5,False)</p>
<p class="p2"><br>
</p>
<p class="p1">&nbsp; &nbsp; do iyr=0,13</p>
<p class="p1">&nbsp; &nbsp; &nbsp; do imn=0,11</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; do id=0,30</p>
<p class="p2"><br>
</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; snow=num(cover(iyr,imn,id,:,:).eq.10)</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nosnow=num(cover(iyr,imn,id,:,:).eq.20)</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; combined=snow&#43;nosnow</p>
<p class="p2"><br>
</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (combined.gt.0) then</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (snow.ge.nosnow) then</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; grid(iyr,imn,id,i,j)=100.</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; grid(iyr,imn,id,i,j)=0.</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end if</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end if</p>
<p class="p2"><br>
</p>
<p class="p1">&nbsp; &nbsp; &nbsp; &nbsp; end do</p>
<p class="p1">&nbsp; &nbsp; &nbsp; end do</p>
<p class="p1">&nbsp; &nbsp; end do</p>
<p class="p2"><br>
</p>
<p class="p1">&nbsp; end do</p>
<p class="p1">end do</p>
<p class="p1"></p>
<p class="p1">year=ispan(1999,2012,1)</p>
<p class="p1">year!0=&quot;year&quot;</p>
<p class="p1">year&amp;year=year</p>
<p class="p1">month=ispan(1,12,1)</p>
<p class="p1">month!0=&quot;month&quot;</p>
<p class="p1">month&amp;month=month</p>
<p class="p1">day=ispan(1,31,1)</p>
<p class="p1">day!0=&quot;day&quot;</p>
<p class="p1">day&amp;day=day</p>
<p class="p2"><br>
</p>
<p class="p1">grid!0=&quot;year&quot;</p>
<p class="p1">grid!1=&quot;month&quot;</p>
<p class="p1">grid!2=&quot;day&quot;</p>
<p class="p1">grid!3=&quot;lat&quot;</p>
<p class="p1">grid!4=&quot;lon&quot;</p>
<p class="p1">grid&amp;year=year</p>
<p class="p1">grid&amp;month=month</p>
<p class="p1">grid&amp;day=day</p>
<p class="p1">grid&amp;lat=lat</p>
<p class="p1">grid&amp;lon=lon</p>
<p class="p2"><br>
</p>
<p class="p1">system(&quot;rm climo_snowcover_asia.nc&quot;)</p>
<p class="p1">out=addfile(&quot;climo_snowcover_asia.nc&quot;,&quot;c&quot;)</p>
<p class="p1">out-&gt;grid=grid</p>
<br>
<p></p>
<p></p>
<p><br>
</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>
</div>
</body>
</html>