宇宙单位及其等价物#

这个包定义和收集宇宙学单位和等价物。我们建议将此设备包作为

>>> import astropy.cosmology.units as cu

要启用Main astropy.units 要在搜索单位换算和当量时访问这些单位,请使用 add_enabled_units()

>>> import astropy.units as u
>>> u.add_enabled_units(cu)  

关于单位#

:hide:

>>> import astropy.units as u

宇宙红移与无量纲等价#

宇宙学中有许多距离的测量方法--光度、CMB温度、宇宙年龄等--但红移是定义其他距离的主要测量方法。在宇宙学中,距离测量通常是令人恼火的,因为它们可以互换使用。 astropy 提供了 redshift 单位和相关的等价物,以帮助这些推导和统一的距离测量。

实例#

要转换为无因次单位或从无因次单位转换为“红移”单位,请执行以下操作:

>>> import astropy.units as u
>>> import astropy.cosmology.units as cu
>>> z = 1100 * cu.redshift
>>> z.to(u.dimensionless_unscaled, equivalencies=cu.dimensionless_redshift())
<Quantity 1100.>

当量作为复合单位的量的一部分

>>> q = (2.7 * u.K) * z
>>> q.to(u.K, equivalencies=cu.dimensionless_redshift())
<Quantity 2970. K>

由于红移不是真正的单位,而且使用频率很高,因此实际上在默认情况下启用了红移/无量纲等效值。

>>> z == 1100 * u.dimensionless_unscaled
True
>>> q.to(u.K)
<Quantity 2970. K>

若要临时删除等效项并强制单位严格,请使用 astropy.units.set_enabled_equivalencies() 作为一个背景。

>>> with u.set_enabled_equivalencies([]):
...     try:
...         z.to(u.dimensionless_unscaled)
...     except u.UnitConversionError:
...         print("equivalency disabled")
equivalency disabled

另一个红移等效项是 with_redshift ,使红移可以转换为其他单位,如CMB温度:

>>> from astropy.cosmology import WMAP9
>>> z = 1100 * cu.redshift
>>> z.to(u.K, cu.with_redshift(WMAP9))
<Quantity 3000.225 K>

或者哈勃参数:

>>> z.to(u.km / u.s / u.Mpc, cu.with_redshift(WMAP9))  
<Quantity 1565637.40154275 km / (Mpc s)>
>>> z.to(cu.littleh, cu.with_redshift(WMAP9))  
<Quantity 15656.37401543 littleh>

或物理距离(移动、回望或光度):

>>> z.to(u.Mpc, cu.with_redshift(WMAP9, distance="luminosity"))  
<Quantity 15418438.76317008 Mpc>

这些转换依赖于宇宙学,所以如果宇宙学改变了,转换也会改变。

>>> excosmo = WMAP9.clone(Tcmb0=3.0)
>>> z.to(u.K, cu.with_redshift(excosmo))
<Quantity 3303. K>

如果未给出任何参数(或参数为 None ),则此等效项采用当前缺省值 Cosmology

>>> z.to(u.K, cu.with_redshift())
<Quantity 3000.7755 K>

要在更大的代码块中使用此等效项,请执行以下操作:

>>> with u.add_enabled_equivalencies(cu.with_redshift()):
...     # long derivation here
...     z.to(u.K)
<Quantity 3000.7755 K>

减少的哈勃常数和“小h”当量#

哈勃常数的无量纲版本--通常被称为“小h”--是河外天体物理学中经常使用的一个量。它也被广泛认为是初学者在这些领域存在的祸害(例如,见标题 this paper ,这也为小h的使用提供了宝贵的建议)。 astropy 提供了 with_H0() 等价性,通过提供一种将物理单位转换为“小h”单位/从物理单位转换为“小h”单位的方法,帮助至少在其中一些情况下保持这一点。

实例#

转换为物理单位或从物理单位转换为“小h”单位:

>>> import astropy.units as u
>>> import astropy.cosmology.units as cu
>>> H0_70 = 70 * u.km/u.s/u.Mpc
>>> distance = 70 * (u.Mpc/cu.littleh)
>>> distance.to(u.Mpc, cu.with_H0(H0_70))  
<Quantity 100.0 Mpc>
>>> luminosity = 0.49 * u.Lsun * cu.littleh**-2
>>> luminosity.to(u.Lsun, cu.with_H0(H0_70))  
<Quantity 1.0 solLum>

请注意单位名称 littleh :而这个单位在文献中通常被表示为 h ,这就是 littleh 以避免与“小时”混淆。

如果未给出任何参数(或参数为 None ),则此等效项假定 H0 从当前默认设置 Cosmology

>>> distance = 100 * (u.Mpc/cu.littleh)
>>> distance.to(u.Mpc, cu.with_H0())  
<Quantity 147.79781259 Mpc>

这种等价性还允许小h比例的常见幅度公式:

>>> mag_quantity = 12 * (u.mag - u.MagUnit(cu.littleh**2))
>>> mag_quantity  
<Magnitude 12. mag(1 / littleh2)>
>>> mag_quantity.to(u.mag, cu.with_H0(H0_70))  
<Quantity 11.2254902 mag>

参考/API#

Asterpy.Cosmology.Units模块#

宇宙单位和等价物。

可用单位#

单位

描述

表示

别名

SI前缀

littleh

折合/“无因次”哈勃常数

不是

redshift

宇宙红移。

不是

功能#

dimensionless_redshift \()

允许红移为1:1等同于无量纲。

with_redshift([cosmology, distance, hubble, ...])

在宇宙学距离的度量之间换算。

redshift_distance([cosmology, kind])

在红移和距离之间转换数量。

redshift_hubble([cosmology])

在红移和哈勃参数与Little-h之间转换数量。

redshift_temperature([cosmology])

在红移和CMB温度之间换算量。

with_H0([H0])

在带有小-h的量和等价的物理单位之间进行转换。