Skip to content

jyangch/bayspec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

202 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A Bayesian inference-based spectral fitting tool for multi-dimensional and multi-wavelength astrophysical data.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages