[SciPy-user] interpolation question
John Travers
jtravs at gmail.com
Wed Oct 17 15:17:09 EDT 2007
Hi Micheal,
On 17/10/2007, Michael Hearne <mhearne at usgs.gov> wrote:
>
> Is the 'linear' option in interpolate.interp2d() doing 'bilinear'
> interpolation, or something else?
Something else. It should be bilinear, but the underlying code is
designed for scattered grids of data and therefore has a more
complicated algorithm.
For regular girds (like yours) you should use RectBivariateSpline
------------------------------
from scipy.interpolate import RectBivariateSpline
# code in between
outgrid = RectBivariateSpline(xrange,yrange,data,kx=1,ky=1)
------------------------------
This gives me the same results as your matlab run.
Note that the input x and y are 1d arrays rather than 2d.
RectBivariateSpline is generally much more robust for regular grids,
and should be used unless you really do have scattered data.
Note to other developers: RectBivariateSpline should be used in
interp2d when possible. If I get time at the end of the month I'll do
this.
Cheers,
John
More information about the SciPy-User
mailing list