Bayesian Analysis of Galaxies for Physical Inference and Parameter EStimation is a state of the art Python code for modelling galaxy spectra and fitting spectroscopic and photometric observations.

Bagpipes is currently in a state of active development in the run-up to the release of version 1. Please email me if you have any queries, or find things which don’t work as they’re supposed to.


Source and installation

Bagpipes is developed at GitHub, however the code cannot be installed from there, as the large model grid files aren’t included in the repository. The code should instead be installed with pip:

pip install bagpipes

All of the code’s Python dependencies will be automatically installed. The only non-Python dependency is the MultiNest nested sampling algorithm (used only for fitting). To install MultiNest see point 1 of the “on your own computer” section of the PyMultiNest installation instructions.

In my experience, the sequence of commands necessary to install MultiNest on a mac is as follows:

git clone
brew install gcc49
export DYLD_LIBRARY_PATH="/usr/local/bin/gcc-4.9:$DYLD_LIBRARY_PATH"
cd MultiNest/build
cmake ..
sudo make install
cd ../..
rm -r MultiNest


Bagpipes is described in Section 3 of Carnall et al. 2018, if you make use of Bagpipes, please include a citation to this work in any publications. Please note development of the code has been ongoing since this work was published, so certain parts of the code are no longer as described.

Getting started

The best place to get started is by looking at the iPython notebook examples. It’s a good idea to tackle them in order as the later examples build on the earlier ones. These documentation pages contain a more complete reference guide.

Bagpipes is structured around three core classes:

  • model_galaxy: for generating model galaxy spectra
  • galaxy: for loading observational data into Bagpipes
  • fit: for fitting models to observational data.


A few of the excellent projects Bagpipes relies on are: