Revisão | 99f0ffe970486f3d562b6e9829410d50017eb73c (tree) |
---|---|
Hora | 2008-11-05 03:47:58 |
Autor | iselllo |
Commiter | iselllo |
This code plots a spherical harmonic and saves it as a file. NOT still clear how to get the png file without opening the applet. Find out more!
@@ -0,0 +1,21 @@ | ||
1 | +#! /usr/bin/env python | |
2 | + | |
3 | + | |
4 | +from numpy import * | |
5 | +from enthought.mayavi import mlab | |
6 | + | |
7 | +# Create the data. | |
8 | +dphi, dtheta = pi/250.0, pi/250.0 | |
9 | +[phi,theta] = mgrid[0:pi+dphi*1.5:dphi,0:2*pi+dtheta*1.5:dtheta] | |
10 | +m0 = 4; m1 = 3; m2 = 2; m3 = 3; m4 = 6; m5 = 2; m6 = 6; m7 = 4; | |
11 | +r = sin(m0*phi)**m1 + cos(m2*phi)**m3 + sin(m4*theta)**m5 + cos(m6*theta)**m7 | |
12 | +x = r*sin(phi)*cos(theta) | |
13 | +y = r*cos(phi) | |
14 | +z = r*sin(phi)*sin(theta) | |
15 | + | |
16 | +# View it. | |
17 | +s = mlab.mesh(x, y, z) | |
18 | + | |
19 | +mlab.savefig("figure.png") | |
20 | + | |
21 | +mlab.show() |