Skip to main content

Python/C++ version of NE2001, YMW16, and YT2020 electron density models

Project description

Python application License: LGPL v3 CoverageDocumentation Status

PyGEDM

Python bindings for the YMW16, NE2001 and YT2020 electron density models

This package is a Python interface to the YMW16 and NE2001 electron density models, and YT2020 halo model. The Yao, Manchester and Wang (2017, Astrophys. J., 835, 29; arXiv:1610.09448) YMW16 electron density model, is written in C++, and the Cordes and Lazio (2001, arXiv:0207156) NE2001 model is written in FORTRAN. This package, PyGEDM, wraps these two codes using pybind11 to make them usable from Python. Here, we have converted NE2001 to C++ using f2c.

Usage

Some usage examples can be found in the examples directory.

import pygedm

# calculate DM at a given distance
DM, tau_sc = pygedm.dist_to_dm(204.0, -6.5, 200, method='ne2001')
DM, tau_sc = pygedm.dist_to_dm(204.0, -6.5, 200, method='ymw16')

# calculate distance for a given sky position and DM
dist, tau_sc = pygedm.dm_to_dist(123.4, 4.0, 200)

# calculate N_e density at xyz galactocentric coordinates
ne = pygedm.calculate_electron_density_xyz(1.0, 2.0, 3.0)

# calculate N_e density at Galactic lat/long/distance coords
ne = pygedm.calculate_electron_density_lbr(204.0, -6.5, 3000.0)

# Calculate halo DM contribution
dm_halo = pygedm.calculate_halo_dm(gl=0, gb=30)

The methods return astropy Quantities, which have units attached, and can accept astropy Angles and Quantities as arguments:

import pygedm
import astropy.units as u
import astropy.coordinates as c
DM = u.Quantity(10.0, unit='pc cm^-3')
ra, dec = c.Angle(23.0, unit='hourangle'), c.Angle('-43:00:02', unit='degree')
sky_coords = c.SkyCoord(ra, dec, frame='icrs')
dist, tau_sc = pygedm.dm_to_dist(sky_coords.galactic.l, sky_coords.galactic.b, DM)

print(dist.to('lyr'))
>> 3362.16343117 lyr
print(tau_sc.to('ns'))
>> 7.758686138 ns

Installation

Requires pybind11, astropy, numpy, scipy, a newish C compiler with C++11 support (Ubuntu 16.04+ default gcc will work), plus f2c (apt-get f2c in Ubuntu, conda install -c conda-forge f2c if using conda).

You should be able to install with:

pip install pygedm

or

pip install git+https://github.com/telegraphic/pygedm

to install the latest version from github. Alternatively, download this repository and install via

python setup.py install

To run unit tests, run python setup.py test. Note that these tests only check the Python bindings, not the underlying C/FORTRAN source code (which is not supplied with unit tests).

References

If using PyGEDM in a journal article, please remember to cite the underlying electron density models:

Cordes, J. M., & Lazio, T. J. W. (2002),
NE2001.I. A New Model for the Galactic Distribution of Free Electrons and its Fluctuations, arXiv e-prints, astro-ph/0207156.

Cordes, J. M., & Lazio, T. J. W. (2003),
NE2001. II. Using Radio Propagation Data to Construct a Model for the Galactic Distribution of Free Electrons, arXiv e-prints, astro-ph/0301598.

Yao, J. M., Manchester, R. N., & Wang, N. (2017),
A New Electron-density Model for Estimation of Pulsar and FRB Distances, The Astrophysical Journal, Volume 888, Issue 2, id.105, Colume 835, id.29

Yamasaki, S., & Totani, T. (2020),
The Galactic Halo Contribution to the Dispersion Measure of Extragalactic Fast Radio Bursts, The Astrophysical Journal, Volume 888, Issue 2, id.105

These are available in bibtex format in references.bib, and also as an ADS library.

YMW16 C README

YMW16 is a model for the distribution of free electrons in the Galaxy, the Magellanic Clouds and the inter-galactic medium, that can be used to estimate distances for real or simulated pulsars and fast radio bursts (FRBs) based on their position and dispersion measure.

The Galactic model is based on 189 pulsars that have independently determined distances as well as dispersion measures, whereas simpler models are used for the electron density in the MC and the IGM. It is estimated that the 95% of predicted Galactic pulsar distances will have a relative error of less than a factor of 0.9. Pulse broadening due to scattering in the Galactic interstellar medium, the Magellanic Clouds, the intergalactic medium and FRB host galaxies is estimated.

As well as the ymw16 dm-distance program, we also provide a program, ymw16_ne, which gives the electron density at any point in the Galaxy or Magellanic Clouds.

A paper (Yao, Manchester and Wang, 2017, Astrophys. J., 835, 29; arXiv:1610.09448) describes the model and compares its predictions with those of earlier Galactic electron density models. YMW16 is the first electron-density model to estimate extragalactic pulsar distances and FRB distances.

To make a command-line executable version of the program, download and unpack the latest version of the program. Then run "make_ymw16" to create the executable. The environment variable YMW16_DIR may be set up to point at a directory containing ymw16par.txt and spiral.txt. Access to these files is needed at runtime.

Websites allowing interactive access to the YMW16 distance model and download of the latest program version are available at:

Please report any issues or bugs at https://bitbucket.org/psrsoft/ymw16/issues/new/ or directly to the authors. Please provide an example illustrating the problem.

YMW16 C LICENSE

Copyright (C) 2016, 2017  J. M. Yao, R. N. Manchester, N. Wang.

YMW16 is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.

YMW16 is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License,
available at http://www.gnu.org/licenses/, for more details.

Jumei Yao (yaojumei _@_ xao.ac.cn), Richard N Manchester
(dick.manchester _@_ csiro.au), Na Wang (na.wang _@_ xao.ac.cn)

NE2001 README

07 July 2002 To compile and execute the code, see code.pdf.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pygedm-0.0.3-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

pygedm-0.0.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

pygedm-0.0.3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

pygedm-0.0.3-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

File details

Details for the file pygedm-0.0.3-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for pygedm-0.0.3-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f3bb2e69a74e26fabdf0405d5c61354170a0b7d6a566fa5df455d18fd2d6e0de
MD5 79207053d55ee6fc2805292b5fd3de79
BLAKE2b-256 fdec0d13f512ba9306647c92c0c4bbabc6466c81b1195650fc0138acc9ef334a

See more details on using hashes here.

File details

Details for the file pygedm-0.0.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for pygedm-0.0.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 38a3e3440390f12ecece92f1c8b6cb2cd223df3bc31af3d200785a8db22e0091
MD5 4c388c189135b96fb07a427f5f9ecd0c
BLAKE2b-256 47c4160f8582ec463db4a877d7af11682c0df61714ce029b699278c30f01aedf

See more details on using hashes here.

File details

Details for the file pygedm-0.0.3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for pygedm-0.0.3-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 7267319afa2c8f544f1e474e7dfafdec82c15a7a7e135f4b82ee20da0de17d63
MD5 5d9c3ec6eef08b5c53033b6b59d2ee3f
BLAKE2b-256 849d29f2737d4c99a3e1e01ac5a0b5e2c153c025833aae60ddc9d70c41b946e3

See more details on using hashes here.

File details

Details for the file pygedm-0.0.3-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for pygedm-0.0.3-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ecb7f14027e61961fb7e68e0b489ba51950da5161f02d81ac989a6766f81c429
MD5 dacb53a9090caae862b23c151269462c
BLAKE2b-256 277d2070549ac04cfb8b446cc34077b45d81d309515262c472b80056cacfd0e0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page