References

Parameters

healpix_params.png

Install

Tips

Simple plot

    import matplotlib.pylab as pl

    NSIDE = 32
    npix = hp.nside2npix(NSIDE)
    m = np.zeros(npix)

    hp.mollview(m, title='theta')
    pl.ion()
    pl.show()
    pl.savefig('theta.eps')

Coordinates

theta

theta.png
#!/usr/bin/env python

import numpy as np
import healpy as hp
import matplotlib.pylab as pl

def main():
    NSIDE = 32
    npix = hp.nside2npix(NSIDE)
    m = np.zeros(npix)

    for idx in range(npix):
        theta, phi = hp.pix2ang(NSIDE, idx)
        m[idx] = theta

    hp.mollview(m, title='theta')
    pl.ion()
    pl.show()
    pl.savefig('theta.eps')
 
if __name__ == '__main__':
    main()

phi

phi.png
#!/usr/bin/env python

import numpy as np
import healpy as hp
import matplotlib.pylab as pl
 
def main():
    NSIDE = 32
    npix = hp.nside2npix(NSIDE)
    m = np.zeros(npix)

    for idx in range(npix):
        theta, phi = hp.pix2ang(NSIDE, idx)
        m[idx] = phi

    hp.mollview(m, title='phi')
    pl.ion()
    pl.show()
    pl.savefig('phi.eps')


if __name__ == '__main__':
    main()

Attribute Error: 'module' object has no attribute 'figure'

Error something like

Traceback (most recent call last): 
  File "/home/cmb/chinoney/pb/polarbear_devel/polarbear_python/util_for_analysis_backend/plot_healpix_map.py", line 48, in <module>
    main()
  File "/home/cmb/chinoney/pb/polarbear_devel/polarbear_python/util_for_analysis_backend/plot_healpix_map.py", line 41, in main
    hp.mollview(val, title=target) 
  File "/home/cmb/chinoney/opt/python/lib/python2.7/site-packages/healpy/visufunc.py", line 144, in mollview
    f=pylab.figure(fig,figsize=(8.5,5.4))
AttributeError: 'module' object has no attribute 'figure'

Replace all the "import pylab" w/ "import matplotlib.pyplot as pylab" (in healpy/visufunc.py)

    import matplotlib.pyplot as pylab
    #import pylab