2

我有一个高分辨率的 healpix 贴图(nside = 4096),我想在给定半径的磁盘中平滑,比如说 10 arcmin。

作为一个非常新的healpy并阅读了文档,我发现一个 - 不太好的 - 方法是执行“锥形搜索”,即在每个像素周围找到磁盘内的像素,平均它们并给出这个中心像素的新值。然而,这是非常耗时的。

import numpy as np
import healpy as hp

kappa = hp.read_map("zs_1.0334.fits") #Reading my file

NSIDE = 4096

t = 0.00290888  #10 arcmin
new_array = []
n = len(kappa)
for i in range(n):
     a = hp.query_disc(NSIDE,hp.pix2vec(NSIDE,i),t)
     new_array.append(np.mean(kappa[a]))  

我认为 healpy.sphtfunc.smoothing 函数可能会有所帮助,因为它声明您可以输入任何自定义光束窗口函数,但我根本不明白它是如何工作的......

非常感谢你的帮助 !

4

2 回答 2

1

正如建议的那样,我可以通过指定自定义(圆形)光束窗口轻松地使用 healpy.sphtfunc.smoothing 函数。

要计算光束窗口,这是我的问题,healpy.sphtfunc.beam2bl 在礼帽的情况下非常有用且简单。

适当的 l_max 大约为 2*Nside,但根据具体地图,它可以更小。例如,可以计算角功率谱(Cls)并检查它是否衰减小于 l_max 的 l ,这有助于获得更多时间。

非常感谢在评论区提供帮助的每一个人!

于 2019-05-18T10:00:14.227 回答
1

因为我花了一定的时间试图弄清楚函数平滑是如何工作的。有一些代码可以让您进行 top_hat 平滑。

干杯,

import healpy as hp
import numpy as np
import matplotlib.pyplot as plt

def top_hat(b, radius):
    return np.where(abs(b)<=radius, 1, 0)

nside = 128
npix = hp.nside2npix(nside) 

#create a empy map
tst_map = np.zeros(npix)

#put a source in the middle of the map with value = 100
pix = hp.ang2pix(nside, np.pi/2, 0)
tst_map[pix] = 100


#Compute the window function in the harmonic spherical space which will smooth the map.
b = np.linspace(0,np.pi,10000)
bw = top_hat(b, np.radians(45)) #top_hat function of radius 45°
beam = hp.sphtfunc.beam2bl(bw, b, nside*3)

#Smooth map
tst_map_smoothed = hp.smoothing(tst_map, beam_window=beam)

hp.mollview(tst_map_smoothed)
plt.show()
于 2020-10-28T13:24:35.100 回答