[SciPy-User] 3D scatter data interpolate

Vasco Gervasi yellowhat46 at gmail.com
Mon Feb 15 14:48:44 EST 2016


Hi all,
I would like to interpolate 3D scatter data.
I have some 3D points, each point has an associated value, I would like to
interpolate these point to calculate the value of a random point.
This example may help to understand:

> from math import cos, sin
> from scipy.interpolate import Rbf
> from numpy import linspace, pi
> from mpl_toolkits.mplot3d import Axes3D
> import matplotlib.pyplot as plt
> #%% Data
> R = 10.0
> x = list()
> y = list()
> z = list()
> c = list()
> for i in linspace(0.0,10.0,11):
>     for t in linspace(0.0,2*pi,90):
>         x.append(R*cos(t))
>         y.append(R*sin(t))
>         z.append(i)
>         c.append(i)
> #%% Plot
> fig = plt.figure()
> ax = fig.add_subplot(111, projection='3d')
> sc = ax.scatter(x, y, z, c=z)
> ax.set_xlabel('X')
> ax.set_ylabel('Y')
> ax.set_zlabel('Z')
> plt.colorbar(sc)
> #%%
> rbfi = Rbf(x, y, z, c)
> xi = [0,0]
> yi = [0,0]
> zi = [0,1]
> print rbfi(xi, yi, zi)

As you can see here we have some points over a cylinder, each point has
associate a value (color), which in this case is the z-coordinate.
scipy.interpolate.Rbf should answer my problem, to better understsand how
it works I gave it some points [[0,0,0],[0,0,1]], but the result of
rbfi(xi, yi, zi) is [-1.04833984 -0.10205078].
I expected that a point along the axis, aligned with some point should
return the z-coordinate of this point [0, 1] but got some negative number.
Any ideas?
Do you have any alternative that I can use to have a linear interpolation
or by the nearest?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20160215/bebf80f7/attachment.html>


More information about the SciPy-User mailing list