def calc_ps3d(self):
"""
Calculate the 3D power spectrum of the image cube.
The power spectrum is properly normalized to have dimension
of [K^2 Mpc^3].
"""
if self.window is not None:
logger.info("Applying window along frequency axis ...")
self.cube *= self.window[:, np.newaxis, np.newaxis]
logger.info("3D FFTing data cube ...")
cubefft = fftpack.fftshift(fftpack.fftn(self.cube))
logger.info("Calculating 3D power spectrum ...")
ps3d = np.abs(cubefft) ** 2 # [K^2]
# Normalization
norm1 = 1 / (self.Nx * self.Ny * self.Nz)
norm2 = 1 / (self.fs_xy**2 * self.fs_z) # [Mpc^3]
norm3 = 1 / (2*np.pi)**3
self.ps3d = ps3d * norm1 * norm2 * norm3 # [K^2 Mpc^3]
return self.ps3d
评论列表
文章目录