Update
Code: Alles auswählen
import numpy as np
from scipy.special import sph_harm
from mayavi import mlab
theta_1d = np.linspace(0, np.pi, 91) # 2 GRAD Schritte
phi_1d = np.linspace(0, 2*np.pi, 181) # 2 GRAD Schritte
theta_2d, phi_2d = np.meshgrid(theta_1d, phi_1d)
xyz_2d = np.array([np.sin(theta_2d) * np.sin(phi_2d),
np.sin(theta_2d) * np.cos(phi_2d),
np.cos(theta_2d)])
# Animierte Ansicht von Y_lm
def show_Y_lm(l, m, camera):
Y_lm = sph_harm(m,l, phi_2d, theta_2d)
r = np.abs(Y_lm.real)*xyz_2d
mlab.figure(size=(500,500))
s = mlab.mesh(r[0], r[1], r[2], scalars=Y_lm.real, colormap="cool")
for i in range(camera.shape[0]):
azimuth,elevation,distance,roll = camera[i]
mlab.view(azimuth=azimuth, elevation=elevation, distance=distance, roll=roll)
mlab.savefig("plot/Y_%i_%i_%02i.png" % (l,m, i))
# kamerafuehrung
nf = 40
camera = np.zeros((nf,4))
camera[:,0] = np.linspace( 70, 55,nf) # azimuth
camera[:,1] = np.linspace( 50,130,nf) # elevation
camera[:,2] = np.linspace( 3,1.2,nf) # distance
camera[:,3] = np.linspace(-50,-50,nf) # roll
show_Y_lm(l=3,m=0, camera=camera)
mlab.show()
#convert -delay 10 -duplicate 1,-2-1 -loop -0 plot/*.png Y_3_0.gif