[ncl-talk] regridding EASE snow data

Mary Haley haley at ucar.edu
Wed Dec 2 08:39:36 MST 2015


Hi Michael,

Most of our regridding routines do some sort of interpolation.

You could try triple2grid, which *places* values at the nearest locations
of a 2D rectilinear grid.

You will need to first turn your EASE grid and it's lat/lon values into 1D
variables:

lat1d    = ndtooned(latitude)
lon1d    = ndtooned(longitude)
cover1d  = ndtooned(cover)
opt      = False  ; if True, then some options are available

cover_regrid = triple2grid(lon1d,lat1d,cover1d,lon,lat,opt)

I admit I've never tried this, so please let ncl-talk know if this works
for you.

You can see what "opt" options are available:

http://www.ncl.ucar.edu/Document/Functions/Built-in/triple2grid.shtml

--Mary


On Tue, Dec 1, 2015 at 12:02 PM, Michael Notaro <mnotaro at wisc.edu> wrote:

> 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
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151202/cde591d2/attachment.html 


More information about the ncl-talk mailing list