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.
License
BaySpec is distributed under the
GPL-3.0 license.
Metadata
Release files for bayspec 0.3.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bayspec-0.3.14.tar.gz | 110.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bayspec-0.3.14-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 229.3 kB
Release files / bayspec-0.3.14.tar.gz
| Download URL | bayspec-0.3.14.tar.gz |
|---|---|
| Size | 110.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61a2cd72cf5261a34fd0360c5c8734f2104e34dccc103cf8f9e5a670eb9016fd
|
|
BLAKE2b-256 checksum How to use checksums |
e6c30482505f84363e4389564d427ca8d8fd85c9aeee08534734af3e811e246b
|
| 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.3.14-py3-none-any.whl
| Download URL | bayspec-0.3.14-py3-none-any.whl |
|---|---|
| Size | 118.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3be4630e1da8575ec510e85645cee209142d4296f7b25c80d86ece5476fa6972
|
|
BLAKE2b-256 checksum How to use checksums |
e013464c04247ed6cf28c216e2d471ce6702d51e56f49dc32a0ae173a50e19c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|