Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2ef0685

Browse files
Create sphere_healpy.py
This code plots the pixel centers created by the healpix package on top of a spherical surface using Mayavi for 3D visualization.
1 parent a71f219 commit 2ef0685

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎sphere_healpy.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from mayavi import mlab
2+
import numpy as np
3+
import healpy as hp
4+
5+
# Create a sphere
6+
r = 1.0
7+
pi = np.pi
8+
cos = np.cos
9+
sin = np.sin
10+
phi, theta = np.mgrid[0:pi:101j, 0:2 * pi:101j]
11+
12+
x = r*sin(phi)*cos(theta)
13+
y = r*sin(phi)*sin(theta)
14+
z = r*cos(phi)
15+
16+
mlab.figure(1, bgcolor=(1, 1, 1), fgcolor=(0, 0, 0), size=(400, 300))
17+
mlab.clf()
18+
19+
pix_centers = hp.pix2vec(1, np.arange(12))
20+
xx, yy, zz = pix_centers
21+
22+
23+
mlab.mesh(x , y , z, color=(0.0,0.5,0.5))
24+
mlab.points3d(xx, yy, zz, scale_factor=0.2)
25+
26+
27+
mlab.show()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /