[SciPy-user] How to fit a surface from a list of measured 3D points ?
Tue Mar 31 11:29:23 CDT 2009
What's your eventual goal for the fit surface? There are a lot of
possible approaches possible with the tools in scipy (e.g. fit a
spline, as you have done, or fit a simpler parameteric surface in a
least-squares fashion, or go for a nonparametric approach and
interpolate between the points with radial basis functions). The best
approach will likely depend on what you want to do with the surface...
but what you have seems like a reasonable start.
Also, ndimage.map_coordinates is for resampling of an array (e.g.
image) at arbitrary coordinates: perhaps not of direct use here.
On Mar 31, 2009, at 4:48 AM, Loïc BERTHE wrote:
> I have a list of 856 measured 3d points and would like to fit a 3D
> surface from theses points.
> Theses points are not regularly spaced.
> Here is the code I used :
> from numpy import *
> from matplotlib.mlab import csv2rec
> from matplotlib.pyplot import *
> data = csv2rec('data.csv', delimiter=';')
> scatter(data.x, data.y, s=data.z, c=data.z)
> title('data points : z=f(x,y)')
> # interpolation spline with scipy
> from scipy import interpolate
> tck0 = interpolate.bisplrep(data.x, data.y, data.z)
> xnew,ynew = mgrid[-1:1:70j,-1:1:70j]
> znew = interpolate.bisplev(xnew[:,0],ynew[0,:],tck0)
> title("Interpolated z=f(xnew,ynew)")
> I've attached the two figures describing the data and the fit which is
> not very interesting.
> Is there a better approach to fit theses data ?
> I had a look to the ndimage module and the map_coordinates function
> but I don't know if this is a better tool for this problem.
> Have you an example of the ndimage use ?
> SciPy-user mailing list
More information about the SciPy-user