Skip to main content
 首页 » 编程设计

python之AstroPy距离红移转换精度

2024年11月24日14qq78292959

AstroPy.coordinates.Distance 函数的红移转换精度如何?

它似乎只对千分之一位有用(比 float 精度问题精确得多):

from astropy import units as u 
from astropy.coordinates import SkyCoord, Distance 
from astropy.cosmology import Planck15 
 
z1 = 0.05598 
z2 = 0.31427 
 
dist1 = Distance(unit=u.pc, z = z1, cosmology = Planck15) 
dist2 = Distance(unit=u.pc, z = z2, cosmology = Planck15) 
 
dist1.z    #prints 0.05718 
dist2.z    #prints 0.31916 

我正在使用它来计算河外源之间的 3D 距离,这些差异大约为 Mpc,这对于我正在研究的内容来说非常大。这是 AstroPy 不可避免的限制吗?

请您参考如下方法:

这适用于 python 3.7 的 astropy 3.2.1。

from astropy import units as u 
from astropy.coordinates import SkyCoord, Distance 
from astropy.cosmology import Planck15 
 
z1 = 0.05598 
z2 = 0.31427 
 
dist1 = Distance(unit=u.pc, z = z1, cosmology = Planck15) 
dist2 = Distance(unit=u.pc, z = z2, cosmology = Planck15) 
 
dist1.z 
Out[9]: 0.055979999974738834 
 
dist2.z 
Out[10]: 0.31427000077974493 

看起来计算精度为 7 位有效数字左右。

z3 = 1.31427987654321 
 
dist3 = Distance(unit=u.pc, z = z3, cosmology = Planck15) 
 
dist3.z 
Out[23]: 1.3142798808605372 
 
z4 = 900.31427987654321 
 
dist4 = Distance(unit=u.pc, z = z4, cosmology = Planck15) 
 
dist4.z 
Out[29]: 900.3142861453044 

在接近 z=1000 的某个地方,这将返回一个错误,指出该值已最大化,因为此时您已经接近 CMB 区域。