Bayesian inference-based spectral fitting for high-energy astrophysical data.
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 (MultiNestviapymultinest); maximum-likelihood fits vialmfitoriminuitfor quick checks. - OGIP Type I & II FITS. Source and background
PHA/PHA2spectra, plusRMF,RSP/RSP2, andARF/ARF2responses — 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
astromodelsandXspecbridges. 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:
- Install
HEASoftandXspec v12.12.1+. - After initialising the
HEASoftenvironment, installxspec-models-cxc.
Note:
bayspeccurrently supports onlyAdditiveandMultiplicativeXspecmodels.
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:
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)
| 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)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| 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.