pyne2001 安装与使用
pyne2001为用python包装NE2001银河自由电子密度模型的原始FORTRAN程序,该模块使用了 NE2001提供的FORTRAN代码的1.0版本, 以使文本输出的解析更容易。
安装
pyne2001
可以用尝试pip安装:
pip install pyne2001
但是会报错,其原因是在安装包pyne2001-0.1.3/pyne2001/NE2001/src
下的Makefile
文件有错误,故需要用以下方式安装:
-
- 解压
tar xvf pyne2001-0.1.3.tar.gz
- 解压
-
- 编辑
pyne2001-0.1.3/pyne2001/NE2001/src
下的Makefile
文件,需要在第一行加入:
FC = gfortran
如图所示
4.
pyne2001-0.1.3/
目录下运行python setup.py install
, 安装完毕,尝试In [1]: import pyne2001 In [2]: pyne2001.test() .............. ---------------------------------------------------------------------- Ran 14 tests in 0.599s OK
- 编辑
pyne2001 函数库
pyne2001
provides 6 functions, see their docstrings for the full details:
get_dist
: Calculate the NE2001 distance for the given Galactic coordinates and DM. Returns a tuple(dist_kpc, lim)
wherelim
is a boolean flag that isTrue
if the returned distance value is only a lower limit estimate (i.e. input DM exceeds Galactic contribution).get_dist_full
: Same asget_dist
, but instead return the full NE2001 output as a dictionary. The keys are parsed from the second output column of the NE2001 program, see table below and original paper for further details.get_dm
: Calculate the NE2001 DM for for the given Galactic coordinates and distance.get_dm_full
: Same asget_dm
, but instead return the full NE2001 output as a dictionary. The keys are parsed from the second output column of the NE2001 program, see table below and original paper for further details.get_galactic_dm
: A convenience function to get the Galactic DM contribution for a given line of sight. Simply callsget_dm
withdist_kpc = 30.0
.test
: Run all unit tests
输出结果详细如下:
Key Unit Description
------------------------------------------------------------
DIST (kpc) ModelDistance
DM (pc-cm^{-3}) DispersionMeasure
DMz (pc-cm^{-3}) DM_Zcomponent
SM (kpc-m^{-20/3}) ScatteringMeasure
SMtau (kpc-m^{-20/3}) SM_PulseBroadening
SMtheta (kpc-m^{-20/3}) SM_GalAngularBroadening
SMiso (kpc-m^{-20/3}) SM_IsoplanaticAngle
EM (pc-cm^{-6}) EmissionMeasure_from_SM
TAU (ms) PulseBroadening @1GHz
SBW (MHz) ScintBW @1GHz
SCINTIME (s) ScintTime @1GHz @100 km/s
THETA_G (mas) AngBroadeningGal @1GHz
THETA_X (mas) AngBroadeningXgal @1GHz
NU_T (GHz) TransitionFrequency
LOWERLIM If True, ModelDistance is a lower limit only
由脉冲星赤经赤纬,DM/DIST获取相关参数
python 代码如下:
from astropy.coordinates import SkyCoord
from astropy import units as u
import pyne2001 as pn
ra = "17:20:55" ##赤经
dec = "-05:33:40" ## 赤纬
dm = 36.8337 ## 脉冲星色散量
##转换为银经银纬
source = SkyCoord(ra+" "+dec,frame='icrs',unit=(u.hourangle,u.deg))
gl = source.galactic.l.deg
gb = source.galactic.b.deg
##已知DM 计算 由ISM导致的色散、散射、闪烁参数
para = pn.get_dist_full(gl,gb,dm)
print(para)
##已知距离 计算 由ISM导致的色散、散射、闪烁参数
dist = 1.3407
para = pn.get_dm_full(gl,gb,dm)
print(para)
完结