Phil Bull > Code


I try to make all of my scientific code, or at least a substantial fraction of it, publicly available. This enables other people to reproduce and check my work if they want to. It also allows them to build off my code and do cool new things, rather than having to spend months solving problems that I may have already solved. That's the theory, anyway. Much of the code is written in Python, C++, and/or Fortran 90, and housed on Gitlab.


RadioFisher is a Fisher forecasting code for cosmology with intensity maps of the redshifted 21cm emission line of neutral hydrogen. The formalism implemented by this code is described in Bull, Ferreira, Patel and Santos (2014).

For code and documentation, check out the Radio Fisher git repository.

There are also some additions for forecasting modified gravity parameters; you can learn more about about them here.

Commander 2

I'm one of the main developers of Commander 2, an advanced full-sky CMB analysis code. It's designed to do CMB component separation, power spectrum estimation, and a bunch of other things for full-sky, high-resolution, multi-frequency CMB experiments like WMAP and Planck.

Commander implements a Gibbs sampling scheme, which means that we are able to sample from the full joint posterior distribution of a realistic physical sky model. This is great for making sure that statistical uncertainties are rigorously propagated, so Commander is the method of choice for low-ℓ power spectrum estimation, producing physical foreground maps, and detecting exotic features in the CMB.

For more details on Commander 2, including the source code and a list of related publications, check out the Commander website.


FIST (Flat-sky Inference of Spatial Templates) is a joint project between myself and Thibaut Louis for performing Gibbs sampling on small patches of the CMB sky. Based on the Commander Gibbs sampling scheme, it's specifically geared towards characterising the Sunyaev-Zel'dovich effect from galaxy clusters detected by small-angle CMB experiments like ACT and SPT. It's fast and flexible enough to support a range of other types of analyses, though, and we're open to suggestions for how to extend it.

The code is still under heavy development. FIST will be released under an open source license once it's matured, but for now you can check out the git repository if you'd like to see how it's progressing.

Spectral Distortions

This is a Python numerical code for calculating spectral distortions in a perturbed LambdaCDM model. The emphasis is on calculating the Kinematic SZ angular power spectrum and Compton-y distortion in the presence of a large, spherically-symmetric potential fluctuation centred on the observer, but it should be pretty easy to modify it for more general usage. The code was used in my February 2013 paper with Marc Kamionkowski. You can find all of the Python scripts used for this paper in this git repo. The bulk of the interesting numerics are contained within, so check that out first.

You are free to use, distribute, and modify this code, as long as you cite our paper, Phys. Rev. D 87, 081301(R) (2013).

Bubble (relativistic exact solutions)

Bubble is an umbrella project for a number of numerical codes for general relativistic cosmology that I have written in Python and C++. Much of the code is a perpetual "work in progress", and is not really intended for "useful" public release. It is provided mostly so that people can inspect my code, and use and adapt it if they wish, but I've made no attempt to factor it into an easy-to-use library. That said, if you would like to use the code, please email me and I'll be very happy to help you get it working. If you notice any problems (and I encourage you to look for them!), please let me know, and I'll either fix them myself, or merge your patches.

What does it do?

There are a number of different codes contained within this project.

Using the code

Large segments of the code have been tested for correctness and used to produce scientific results, but if you do use it for your own work, I suggest that you perform your own tests as well. This code release is part of my commitment to producing open, reproducible scientific results. If you do use it, or a modified version of it, please cite the relevant paper:

There is some inter-dependence between the code in the different branches. For example, mcmc requires a pre-built binary of bubble for some of its functions to run. Likewise, the code in accel depends on pyltb. You will find that you need to edit makefiles and so on to get some things working. It should be reasonably self-explanatory, but please do email me if you get stuck.

The best way of getting the code is to clone the appropriate git repository.

Can I modify the code?

Yes, you can. In fact, I actively encourage it! It would be great if you could release any modifications that you make to the code, so that they can be shared by everyone. I'm not a stickler about it, though, as long as: (a) you're nice about it, (b) make good faith attempts to describe and/or share your modifications if asked, and (c) you give proper credit. In return, I promise to be super nice to you, and give you all the help I can. You should, however, be aware that bubble links against GSL, so if you publicly release it, or a modified version of it, you must abide by the GPL.