我有标量值,这些标量值位于极坐标中的点网格上。虽然我可以自由选择θ和phi角度,但r值是由数据评估中的另一个步骤给出的。如何使用 mayavi 绘制等值面和一些切口数据?
目前,我正在尝试使用 scipy.interpolate.griddata 来获取一个欧几里得网格,但它已经工作了几个小时而没有结果......
from scipy import *
from enthought.mayavi import mlab
r_val = [0.5, 1.0, 1.5, 2.0] # externally given
r, theta, phi = mgrid[
r_val[0]:r_val[-1]:len(r_val)*1.j,
0:pi:len(r_val)*1.j,
0:2.*pi:len(r_val)*1.j ]
x = r*sin(theta)*cos(phi)
y = r*sin(theta)*sin(phi)
z = r*cos(theta)
# here would be the data
s = ones_like(x)
s *= r*r
# the x,y,z axes of this plot are r,theta,phi
mlab.contour3d(s)
# but I want them to be x,y,z!
# this does not work
#mlab.contour3d(x,y,z,s)
请参阅 http://permalink.gmane.org/gmane.comp.python.enthought.devel/20667
src = mlab.pipeline.scalar_scatter(x,y,z,s)
iso=mlab.pipeline.iso_surface(gs)