[ncl-talk] regridding EASE snow data
Michael Notaro
mnotaro at wisc.edu
Tue Dec 1 12:02:26 MST 2015
Does anyone have a suggestions for quickly regridding
EASE snow cover data, with the following characteristics,
latitude(720 rows, 720 columns)
longitude(720 rows, 720 columns)
cover(720 rows, 720 columns)
to a new 0.2 degree x 0.2 degree grid, with the following
characteristics?
lat=fspan(0.,90.,451)
lon=fspan(0.,180.,901)
grid(451,901)
It needs to be regridded, not interpolated, as
the values are 10 for snow covered land and
20 for non-snow covered land.
I've tried using getind_latlon2d within dual
do loops, but it was extremely slow.
My latest attempt is below, using mask
to reduce data to only nearby locations.
In this case, I am trying to regrid 14 years
worth of daily snow cover.
Thanks, Michael
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
begin
cvr=new((/14,12,31,720,720/),float)
cvr at _FillValue=1e+35
cvr=1e+35
a=addfile("1999/nhtsd25e2_19990101_v01r01.nc","r")
latitude=a->latitude ; (rows,cols)
longitude=a->longitude
do iyr=0,13
do imn=0,11
do id=0,30
years=iyr+1999
if (imn.le.8) then
months="0"+(imn+1)
else
months=""+(imn+1)
end if
if (id.le.8) then
days="0"+(id+1)
else
days=""+(id+1)
end if
filen=""+years+"/nhtsd25e2_"+years+""+months+""+days+"_v01r01.nc"
if (isfilepresent(filen)) then
a=addfile(filen,"r")
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
end if
end do
end do
end do
lat=fspan(0.,90.,451)
lat!0="lat"
lat at units="degrees_north"
lat&lat=lat
lon=fspan(0.,180.,901)
lon!0="lon"
lon at units="degrees_east"
lon at lon=lon
grid=new((/14,12,31,451,901/),float)
grid at _FillValue=1e+35
grid=1e+35
do i=0,450
do j=0,900
cover=mask(cvr,latitude.ge.lat(i)+0.5,False)
cover=mask(cover,latitude.le.lat(i)-0.5,False)
cover=mask(cover,longitude.ge.lon(j)+0.5,False)
cover=mask(cover,longitude.le.lon(j)-0.5,False)
do iyr=0,13
do imn=0,11
do id=0,30
snow=num(cover(iyr,imn,id,:,:).eq.10)
nosnow=num(cover(iyr,imn,id,:,:).eq.20)
combined=snow+nosnow
if (combined.gt.0) then
if (snow.ge.nosnow) then
grid(iyr,imn,id,i,j)=100.
else
grid(iyr,imn,id,i,j)=0.
end if
end if
end do
end do
end do
end do
end do
year=ispan(1999,2012,1)
year!0="year"
year&year=year
month=ispan(1,12,1)
month!0="month"
month&month=month
day=ispan(1,31,1)
day!0="day"
day&day=day
grid!0="year"
grid!1="month"
grid!2="day"
grid!3="lat"
grid!4="lon"
grid&year=year
grid&month=month
grid&day=day
grid&lat=lat
grid&lon=lon
system("rm climo_snowcover_asia.nc")
out=addfile("climo_snowcover_asia.nc","c")
out->grid=grid
Michael Notaro
Associate Director
Nelson Institute Center for Climatic Research
University of Wisconsin-Madison
Phone: (608) 261-1503
Email: mnotaro at wisc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151201/4ff6869c/attachment.html
More information about the ncl-talk
mailing list