首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用healpy进行角度入库

使用healpy进行角度入库
EN

Stack Overflow用户
提问于 2016-12-07 17:59:22
回答 1查看 249关注 0票数 1

假设我有三个量: theta,φ和v(theta,φ)。我想使用角度装箱,这样我就可以插值任何未来的theta & phi来得到v。我完全不熟悉healpix,不知道如何去做。本质上,我想要一个θ和φ的网格,然后想使用scipy.griddata进行插值。谢谢。

EN

回答 1

Stack Overflow用户

发布于 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),然后对于未来的thetaphi,您可以找到它们所属的像素,并使用healpy非常快速地获得该像素的映射值。

在这里查看我的笔记本:https://gist.github.com/zonca/e16fcf42e23e30fb2bc7301482f4683f

我复制了下面的代码以供参考:

代码语言:javascript
复制
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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41014414

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档