[SciPy-User] 3D spline interpolation very, very slow - UPDATE -

Evgeni Burovski evgeny.burovskiy at gmail.com
Tue Sep 9 16:04:54 EDT 2014


>
> Only the documentation should be improved.

Pull requests are always welcome :-).

>
> Best regards:
>
> Uwe Fechner
>
> Am 09.09.2014 um 15:53 schrieb Joe Kington:
> > The reason is because `ndimage.map_coordinates` pre-calculates a series
of weights on the entire
> > input grid to reduce a higher-order interpolation problem to linear
interpolation.    This is why
> > linear 3D interpolation (`order=1`) takes a fraction of a millisecond
while your second-order spline
> > interpolation on the same dataset takes several seconds.
> >
> > It's an optimization for the situation where you're interpolating many
(e.g. thousands) of points
> > instead of a single point, as your example.  In a nutshell,
`map_coordinates` isn't optimized for
> > the use-case of interpolating a small number of points.
> >
> > If you were to compare an interpolation with several thousand points,
the timing should be similar.
> >
> > However, the cost is a one-time cost.  One way to get around it is to
pre-calculate the weights
> > before-hand using `ndimage.spline_filter` and then pass them in and
specify `prefilter=False` to
> > `map_coordinates.  Here's a quick modification of your original example:
> > https://gist.github.com/joferkington/cc2f4d9a3eb96d837ef1
> >
> > At any rate, this is something that could certainly be more optimized
for a small number of points.
> > It currently assumes you're interested in interpolating over most of
the input array and does a lot
> > of (sometimes unnecessary) legwork to optimize for that use-case.  I'm
not going to volunteer, at
> > the moment, though :)
> >
> > (Also, on a side note, it's best to use odd-ordered splines.  Otherwise
you won't have a "smooth"
> > interpolation.  I'd be willing to bet that your julia example is
effectively using `order=3`.
> > Regardless, that doesn't have anything to do with speed.)
> >
> > Hope that helps,
> > -Joe
> >
> > On Tue, Sep 9, 2014 at 5:06 AM, Uwe Fechner <u.fechner at tudelft.nl
<mailto:u.fechner at tudelft.nl>> wrote:
> >
> >     Hello,
> >
> >     I am trying to do a spline interpolation of a 3D wind field.
> >
> >     For this I am using the function ndimage.map_coordinates.
> >
> >     For some reasons this works well if I interpolate in one dimension,
> >     but it gets terrible slow if I do this in three dimensions.
> >
> >     An example program can be found at:
> >     https://gist.github.com/anonymous/32c8599466dad30cd551
> >
> >     Am I doing something wrong?
> >
> >     I wrote a similar program, using the Julia programming language,
> >     at the speed is about 10000 times higher.
> >
> >     This Julia program can be found at:
> >     https://gist.github.com/anonymous/70af96a6916b4906f2b0
> >
> >     Any ideas how to improve the speed of the Python code are welcome.
> >
> >     Best regards:
> >
> >     Uwe Fechner
> >
> >        ---------------------------------------------
> >     Uwe Fechner, M.Sc.
> >     Delft University of Technology
> >     Faculty of Aerospace Engineering/ Wind Energy
> >     Kluyverweg 1,
> >     2629 HS Delft, The Netherlands
> >     Phone: +31-15-27-88902 <tel:%2B31-15-27-88902>
> >
> >     _______________________________________________
> >     SciPy-User mailing list
> >     SciPy-User at scipy.org <mailto:SciPy-User at scipy.org>
> >     http://mail.scipy.org/mailman/listinfo/scipy-user
> >
> >
> >
> >
> > _______________________________________________
> > SciPy-User mailing list
> > SciPy-User at scipy.org
> > http://mail.scipy.org/mailman/listinfo/scipy-user
> >
>
>
> --
> ---------------------------------------------
> Uwe Fechner, M.Sc.
> Delft University of Technology
> Faculty of Aerospace Engineering/ Wind Energy
> Kluyverweg 1,
> 2629 HS Delft, The Netherlands
> Phone: +31-15-27-88902
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20140909/0ba7be25/attachment.html>


More information about the SciPy-User mailing list