regrid: Regrid

Description Usage Arguments Value Author(s) Examples

Description

Fast transform data from one longitude-latitude grid to another through bi-linear interpolation. The regridding is done by first calculating a set of weights

Let X(i,j) be a i-j matrix containing the data on a grid with i logitudes and j latitudes. We want to transform this to a different grid with k longitudes and l latitudes:

X(i,j) -> Y(k,l)

First the routine computes a set of weight, then performs a matrix multiplication to map the original data onto the new grid. The weights are based on the distance between points, taking longitude & latitude and use distAB() to estimate the geographical distance in km.

The matrix operation is: Y = beta X

beta is a matrix with dimensions (i*j,k*l)

( Y(1,1) ) (beta(1,1), beta(2,1), beta(3,1), ... ) ( X(1,1) ) ( Y(1,2) ) = (beta(1,2), beta(2,2), beta(3,2), ... ) ( X(1,2) ) ( ..... ) (beta(1,3), beta(2,3), beta(3,3), ... ) ( X(1,3) )

Most of the elements in Beta are zero!

Usage

1
2
3
4
5
6
7
regrid.weights(xo,yo,xn,yn,verbose)
sparseMproduct(beta,x)
regrid(x,is,...)
regrid.default(x,is,verbose=FALSE,...) 
regrid.field(x,is,verbose=FALSE,...) 
regrid.matrix(x,is,verbose=FALSE,...) 
regrid.eof(x,is,verbose=FALSE)

Arguments

xo

Old x-coordinates (longitudes)

yo

Old y-coordinates (latitudes)

xn

New x-coordinates (longitudes)

yn

New y-coordinates (latitudes)

beta

The matrix of interpolation weights

x

a field object.

is

A list holding the coordinates xn and yn, a field object, an eof object, or a station object - for the latter three, the field x is interpolated to the longitude/latitude held by is.

verbose

Clutter the screen.

Value

A field object

Author(s)

R.E. Benestad and A. Mezghanil

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
# Use regrid to interpolate to station location:
t2m <- retrieve.ncdf4("~/data/ERAINT/ERAINT_t2m_mon.nc",param="t2m")
data(Oslo)
z.oslo <- regrid(t2m,is=Oslo)
plot(Oslo)
lines(z.oslo)

# Regrid t2m onto the grid of the gcm
gcm <- t2m.NorESM.M()
Z <- regrid(t2m,gcm)
map(Z)

# Example using regrid on a matrix object:
t2m.mean <- as.pattern(t2m,FUN='mean')
z <- regrid(t2m.mean,is=list(seq(min(lon(t2m)),max(lon(t2m)),by=0.5),
                             seq(min(lat(t2m)),max(lat(t2m),by=0.5)))
image(lon(z),lat(z),z)

## End(Not run)

metno/esd.test documentation built on May 22, 2019, 7:49 p.m.