<br><br><div class="gmail_quote">On Fri, Jun 10, 2011 at 1:01 AM, Charles R Harris <span dir="ltr"><<a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div class="im">On Fri, Jun 10, 2011 at 12:26 AM, Ole Nielsen <span dir="ltr"><<a href="mailto:ole.moller.nielsen@gmail.com" target="_blank">ole.moller.nielsen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote">Dear Scipy developers<br><br>I am working on a project where we need to interpolate from gridded data to individual points.<br>We want it to be fast, bilinear (i.e. smooting is not important) and be able to deal with NaN in a sensible way.<br>
<br>I looked at a few and settled for RectBivariateSpline which is part of scipy.interpolate.<br>It works well but, we have encountered two problems:<br><ol><li>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.<br>
</li><li>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?</li></ol></div></blockquote></div><div>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. <br>
<br></div></div></blockquote><div><br>I should say that I interpreted gridded as evenly spaced points on a square grid. If that is not the case the <font size="2">LinearNDInterpolator might be your best bet.<br><br>Chuck<br>
</font> </div><br></div>