Skip to content

Instantly share code, notes, and snippets.

Created December 5, 2016 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/60d97f20a19d820e299c253612728907 to your computer and use it in GitHub Desktop.
Save anonymous/60d97f20a19d820e299c253612728907 to your computer and use it in GitHub Desktop.
# Adopted to Julia
# Copyright (c) 2016, Hiroharu Sugawara <hsugawa@gmail.com>
# License: BSD Style.
#
# Author: Gael Varoquaux <gael.varoquaux@normalesup.org>
# Copyright (c) 2008, Enthought, Inc.
# License: BSD Style.
# Create a sphere
# phi, theta = np.mgrid[0:pi:101j, 0:2 * pi:101j]
phi = [ u1 for u1 in linspace(0,pi,101), v1 in linspace(0,2*pi,101) ]
theta = [ v1 for u1 in linspace(0,pi,101), v1 in linspace(0,2*pi,101) ]
r = 0.3
x = r * sin(phi) .* cos(theta)
y = r * sin(phi) .* sin(theta)
z = r * cos(phi)
using PyCall
@pyimport mayavi.mlab as mlab
@pyimport scipy.special as spe
mlab.figure(1, bgcolor=(1, 1, 1), fgcolor=(0,0,0), size=(400, 300))
mlab.clf()
# Represent spherical harmonics on the surface of the sphere
for n in 1:6-1, m in 0:n-1
s = real( spe.sph_harm(m, n, theta, phi) )
mlab.mesh(x - m, y - n, z, scalars=s, colormap="jet")
s[s .< 0] *= 0.97
s /= maximum(s)
mlab.mesh(s .* x - m, s .* y - n, s .* z + 1.3, scalars=s, colormap="Spectral" )
end
mlab.view(90, 70, 6.2, (-1.3, -2.9, 0.25))
mlab.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment