Bagpipes¶
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. I’ve recently added a latest news page, which I’ll use to track updates to the code and any issues people make me aware of.
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)
Bagpipes has been used in ~30 refereed publications as of Jan 2021. For more example use cases take a look at papers that cite the bagpipes paper, e.g. 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 (with Homebrew installed) is as follows:
git clone https://github.com/JohannesBuchner/MultiNest
brew install gcc49
export DYLD_LIBRARY_PATH="/usr/local/bin/gcc-4.9:$DYLD_LIBRARY_PATH"
cd MultiNest/build
cmake ..
make
sudo make install
cd ../..
rm -r MultiNest
If you are running a Linux operating system, or have MacPorts instead of Homebrew, you may run into additional issues. I may be able to provide advice if you get stuck.
Published papers and citing the code¶
Bagpipes is described primarily in Section 3 of Carnall et al. (2018), with further development specific to spectroscopic fitting described in Section 4 of Carnall et al. (2019b). These papers are the best place to start if you want to understand how the code works.
If you make use of Bagpipes, please include a citation to Carnall et al. (2018) in any publications. You may also consider citing Carnall et al. (2019b), particularly if you are fitting spectroscopy.
Please note development of the code has been ongoing since these works were published, so certain parts of the code are no longer as described. Please inquire if in doubt.
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.
Acknowledgements¶
A few of the excellent projects Bagpipes relies on are:
The Bruzual & Charlot (2003) stellar population models.
The Draine & Li (2007) dust emission models.
The MultiNest nested sampling algorithm (Feroz et al. 2013)
The PyMultiNest Python interface for Multinest (Buchner et al. 2014).
The Cloudy photoionization code (Ferland et al. 2017).
The Deepdish HDF5 loading/saving interface.