2016-12-07 3 views
1

세 개의 양 : theta, phi 및 v (theta, phi)가 있다고 가정 해 봅시다. 모든 비터를 보간 할 수 있도록 각 비닝을 사용하고 싶습니다. v를 얻으려면 φφ를 사용해야합니다. 전 healpix에 새로운 것이므로이 작업을 수행하는 방법을 이해하지 못합니다. 본질적으로 저는 theta와 phi 그리드를 원합니다. 그러면 보간을 위해 scipy.griddata를 사용하고 싶습니다. 감사.healpy를 사용한 각 binning

+0

당신이 [numpy.histogram] 봐 (이 있었나요 https://docs.scipy.org/ doc/numpy/reference/generated/numpy.histogram.html) – DrBwts

답변

0

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

내가 참조를 위해 아래의 코드를 복사 :

여기 내 노트북 ​​참조

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

매우 도움이되었습니다. 감사합니다! – user6769140