0

I'm trying to understand what the new indices of a HEALPix array would be after applying the cartview rotation. So I have:

latra = [-90,90]
lonra = [-180,180]
nside = 16
pixels = np.arange(12*nside**2)
newPixIndex = hp.cartview(pixels, rot=(45,0), lonra=lonra,latra=latra, return_projected_map=True)

How do I get the new order of pixels after performing the cartview rotation from the returned newPixIndex map?

Adam G.
  • 75
  • 11

1 Answers1

0

I found a solution here (Apply rotation to HEALPix map in healpy) by doing the following:

def rotate_map(hmap, rot_theta, rot_phi):
    """
    Take hmap (a healpix map array) and return another healpix map array
    which is ordered such that it has been rotated in (theta, phi) by the
    amounts given.
    """
    nside = hp.npix2nside(len(hmap))

    # Get theta, phi for non-rotated map
    t,p = hp.pix2ang(nside, np.arange(hp.nside2npix(nside))) #theta, phi

    # Define a rotator
    r = hp.Rotator(deg=False, rot=[rot_phi,rot_theta])

    # Get theta, phi under rotated co-ordinates
    trot, prot = r(t,p)

    # Interpolate map onto these co-ordinates
    rot_map = hp.get_interp_val(hmap, trot, prot)

    return rot_map

nside = 64
indices = np.arange(12*nside**2)
rot = [0, 15, 30, 45, 60, 75, 90]

for i in range(len(rot)):
    newIndex = np.array(rotate_map(indices,0,np.rad2deg(rot[i])),dtype='int')
Adam G.
  • 75
  • 11