[SciPy-Dev] Bivariate interpolation and NaN

Charles R Harris charlesr.harris@gmail....
Fri Jun 10 02:01:24 CDT 2011


On Fri, Jun 10, 2011 at 12:26 AM, Ole Nielsen
<ole.moller.nielsen@gmail.com>wrote:

> Dear Scipy developers
>
> I am working on a project where we need to interpolate from gridded data to
> individual points.
> We want it to be fast, bilinear (i.e. smooting is not important) and be
> able to deal with NaN in a sensible way.
>
> I looked at a few and settled for RectBivariateSpline which is part of
> scipy.interpolate.
> It works well but, we have encountered two problems:
>
>    1. If there is a single NaN in the grid, all interpolated points become
>    NaN even if the surrounding pixels are valid floating point numbers. I would
>    have expected NaNs only for points whose immediate neighbours contain NaN.
>    2. We have noticed small 'overshoots', i.e. interpolated values may be
>    outside the range of the gridded data. Can anyone tell me if this is
>    expected?
>
> I think both are expected. Splines are a global fit and nans will cause
global trouble. Likewise, splines can exhibit ringing. You can use a
smoothing spline to get around that, but it won't interpolate the data
points exactly. It sounds to me like you want something local, for instance
bi-cubic interpolation or bilinear (the algorithm name). There are some
tools for this sort of thing in scipy.ndimage, and tools like gdal or
imagemagick might also do what you want depending on the specifics of the
problem.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-dev/attachments/20110610/3be014a5/attachment.html 


More information about the SciPy-Dev mailing list