Skip to main content

Python/C++ version of YMW16 electron density model

Project description

Build Status License: LGPL v3 Coverage Status

PyYMW16

A Python / C++ Version of YMW16 electron-density model

This is a Python / C++ port of the Yao, Manchester and Wang (2017, Astrophys. J., 835, 29; arXiv:1610.09448) YMW16 electron density model. The code uses pybind11 to create Python bindings to the (C++ ported) YMW16 code.

Usage

Some usage examples can be found in the examples directory.

import pyymw16

# calculate DM at a given distance
DM, tau_sc = pyymw16.dist_to_dm(204.0, -6.5, 200)

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

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

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

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

import pyymw16
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 = pyymw16.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, and a newish C compiler with C++11 support (Ubuntu 16.04+ default gcc will work).

You should be able to install with:

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

Or, 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 source code.

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 http://www.xao.ac.cn/ymw16/, http://www.atnf.csiro.au/research/pulsar/ymw16/ and https://bitbucket.org/psrsoft/ymw16/.

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)

Project details


Download files

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

Source Distribution

pyymw16-2.0.7.tar.gz (18.1 kB view details)

Uploaded Source

Built Distributions

pyymw16-2.0.7-cp36-cp36m-macosx_10_7_x86_64.whl (67.1 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

pyymw16-2.0.7-cp27-cp27m-macosx_10_13_x86_64.whl (65.7 kB view details)

Uploaded CPython 2.7m macOS 10.13+ x86-64

File details

Details for the file pyymw16-2.0.7.tar.gz.

File metadata

  • Download URL: pyymw16-2.0.7.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for pyymw16-2.0.7.tar.gz
Algorithm Hash digest
SHA256 a1ab9a4a3fdb7d9a6ccaa949840e21319f8c44707eb7dd033d14e6e6697696a5
MD5 8d8f7eaaa96f43f01a23fdf7290c29ea
BLAKE2b-256 e0aa65f18199e4d8b772426d97ba28b1765b74a9d0eb5b036667b234ab143887

See more details on using hashes here.

File details

Details for the file pyymw16-2.0.7-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: pyymw16-2.0.7-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 67.1 kB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for pyymw16-2.0.7-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 e5eb39521a5bdab1e0027dbe63c55b0d8f03215c630e0f533a0a33ba235e84e5
MD5 63fda9c6ee5252686301217167f5ed19
BLAKE2b-256 9fc004d3d2cd20f447a2d63143341b159805ea4d709dba9a30fd1ff7bc843aff

See more details on using hashes here.

File details

Details for the file pyymw16-2.0.7-cp27-cp27m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: pyymw16-2.0.7-cp27-cp27m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 65.7 kB
  • Tags: CPython 2.7m, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for pyymw16-2.0.7-cp27-cp27m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 06245be1e8aa679ccd26a84c954fb4c20c033e3dd217b2ebfb3a419a53aac8fd
MD5 e23c263a05bcc33618966965ea332143
BLAKE2b-256 99ea35d46e5e865686275afa7104f498d87f73604cbce825cf0fb98b2c628228

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