常量 (astropy.constants
)¶
介绍¶
astropy.constants
包含许多在天文学中有用的物理常数。常数是 Quantity
具有描述其来源和不确定性的附加元数据的对象。
入门¶
要使用国际单位制(SI单位)中的常量,可以直接从 astropy.constants
子包:
>>> from astropy.constants import G
或者,如果要避免显式导入所需的所有常量,可以执行以下操作:
>>> from astropy import constants as const
然后,例如, const.G
. 常数是完全成熟的 Quantity
对象,以便您可以方便地将它们转换为不同的单位。
例子¶
要将常量转换为不同的单位:
>>> print(const.c)
Name = Speed of light in vacuum
Value = 299792458.0
Uncertainty = 0.0
Unit = m / s
Reference = CODATA 2018
>>> print(const.c.to('km/s'))
299792.458 km / s
>>> print(const.c.to('pc/yr'))
0.306601393788 pc / yr
然后可以将它们与unit和其他非常量结合使用 Quantity
物体::
>>> from astropy import units as u
>>> F = (const.G * 3. * const.M_sun * 100 * u.kg) / (2.2 * u.au) ** 2
>>> print(F.to(u.N))
0.3675671602160826 N
可以将大多数常量转换为厘米-克-秒(CGS)单位,例如:
>>> const.c.cgs
<Quantity 2.99792458e+10 cm / s>
然而,在CGS中,有些常量是用不同的物理维度定义的,不能直接转换。由于这种模糊性,在不指定系统的情况下,不能在表达式中使用这些常量:
>>> 100 * const.e
Traceback (most recent call last):
...
TypeError: Constant u'e' does not have physically compatible units
across all systems of units and cannot be combined with other
values without specifying a system (eg. e.emu)
>>> 100 * const.e.esu
<Quantity 4.8032045057134676e-08 Fr>
常量集合(和以前的版本)¶
常量被组织到版本模块中。的常数 astropy
2.0可以在 astropyconst20
模块。例如:
>>> from astropy.constants import astropyconst20 as const
>>> print(const.e)
Name = Electron charge
Value = 1.6021766208e-19
Uncertainty = 9.8e-28
Unit = C
Reference = CODATA 2014
物理CODATA常量在名为 codata2010
, codata2014
或 codata2018
:
>>> from astropy.constants import codata2014 as const
>>> print(const.h)
Name = Planck constant
Value = 6.62607004e-34
Uncertainty = 8.1e-42
Unit = J s
Reference = CODATA 2014
由国际天文学联合会(IAU)定义的天文常数被收集在模块中,其名称如下 iau2012
或 iau2015
:
>>> from astropy.constants import iau2012 as const
>>> print(const.L_sun)
Name = Solar luminosity
Value = 3.846e+26
Uncertainty = 5e+22
Unit = W
Reference = Allen's Astrophysical Quantities 4th Ed.
>>> from astropy.constants import iau2015 as const
>>> print(const.L_sun)
Name = Nominal solar luminosity
Value = 3.828e+26
Uncertainty = 0.0
Unit = W
Reference = IAU 2015 Resolution B 3
天文常数和物理常数被组合成具有以下名称的模块 astropyconst13
, astropyconst20
和 astropyconst40
对于不同的版本。但是,直接导入这些以前版本的模块会导致与已经导入的其他子包不一致 astropy.constants
. 尤其是, astropy.units
将已使用常量的默认版本。当以这种方式使用以前版本的常量时,应使用常量而不是单位来构造数量。
以确保在其他Astropy包(例如 astropy.units
)那个进口 constants
,物理和天文常数版本应通过 ScienceState
类。必须在第一次导入 astropy.constants
或 astropy.units
. 例如,可以使用CODATA2010物理常数和IAU 2012天文常数:
>>> from astropy import physical_constants, astronomical_constants
>>> physical_constants.set('codata2010')
<ScienceState physical_constants: 'codata2010'>
>>> physical_constants.get()
'codata2010'
>>> astronomical_constants.set('iau2012')
<ScienceState astronomical_constants: 'iau2012'>
>>> astronomical_constants.get()
'iau2012'
然后所有其他导入的包 astropy.constants
将使用以前版本的常量自一致初始化。
也可以使用参考版本模块的值来设置版本:
>>> from astropy import physical_constants, astronomical_constants
>>> physical_constants.set('astropyconst13')
<ScienceState physical_constants: 'codata2010'>
>>> physical_constants.get()
'codata2010'
>>> astronomical_constants.set('astropyconst13')
<ScienceState astronomical_constants: 'iau2012'>
>>> astronomical_constants.get()
'iau2012'
如果任一 astropy.constants
或 astropy.units
已经导入,a RuntimeError
将被提升。
>>> import astropy.units
>>> from astropy import physical_constants, astronomical_constants
>>> astronomical_constants.set('astropyconst13')
Traceback (most recent call last):
...
RuntimeError: astropy.units is already imported
参考/API¶
astropy.常数包裹¶
包含天文和物理常数,用于天文或其他地方。
典型的用例可能是:
>>> from astropy.constants import c, m_e
>>> # ... define the mass of something you want the rest energy of as m ...
>>> m = m_e
>>> E = m * c**2
>>> E.to('MeV')
<Quantity 0.510998927603161 MeV>
以下常量可用:
名字 |
价值 |
单位 |
描述 |
---|---|---|---|
G |
6.6743e-11号 |
m3/(kg s2) |
引力常数 |
N_A |
6.02214076e+23 |
1/(摩尔) |
阿伏加德罗数 |
R |
8.31446262 |
J/(千摩尔) |
气体常数 |
黑麦 |
10973731.6 |
1/(米) |
里德堡常数 |
a0 |
5.29177211e-11 |
米 |
玻尔半径 |
阿尔法 |
0.00729735257 |
精细结构常数 |
|
自动取款机 |
101325 |
宾夕法尼亚州 |
标准大气 |
b_wien |
0.00289777196 |
m千 |
维恩波长位移定律常数 |
C |
299792458 |
米/(秒) |
真空中的光速 |
E |
1.60217663e-19 |
C |
电子电荷 |
eps0 |
8.85418781e-12号 |
F/m公司 |
真空介电常数 |
g0号 |
9.80665 |
米/秒2 |
标准重力加速度 |
H |
6.62607015e-34 |
J s |
普朗克常数 |
糖化血红蛋白 |
1.05457182e-34 |
J s |
约化普朗克常数 |
k_B |
1.380649e-23 |
J/(K) |
玻尔兹曼常数 |
m_e |
9.1093837e-31 |
公斤 |
电子质量 |
m_n |
1.6749275e-27 |
公斤 |
中子质量 |
m_p |
1.67262192e-27 |
公斤 |
质子质量 |
mu0单位 |
1.25663706e-06 |
N/A2 |
真空磁导率 |
muB公司 |
9.27401008e-24 |
J/T公司 |
玻尔磁子 |
sigma_T |
6.65245873e-29 |
平方米 |
汤姆逊散射截面 |
sigma_sb |
电话:4208-745 |
W/(K4平方米) |
斯特凡玻尔兹曼常数 |
U |
1.66053907e-27 |
公斤 |
原子质量 |
GM_earth |
3.986004e+14 |
m3/(s2) |
标称地球质量参数 |
GM_jup |
1.2668653e+17 |
m3/(s2) |
名义木星质量参数 |
GM_sun |
1.3271244e+20 |
m3/(s2) |
标称太阳质量参数 |
L_bol0 |
3.0128e+28 |
W |
绝对辐射量0的光度 |
L_sun |
3.828e+26 |
W |
标称太阳光度 |
M_earth |
5.97216787e+24 |
公斤 |
地球质量 |
M_jup |
1.8981246e+27 |
公斤 |
木星质量 |
M_sun |
1.98840987e+30 |
公斤 |
太阳质量 |
R_earth |
6378100 |
米 |
标称地球赤道半径 |
R_jup |
71492000 |
米 |
木星名义赤道半径 |
R_sun |
695700000 |
米 |
标称太阳半径 |
澳大利亚 |
1.49597871e+11 |
米 |
天文单位 |
科索沃保护团 |
3.08567758e+19 |
米 |
千帕 |
个人电脑 |
3.08567758e+16 |
米 |
帕塞克 |
功能¶
|
4.0 版后已移除. |
Classes¶
|
物理或天文常数。 |
|
电磁常数。 |