2016-12-07 5 views
1

私は3つの量を持っているとしましょう:theta、phi、v(theta、phi)。私は角ビニングを使用して、今後のtheta & phiを補間してvを得ることができるようにしたいと思います。私は完全にhealpixに新しいので、これを行う方法を理解していません。基本的に私はthetaとphiのグリッドが好きで、補間にscipy.griddataを使いたいと思っています。ありがとう。healpyを使った角度ビニング

+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

関連する問題