This function seems to do the trick (fairly slow, but should be better than the for loop):
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))
t,p = hp.pix2ang(nside, np.arange(hp.nside2npix(nside)))
r = hp.Rotator(deg=False, rot=[rot_phi,rot_theta])
trot, prot = r(t,p)
rot_map = hp.get_interp_val(hmap, trot, prot)
return rot_map
Using this on data from PyGSM, you get the following:
hp.mollview(np.log(rotate_map(gsm.generated_map_data, 0,0)))

When rotating phi:
hp.mollview(np.log(rotate_map(gsm.generated_map_data, 0,np.pi)))

Or a twist theta:
hp.mollview(np.log(rotate_map(gsm.generated_map_data, np.pi/4,0)))

source
share