AstroPy.coordinates.Distance
函数的红移转换有多精确?
它似乎仅对千分之一数字有用(比浮点数精度问题低得多):
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不可避免的限制吗?
答案 0 :(得分:2)
这适用于适用于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区域。