pythonmatplotlibplothealpy

Aitoff projections using healpy and projplot


I have a range of theta and phi’s using the healpy pix2ang command, and then transforming to RA, Decl.::

ra = np.rad2deg(phi)
dec = np.rad2deg(0.5 * np.pi - theta)

I just want to project these onto an e.g. Aitoff type projection, but for the life of me can’t figure out how to do this via:: https://healpy.readthedocs.io/en/latest/generated/healpy.visufunc.projplot.html

projplot(ra, dec, 'bo')  

doesn't really do anything.


Solution

  • hp.projplot is used to add lines to an existing plot. If you're just interested in plotting lines on a different projection, I recommend you check out matplotlib's projections.

    For healpy, please find a quick example below.

    import healpy as hp
    import numpy as np
    
    nside = 64
    npix = hp.nside2npix(nside)
    arr = np.random.randn(npix)
    
    # Draw a circle
    r = np.full(100, 20.)
    phi = np.linspace(0., 2*np.pi, 100)
    x = np.cos(phi)*r
    y = np.sin(phi)*r
    
    # Plot the map and the circle
    hp.mollview(arr)
    hp.projplot(x, y, c='r', lonlat=True)
    

    enter image description here