[SciPy-User] another interpolation question
Pauli Virtanen
pav at iki.fi
Thu Feb 17 14:09:13 EST 2011
On Thu, 17 Feb 2011 13:51:55 -0500, Bryan Woods wrote:
> Yes.
>
> The idea is that I am using a nested model where I have an outer domain
> with fixed latitude / longitude coordinates and I want to downscale the
> data from that outer domain onto a finer inner domain which is contained
> inside of the outer domain.
>
> All the interpolation that I see seeing is to interpolate randomly
> spaced data onto a fixed grid. I am looking to reproject data from and
> to fixed grids. Ideally a function that looks something like:
>
> z_fine[x_fine|:,y_fine|:] = interp2d(x[:], y[:], z[x|:,y|:], x_fine[:],
> y_fine[:])
Yes, we have something like this, but apparently it isn't listed in the
docs (aargh!).
Try
# some random data
from numpy import *
x = linspace(0, 1, 20)
y = linspace(0, 3, 30)
z = sin(x)[:,None] * cos(y)[None,:]
x_fine = linspace(0, 1, 200)
y_fine = linspace(0, 3, 140)
from scipy.interpolate import RectBivariateSpline
interp = RectBivariateSpline(x, y, z)
z_fine = interp(x_fine, y_fine)
More information about the SciPy-User
mailing list