<p>这个函数似乎能做到这一点(相当慢,但应该比for循环更好):</p>
<pre><code>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
</code></pre>
<p>对来自<code>PyGSM</code>的数据使用此方法可以得到以下结果:</p>
<p><code>hp.mollview(np.log(rotate_map(gsm.generated_map_data, 0,0)))</code></p>
<p><a href="https://i.stack.imgur.com/mNtwc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mNtwc.png" alt="enter image description here"/></a></p>
<p>当<code>phi</code>旋转时:</p>
<p><code>hp.mollview(np.log(rotate_map(gsm.generated_map_data, 0,np.pi)))</code></p>
<p><a href="https://i.stack.imgur.com/Wc0zq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wc0zq.png" alt="enter image description here"/></a></p>
<p>或旋转<code>theta</code>:</p>
<p><code>hp.mollview(np.log(rotate_map(gsm.generated_map_data, np.pi/4,0)))</code></p>
<p><a href="https://i.stack.imgur.com/YqCJc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YqCJc.png" alt="enter image description here"/></a></p>