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.

I hope you will find everything you need to know here, however feel free to get in touch if you have further questions, or to get an opinion on specific use cases.

What can Bagpipes do?


Star-formation history recovery from spectroscopy (see Carnall et al. 2019b)


Identification of z > 3 quiescent galaxies from photometry (see Carnall et al. 2020)

See also Carnall et al. (2019a), Williams et al. (2019) and Wild et al. (2020).

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: