From 2ef06857ab2cdac750c5e7856d21665138698ac5 Mon Sep 17 00:00:00 2001 From: Swarali-glitch <71065651+Swarali-glitch@users.noreply.github.com> Date: Sun, 18 Oct 2020 19:03:24 +0530 Subject: [PATCH 1/3] 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. --- sphere_healpy.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 sphere_healpy.py diff --git a/sphere_healpy.py b/sphere_healpy.py new file mode 100644 index 0000000..eef3184 --- /dev/null +++ b/sphere_healpy.py @@ -0,0 +1,27 @@ +from mayavi import mlab +import numpy as np +import healpy as hp + +# Create a sphere +r = 1.0 +pi = np.pi +cos = np.cos +sin = np.sin +phi, theta = np.mgrid[0:pi:101j, 0:2 * pi:101j] + +x = r*sin(phi)*cos(theta) +y = r*sin(phi)*sin(theta) +z = r*cos(phi) + +mlab.figure(1, bgcolor=(1, 1, 1), fgcolor=(0, 0, 0), size=(400, 300)) +mlab.clf() + +pix_centers = hp.pix2vec(1, np.arange(12)) +xx, yy, zz = pix_centers + + +mlab.mesh(x , y , z, color=(0.0,0.5,0.5)) +mlab.points3d(xx, yy, zz, scale_factor=0.2) + + +mlab.show() From 24c4e34bf36419b9d4a42dd13e112336ae2be6a9 Mon Sep 17 00:00:00 2001 From: Swarali-glitch <71065651+Swarali-glitch@users.noreply.github.com> Date: Sun, 18 Oct 2020 20:04:20 +0530 Subject: [PATCH 2/3] Update and rename sphere_healpy.py to sphere_healpy.md --- sphere_healpy.py => sphere_healpy.md | 8 ++++++++ 1 file changed, 8 insertions(+) rename sphere_healpy.py => sphere_healpy.md (80%) diff --git a/sphere_healpy.py b/sphere_healpy.md similarity index 80% rename from sphere_healpy.py rename to sphere_healpy.md index eef3184..6148578 100644 --- a/sphere_healpy.py +++ b/sphere_healpy.md @@ -1,3 +1,10 @@ +# Plot a sphere and pixel centers on it using Healpix package + +*tags:* python, healpix, healpy + +### Snippet +``` + from mayavi import mlab import numpy as np import healpy as hp @@ -25,3 +32,4 @@ mlab.show() +''' From 7ec3b922565d6599c6ea75557dd087b3ab1f611a Mon Sep 17 00:00:00 2001 From: Swarali-glitch <71065651+Swarali-glitch@users.noreply.github.com> Date: Sun, 18 Oct 2020 20:06:04 +0530 Subject: [PATCH 3/3] Update sphere_healpy.md --- sphere_healpy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphere_healpy.md b/sphere_healpy.md index 6148578..6114b8d 100644 --- a/sphere_healpy.md +++ b/sphere_healpy.md @@ -32,4 +32,4 @@ mlab.points3d(xx, yy, zz, scale_factor=0.2) mlab.show() -''' +```