Skip to main content

bayesvp

bayesvp is a Bayesian MCMC parallel Voigt profile fitting routine. bayesvp provides a number of helpful executable scripts that work with command line arguments (saved in your environment PATH). The main functionality is the MCMC Voigt profile fitting (bvpfit) where the user supplies a config file that specifies parameters for the fitting. These include parameter priors, number of walkers, parallel threads, line spread function, continuum model, Bayesian model comparisons, and etc. There are utility functions that allow users to quickly create an example config file, process and plot the chains, process and plot the best fit models and more. You can find more details on the code paper, Liang & Kravtsov 2017 or a related paper Liang et al. 2017

Installation

I recommend installing bayesvp with pip with the --user flag:

pip install bayesvp --user

This usually puts the executable scripts in ~/.local/bin. For MacOS users, ~/Users/username/.local/bin, where username is your username of your mac. Make sure that this is in your PATH.

You can also install it system-wide and might need to add sudo in the beginning.

After installing bayesvp, you should run its unit tests to ensure the package works as expected. The simplest way to do this is inside a python shell:

from bayesvp.tests import run_tests

The output should look something like this:

test_config_file_exists (bayesvp.tests.test_config.TCConfigFile) ... ok
test_default_no_continuum_params (bayesvp.tests.test_config.TCConfigFile) ... ok
test_example_mcmc_params (bayesvp.tests.test_config.TCConfigFile) ... ok
...
test_prior (bayesvp.tests.test_likelihood.TCPosterior) ... ok
test_general_intensity (bayesvp.tests.test_model.TCSingleVP) ... ok
test_simple_spec (bayesvp.tests.test_model.TCSingleVP) ... ok

----------------------------------------------------------------------
Ran 13 tests in 3.654s

OK

If you encounter any error, please send output to the author.

Usage and Tests:

You can run a full test example by executing:

bvpfit --test -pc

If the optional -pc flag is supplied, the default config file and a log are written to the current directory at which the command is run.

This will run an MCMC fit with the default config file and test spectrum (./data/example). After the fit is finished, to process the MCMC chain, you can type:

bvp_process_model --test

You can create your own default config file and modify it to suit the needs of your particular absorption line system. Use -a for the automatic flag.

bvp_write_config -a 

These executables accept command line arguments. For example, to get more info on the usage of bvpfit, simply type:

bvpfit -h

You may want to use the newly generated default config file after the test to set up absorption line systems of your own. Instead of --test, you can supply your own config file.

bvpfit full_path_to_my_own_config_file.dat

It should just be this easy if bayesvp is installed correctly and your environment PATH knows the location of these executables.

Required libraries:

  1. numpy, scipy, matplotlib and pyfits.

  2. MCMC Samplers (kombine and/or emcee)

Notes/Tips/Cautions:

  1. For placing constraints on non-detections (i.e., upper limits), one should not initialize walkers too far away from 'reasonable' parameters(e.g., column density or redshift if you know it from somewhere else). For example, if one knows logN= 15 is clearly too large given the data, then walkers should be initialized such that they do not waste time to get back to smaller logN and/or get stuck at larger logN.

  2. For upper limits, it is better to fix the redshift of the desired system in order to place constraints.

  3. In some cases, the data are contaminated by some other lines, one can skip this contaminated region. e.g., say, from (1215 1219) is the ideal region, but region from 1216 - 1217 is contaminated. Then just select regions in the config file, by breaking the wanted region into two regions (and so forth). 1215 1216 1217 1219

  4. One can add a continuum model (polynomial of degree n) by adding a new line: “continuum 1”, which will add a linear continuum with two extra of parameters (offset and a slope). We do not recommend to go higher than degree 2. The continuum model is restricted to fitting only one segment of the spectrum. Simultaneous fitting with multiple lines is not currently supported.

License & Citing

Author: Cameron Liang (jwliang@oddjob.uchicago.edu; cameron.liang@gmail.com)

Contributors: Andrey Kravtsov

License: MIT. Copyright (c) 2017-2018

If you use bayesvp, please cite the paper:

@ARTICLE{Liang2017,
   author = {{Liang}, C. and {Kravtsov}, A. and {Agertz}, O.},
    title = "{Observing the circumgalactic medium of simulated galaxies through synthetic absorption spectra}",
  journal = {ArXiv e-prints},
archivePrefix = "arXiv",
   eprint = {1710.00411},
 keywords = {Astrophysics - Astrophysics of Galaxies},
     year = 2017,
    month = oct,
   adsurl = {http://adsabs.harvard.edu/abs/2017arXiv171000411L},
  adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

or you can cite this one:

@ARTICLE{LiangKravtsov2017,
   author = {{Liang}, C. and {Kravtsov}, A.},
    title = "{BayesVP: a Bayesian Voigt profile fitting package}",
  journal = {ArXiv e-prints},
archivePrefix = "arXiv",
   eprint = {1710.09852},
 keywords = {Astrophysics - Astrophysics of Galaxies, Astrophysics - Instrumentation and Methods for Astrophysics},
     year = 2017,
    month = oct,
   adsurl = {http://adsabs.harvard.edu/abs/2017arXiv171009852L},
  adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

Release Notes

[0.2.4] - 2019-06-04: Added options to change to Agg backend from tkAgg.

Metadata

Release files for bayesvp 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bayesvp 0.2.5
File Size Uploaded Provenance Actions
bayesvp-0.2.5.tar.gz 531.5 kB Without provenance Details for bayesvp-0.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bayesvp 0.2.5
File Interpreter ABI Platform Actions
bayesvp-0.2.5-py2-none-any.whl Python 2 none any Details for bayesvp-0.2.5-py2-none-any.whl

Total release size: 1.1 MB

Release files / bayesvp-0.2.5.tar.gz

Download URL bayesvp-0.2.5.tar.gz
Size 531.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7167f9e0af52ba73ecad39a2f13c18dd2f642dc3f7ae9ed68486a287126fa4f1
BLAKE2b-256 checksum
How to use checksums
bcfebbbc9a5f5443fdbfa83c10915f1561b8045201b8fbbda13d5b628ed09716
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.13

Release files / bayesvp-0.2.5-py2-none-any.whl

Download URL bayesvp-0.2.5-py2-none-any.whl
Size 541.8 kB
Tags Python 2
SHA-256 checksum
How to use checksums
5eff0926dd270a4ab09fc024fb8753962801d3f38849b6eb55b75d87ade24565
BLAKE2b-256 checksum
How to use checksums
9a0ece261201021b4c2f44fc93b238801157f1522f2074b8dd2bfb298df4aeca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.13

Security for bayesvp 0.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page