Bsixsa

Bayesian X-ray spectral fitting library built on PyXspec with nested sampling and MCMC backends.

What it is

bsixsa is a Python package for Bayesian X-ray spectral analysis that wraps PyXspec with a range of sampling and optimisation methods. It provides nested sampling, MCMC, gradient-based optimisers, and the SIXSA simulation-based inference approach from recent astronomy literature. The library originated as a fork of the BXA toolkit and retains a similar syntax while expanding support for modern backends.

Key features include a unified Solver interface that accepts priors for each free model parameter, automatic handling of XSPEC fit statistics, and pluggable sampler extras such as Nautilus, NESSAI, UltraNest, emcee, and iminuit. SIXSA and Levenberg-Marquardt require no extra dependencies. The documentation covers installation, simple fit examples, prior specification, history matching, backend selection, and plotting utilities.

The primary audience consists of astronomers and high-energy astrophysics researchers who need rigorous uncertainty quantification for X-ray spectra. It helps users move beyond traditional chi-square fitting by delivering full posterior distributions, evidence values, and model comparison metrics. The package is particularly useful for faint sources, complex models, and cases where systematic uncertainties matter.

Getting started requires a conda environment with XSPEC and its calibration data from the HEASARC channel, followed by a pip install from the GitHub repository with desired sampler extras. The site provides copy-paste commands for environment creation and package installation, along with guidance on choosing a backend based on problem dimensionality and speed requirements.

Notable aspects include direct links to the underlying SIXSA papers, transparent discussion of current limitations such as incomplete multi-spectrum support and background handling caveats, and a workflow for exporting posterior chains back into XSPEC for flux calculations. The project is actively developed and hosted on Read the Docs with versioned builds.

This description was generated by AI from the site's public content and may contain errors.

What you can do there

  • Read installation and usage documentation
  • Run simple fit and NXB examples
  • Choose and configure sampling backends
  • Export posterior chains to XSPEC
  • Cite the underlying SIXSA methodology papers

Who it's for

Astronomers and astrophysicists performing Bayesian X-ray spectral analysis.

Frequently asked questions about bsixsa.readthedocs.io

›What is bsixsa used for?

bsixsa performs Bayesian X-ray spectral fitting using PyXspec models with nested sampling, MCMC, optimisers, or simulation-based inference.

›How do I install bsixsa?

Create a conda environment with XSPEC from the HEASARC channel, then install bsixsa from GitHub using pip with the desired sampler extras.

›Which sampling backends are supported?

Supported backends include Nautilus, NESSAI, UltraNest, emcee, and iminuit as optional extras; SIXSA and Levenberg-Marquardt are built in.

›Can I fit multiple spectra simultaneously?

Multiple spectra and backgrounds are not fully supported; nested samplers and emcee use the total fit statistic but this is not systematically tested.

›Is bsixsa available on PyPI?

The current 0.2 release is not on PyPI; the package there is an older incompatible version. Installation must be done from GitHub.

›How do I compute fluxes from the posterior?

Export the posterior as an XSPEC chain and use XSPEC's flux command with errors, as demonstrated in the simple fit example.

›What are the main limitations of bsixsa?

Limitations include no explicit multi-spectrum support, background handling only for nested samplers, SIXSA restricted to one spectrum with cstat, and no cross-calibration constants through the standard interface.