如何使用python astropy将arcsec转换为Mpc?

时间:2019-05-23 16:45:11

标签: python astropy

我需要将以下数量从arcsec转换为mega parsec:

from astropy.cosmology import FlatLambdaCDM
import astropy.units as u

cosmo = FlatLambdaCDM(H0=70, Om0=0.3)
cosmo.luminosity_distance(z=0.3)

# I am not sure how to convert arcsec to Mpc here.

使用的宇宙学:Ade等人2016 https://arxiv.org/pdf/1502.01589.pdf表1 2013F(DS)

到目前为止,我已经尝试过了

{{1}}

替代品: http://arcsec2parsec.joseonorbe.com/index.html

这有效并且给出了3.38 Mpc,但是我不能简单地引用一个网站,希望使用python再现结果。

1 个答案:

答案 0 :(得分:2)

要找到距离,您需要将角直径距离乘以角大小。

l = D_A(z)×θ

参考:http://arcsec2parsec.joseonorbe.com/about.html

from astropy.cosmology import FlatLambdaCDM
import numpy as np
cosmo = FlatLambdaCDM(H0=67.8, Om0=0.308)

# angular diameter distance in Mpc
d_A = cosmo.angular_diameter_distance(z=0.3)
theta = 737.28 # arcsec

# pi radian = 180 degree ==> 1deg = pi/180 ==> 1arcsec = pi/180/3600
theta_radian = theta * np.pi / 180 / 3600

# arc length = radius * angle
distance_Mpc = d_A * theta_radian

print(distance_Mpc) # 3.3846475 Mpc

更新
如评论中所建议,我们也可以使用天体单位,

from astropy.cosmology import FlatLambdaCDM
import numpy as np
from astropy import units as u
cosmo = FlatLambdaCDM(H0=67.8, Om0=0.308)

d_A = cosmo.angular_diameter_distance(z=0.3)
print(d_A) # 946.9318492873492 Mpc

theta = 737.28*u.arcsec
distance_Mpc = (theta * d_A).to(u.Mpc, u.dimensionless_angles()) # unit is Mpc only now

print(distance_Mpc) # 3.384745689510495 Mpc