pyne2001 安装与使用


pyne2001为用python包装NE2001银河自由电子密度模型的原始FORTRAN程序,该模块使用了 NE2001提供的FORTRAN代码的1.0版本, 以使文本输出的解析更容易。

安装

pyne2001 可以用尝试pip安装:

pip install pyne2001

但是会报错,其原因是在安装包pyne2001-0.1.3/pyne2001/NE2001/src下的Makefile文件有错误,故需要用以下方式安装:

    1. 下载pyne2001-0.1.3.tar.gz软件包
    1. 解压 tar xvf pyne2001-0.1.3.tar.gz
    1. 编辑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) where lim is a boolean flag that is True if the returned distance value is only a lower limit estimate (i.e. input DM exceeds Galactic contribution).
  • get_dist_full: Same as get_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 as get_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 calls get_dm with dist_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)

完结

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Persus

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值