[SciPy-Dev] Bivariate interpolation and NaN
Charles R Harris
charlesr.harris at gmail.com
Fri Jun 10 03:14:59 EDT 2011
On Fri, Jun 10, 2011 at 1:01 AM, Charles R Harris <charlesr.harris at gmail.com
> wrote:
>
>
> On Fri, Jun 10, 2011 at 12:26 AM, Ole Nielsen <
> ole.moller.nielsen at 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.
>
>
I should say that I interpreted gridded as evenly spaced points on a square
grid. If that is not the case the LinearNDInterpolator might be your best
bet.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20110610/be546dcd/attachment.html>
More information about the SciPy-Dev
mailing list