Skip to main content

BaySpec

Bayesian inference-based spectral fitting for high-energy astrophysical data.

PyPI Documentation BaySpec App on Hugging Face Spaces DOI License GPL-3.0


BaySpec is a Python library for Bayesian inference on high-energy astrophysical spectra. It pairs MCMC and nested-sampling backends with multi-spectrum, multi-model fitting machinery, reads OGIP FITS data out of the box, and bridges to local, astromodels, and Xspec model libraries.

Features

  • Inference backends. Posterior sampling via MCMC (emcee) or nested sampling (MultiNest via pymultinest); maximum-likelihood fits via lmfit or iminuit for quick checks.
  • OGIP Type I & II FITS. Source and background PHA/PHA2 spectra, plus RMF, RSP/RSP2, and ARF/ARF2 responses — multi-extension archives are row-indexed so individual spectra plug in directly.
  • Multi-dimensional. Time-evolving spectra fit with time-involved physical models.
  • Multi-wavelength. Joint fitting across spectra at different wavelengths.
  • Multi-spectrum, multi-model. Simultaneously fit any number of (data, model) pairs; combine, freeze, or link parameters across pairs.
  • Pluggable model libraries. A local set plus optional astromodels and Xspec bridges. Register your own Python functions as new components.
  • Browser workbench (optional). BaySpec App is a FastAPI + HTMX front-end that exposes the same fitting machinery through a web UI.

Installation

BaySpec is available on PyPI:

pip install bayspec

Optional: MultiNest sampler

To enable MultiNest for nested sampling, follow the pymultinest install guide.

Optional: astromodels components

To pull components from astromodels, install astromodels in your Python environment.

Optional: Xspec components

To pull components from Xspec:

  1. Install HEASoft and Xspec v12.12.1+.
  2. After initialising the HEASoft environment, install xspec-models-cxc.

Note: bayspec currently supports only Additive and Multiplicative Xspec models.

BaySpec App

BaySpec App is the browser front-end for bayspec — a FastAPI + HTMX workbench that loads OGIP spectra, composes models, and runs inference without notebook glue. A public, hosted deployment runs on Hugging Face Spaces:

Open in Spaces

Documentation

Read the full documentation or browse the examples for typical workflows end to end.

Citation

If you use BaySpec in your research, please cite the software version used in your analysis. Citation metadata are provided in CITATION.cff, and a reusable BibTeX entry is available in CITATION.bib. For version 0.4.5:

Yang, J. (2026). BaySpec: Bayesian inference for high-energy astrophysical spectra (Version 0.4.5) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.23291373

@software{bayspec,
  author  = {Yang, Jun},
  title   = {{BaySpec}: Bayesian inference for high-energy astrophysical spectra},
  version = {0.4.5},
  year    = {2026},
  month   = oct,
  date    = {2026-10-11},
  publisher = {Zenodo},
  doi     = {10.5281/zenodo.23291373},
  url     = {https://doi.org/10.5281/zenodo.23291373}
}

Cite the version-specific DOI for the version used in your analysis. The all-versions DOI identifies BaySpec across releases and links to the latest archived version.

License

BaySpec is distributed under the GPL-3.0 license.

Metadata

Release files for bayspec 0.4.6

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

Source distribution (sdist)

Source distribution for bayspec 0.4.6
File Size Uploaded Provenance Actions
bayspec-0.4.6.tar.gz 989.7 kB Without provenance Details for bayspec-0.4.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bayspec 0.4.6
File Interpreter ABI Platform Actions
bayspec-0.4.6-py3-none-any.whl Python 3 none any Details for bayspec-0.4.6-py3-none-any.whl

Total release size: 2.0 MB

Release files / bayspec-0.4.6.tar.gz

Download URL bayspec-0.4.6.tar.gz
Size 989.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b2d6af0a144af19fc96375596781f36ca8fbdad1a55a2cf50ac095446d4fb769
BLAKE2b-256 checksum
How to use checksums
1f0afe1d6f0f263e8b9e92a1aa0d9b2dca87afc09706a96785644d11949b5b65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / bayspec-0.4.6-py3-none-any.whl

Download URL bayspec-0.4.6-py3-none-any.whl
Size 993.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
216dede49c2d1f6511b9dec9f3e2dd8e428e51d9f3d5e2015890ff699bc63791
BLAKE2b-256 checksum
How to use checksums
5f9228df59d988c628ce496abbddeeaa7bf6fa436a994a3ca77ebc1f03f3e893
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Security for bayspec 0.4.6

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.

Release history Release notifications | RSS feed

This release

0.4.6 This release

2 release files No provenance

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