Package: pyne2001
pyne2001A python wrapper around the original FORTRAN implementation of the NE2001 Galactic free electron density model, published in the paperNE2001.I. A New Model for the Galactic Distribution of Free Electrons and its Fluctuations, by J.M. Cordes and T.J.W. Lazio.If usingpyne2001contributes to a project that leads to a scientific publication, please cite the article above.The python functions implemented inpyne2001simply call the NE2001 executable and parse the resulting text output. This module uses version 1.0 of the FORTRAN code available fromhttp://hosting.astro.cornell.edu/~cordes/NE2001/, with a few minor changes documented below (c.f. section "FORTRAN code changes").None of the changes affect the numerical results returned by the NE2001 program, they are just minor bugfixes and quality-of-life changes to make the parsing of the text output easier.Dependencies and Python versionpyne2001works with both python 2.7 and python 3+, and does not depend on any external python libraries. A FORTRAN compiler must be available on the system prior to installing the module.Installationpyne2001can be installed easily with pip:pipinstallpyne2001To check that all went well, try importing the module and running the unit tests, you should see something like this:In [1]: import pyne2001

In [2]: pyne2001.test()
..............
----------------------------------------------------------------------
Ran 14 tests in 0.599s

OKInstallation in development modeIf you want to be able to modify the code freely: clone the repository, then in its base folder typemake install. This compiles the FORTRAN code and runspip installineditable mode.Usagepyne2001provides 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)wherelimis a boolean flag that isTrueif 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_dmwithdist_kpc = 30.0.test: Run all unit testsThe output keys when returning the full output are: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 onlyFORTRAN code changesBugfixes:Removed extra space between declaredcommonarrays  (dmdsm.NE2001.f:68)Replaced hardcoded1by1.0in a call tomax()that needs two arguments of type float (dmdsm.NE2001.f:408)Replacediargcbyiargc_(NE2001.f:28-29)Replaced obsolete PAUSE statement with a WRITE (density.NE2001.f:697)Changes:Input files are now all placed in/bin. Removed/inputdirectory.Removedrun_NE2001.plChanged compiler from f77 to gfortran (Makefile)make cleannow also deleteslibNE2001.a(Makefile)