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