[SciPy-user] How to fit a surface from a list of measured 3D points ?
Loïc BERTHE
berthe.loic@gmail....
Tue Mar 31 03:48:06 CDT 2009
Hi,
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=';')
figure(1)
scatter(data.x, data.y, s=data.z, c=data.z)
colorbar()
title('data points : z=f(x,y)')
xlabel('x')
ylabel('y')
grid()
# 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)
figure()
pcolor(xnew,ynew,znew)
colorbar()
title("Interpolated z=f(xnew,ynew)")
show()
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 ?
Regards,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: small_data.jpg
Type: image/jpeg
Size: 38904 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20090331/d5b7465f/attachment-0002.jpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: small_fit.jpg
Type: image/jpeg
Size: 25113 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20090331/d5b7465f/attachment-0003.jpg
More information about the SciPy-user
mailing list