Skip to main content

BaySpec

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

PyPI Documentation BaySpec App on Hugging Face Spaces 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.

License

BaySpec is distributed under the GPL-3.0 license.

Metadata

Release files for bayspec 0.4.4

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.4
File Size Uploaded
bayspec-0.4.4.tar.gz 130.0 kB Details

Built distribution (wheel)

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

Total release size: 268.6 kB

Release files / bayspec-0.4.4.tar.gz

Download URL bayspec-0.4.4.tar.gz
Size 130.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4e0375407fae7b3f8d0accecafc05e8b79ca226f0544cc5a0f3f9b39cdfc7024
BLAKE2b-256 checksum
How to use checksums
dc7a98817a6e77814321f85b08e03d77a639c2549c6488dd13dd4fc747610e18
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.4-py3-none-any.whl

Download URL bayspec-0.4.4-py3-none-any.whl
Size 138.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d886282452f56b8fa03bf0d59e1d88d5b1a5b8057d378bed723eedccc25421a
BLAKE2b-256 checksum
How to use checksums
94b9d8dcaff4483949a2b5f2134742e1cf0c2134740a35f4d6db0958594c6c20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release history Release notifications | RSS feed

0.4.5

2 release files

This release

0.4.4 This release

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.14

2 release files

0.3.13

2 release files

0.3.12

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.1.18

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.11

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

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