假设我有三个量: theta,φ和v(theta,φ)。我想使用角度装箱,这样我就可以插值任何未来的theta & phi来得到v。我完全不熟悉healpix,不知道如何去做。本质上,我想要一个θ和φ的网格,然后想使用scipy.griddata进行插值。谢谢。
发布于 2016-12-08 03:13:08
你可以只在scipy.interpolate.interp2d中使用插值,参见https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.interpolate.interp2d.html,甚至不使用healpy。
但是,让我向您展示如何使用healpy映射来实现这一点。其思想是为地图的每个像素预先计算v(theta,phi),然后对于未来的theta和phi,您可以找到它们所属的像素,并使用healpy非常快速地获得该像素的映射值。
在这里查看我的笔记本:https://gist.github.com/zonca/e16fcf42e23e30fb2bc7301482f4683f
我复制了下面的代码以供参考:
import healpy as hp
import numpy as np
NSIDE = 64
print("Angular resolution is {:.2f} arcmin".format(hp.nside2resol(NSIDE, arcmin=True)))
NPIX = hp.nside2npix(NSIDE)
print("Number of pixels", NPIX)
pixel_indices = np.arange(NPIX)
theta_pix, phi_pix = hp.pix2ang(NSIDE, pixel_indices)
def v(theta, phi):
return theta ** 2
v_map = v(theta_pix, phi_pix)
new_theta, new_phi = np.radians(30), np.radians(0)
new_pix = hp.ang2pix(NSIDE, new_theta, new_phi)
print("New theta and phi are hitting pixel", new_pix)
# We find what pixel the new coordinates are hitting and get the precomputed value of V at that pixel, to increase accuracy, you can increase NSIDE of the precomputed map.
v_map[new_pix]
v(new_theta, new_phi)https://stackoverflow.com/questions/41014414
复制相似问题