def Dc_to_redshift(self, Dc):
"""
Calculate the redshift corresponding to the given comoving distance
(along LoS) by using interpolation.
"""
if not hasattr(self, "_Dc_interp"):
Dc_min, Dc_max = self.Dc_limit
dDc = self.Dc_cell
N = int((Dc_max - Dc_min) / dDc)
z_ = np.linspace(self.zmin, self.zmax, num=N)
Dc_ = self.cosmo.comoving_distance(z_).value # [Mpc]
self._Dc_interp = interpolate.interp1d(Dc_, z_, kind="linear")
return self._Dc_interp(Dc)
评论列表
文章目录