Skip to content

Instantly share code, notes, and snippets.

@zonca
Created September 13, 2011 21:01
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 zonca/1215159 to your computer and use it in GitHub Desktop.
Save zonca/1215159 to your computer and use it in GitHub Desktop.
example of Mollview hitmap
import numpy as np
import healpy
RA = np.random.random(10000)*360
DEC= np.random.random(10000)*135-45
NSIDE = 64 #nside determines the size of the pixels
pixels = healpy.ang2pix(NSIDE, np.radians(90-DEC), np.radians(RA)) #NOTE healpy uses colatitude (north pole 0) instead of latitude
hitmap = np.ones(healpy.nside2npix(NSIDE)) * healpy.UNSEEN #by convention non hit pixels have a specific value
pixels_binned = np.bincount(pixels)
hitmap[:len(pixels_binned)] = pixels_binned
healpy.mollview(hitmap, xsize=2000)
healpy.graticule()
@zonca
Copy link
Author

zonca commented Sep 13, 2011

More info on Healpix pixelization http://healpix.jpl.nasa.gov/html/intro.htm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment