[SciPy-Dev] SciPy-Dev Digest, Vol 92, Issue 8

Ole Nielsen ole.moller.nielsen@gmail....
Fri Jun 10 20:04:14 CDT 2011


Thank you everyone for your suggestions. I didn't realise that
RectBivariateSpline is a global method, but now it makes sense what I see in
terms of ringing and handling of NaN.

I am really interested in the local methods suggested by Chuck (bi-cubic
interpolation or bilinear. However, looking in scipy.ndimage I couldn't find
this kind of thing. Looking at GDAL this seems to be available only for
resampling.
I couldn't find LinearNDInterpolator either. Can anyone tell me where to
find these packages please.

Just to recab, what we need is a local bilinear interpolation from regular
grid data to a collection of points which handles NaN in a sensible way.

Many thanks
Ole


On Sat, Jun 11, 2011 at 12:00 AM, <scipy-dev-request@scipy.org> wrote:

> Send SciPy-Dev mailing list submissions to
>        scipy-dev@scipy.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://mail.scipy.org/mailman/listinfo/scipy-dev
> or, via email, send a message with subject or body 'help' to
>        scipy-dev-request@scipy.org
>
> You can reach the person managing the list at
>        scipy-dev-owner@scipy.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of SciPy-Dev digest..."
>
>
> Today's Topics:
>
>   1. Bivariate interpolation and NaN (Ole Nielsen)
>   2. Re: Bivariate interpolation and NaN (Charles R Harris)
>   3. Re: Bivariate interpolation and NaN (Gael Varoquaux)
>   4. Re: Bivariate interpolation and NaN (Charles R Harris)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 10 Jun 2011 13:26:01 +0700
> From: Ole Nielsen <ole.moller.nielsen@gmail.com>
> Subject: [SciPy-Dev] Bivariate interpolation and NaN
> To: scipy-dev@scipy.org
> Message-ID: <BANLkTi=fiCLzawFixTSN0GW+G7WTyUXRtQ@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> 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 am interested in thoughts on whether it is possible to achieve this. If
> there is a need to reproduce my observations, I can provide that.
>
> Cheers and thanks
> Ole Nielsen
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://mail.scipy.org/pipermail/scipy-dev/attachments/20110610/0c475125/attachment-0001.html
>
> ------------------------------
>
> Message: 2
> Date: Fri, 10 Jun 2011 01:01:24 -0600
> From: Charles R Harris <charlesr.harris@gmail.com>
> Subject: Re: [SciPy-Dev] Bivariate interpolation and NaN
> To: SciPy Developers List <scipy-dev@scipy.org>
> Message-ID: <BANLkTi=DZrBc6G6HbOcHjJGPg+R1o4=XAA@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> 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-0001.html
>
> ------------------------------
>
> Message: 3
> Date: Fri, 10 Jun 2011 09:13:35 +0200
> From: Gael Varoquaux <gael.varoquaux@normalesup.org>
> Subject: Re: [SciPy-Dev] Bivariate interpolation and NaN
> To: SciPy Developers List <scipy-dev@scipy.org>
> Message-ID: <20110610071335.GC11586@phare.normalesup.org>
> Content-Type: text/plain; charset=us-ascii
>
> On Fri, Jun 10, 2011 at 01:01:24AM -0600, Charles R Harris wrote:
> >    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.
>
> WENO interpolation (weighted essentially non-oscillatory):
>
> http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.148.8505&rep=rep1&type=pdf
>
> http://www.scholarpedia.org/article/WENO_methods
>
> Adrian Townsend presented such interpolation scheme at scipy a couple of
> years ago:
> http://www.archive.org/details/scipy09_day1_14-Adrian_Townsend
> He slides might actually be amongst the most readable material around:
> http://conference.scipy.org/static/wiki/townsend_weno.pdf
> anhd he has Python code:
> http://memmett.github.com/PyWENO/
>
> Gael
>
>
> ------------------------------
>
> Message: 4
> Date: Fri, 10 Jun 2011 01:14:59 -0600
> From: Charles R Harris <charlesr.harris@gmail.com>
> Subject: Re: [SciPy-Dev] Bivariate interpolation and NaN
> To: SciPy Developers List <scipy-dev@scipy.org>
> Message-ID: <BANLkTikTVFHk9_1Jp6_VMAigJDb0nfXN+g@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> On Fri, Jun 10, 2011 at 1:01 AM, Charles R Harris <
> charlesr.harris@gmail.com
> > wrote:
>
> >
> >
> > 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.
> >
> >
> 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.scipy.org/pipermail/scipy-dev/attachments/20110610/be546dcd/attachment-0001.html
>
> ------------------------------
>
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>
>
> End of SciPy-Dev Digest, Vol 92, Issue 8
> ****************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-dev/attachments/20110611/79acf212/attachment.html 


More information about the SciPy-Dev mailing list