Public repository for the Monte Python Code
Python C Other
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bestfit added covmat and bestfit for highl+lowl+lensing and for highlTTTEEE+lowl Oct 1, 2015
covmat Added BK14 likelihood as well as Planck priors on two nuisance parame… Jul 20, 2016
data added file for sensitivity of DESI Jun 20, 2016
montepython finally coded a really robust method for nice 1d posterior curves Oct 12, 2017
plot_files added new option info.force_limits{} in .plot file Aug 27, 2017
sphinx-documentation corrected typo in doc: --conf instead -conf Jun 2, 2016
tests updated changelog and tests to reflect latest lensing behaviour Sep 30, 2014
wrapper_wmap removed the source tar.gz for likelihood_v4p1 to force a download Oct 25, 2012
.gitignore ignoring coverage information Oct 13, 2014
.landscape.yaml added config for Landscape Sep 10, 2014
BK14.param Added BK14 likelihood as well as Planck priors on two nuisance parame… Jul 20, 2016
LICENSE.txt added the MIT license file Aug 15, 2014
Makefile added a Makefile for running separate tests May 23, 2014
README.rst Updated to transfer to the new repository May 10, 2018
TODO.rst Fixed error on git Apr 3, 2014
VERSION version number updated to 2.2.2 Apr 12, 2016
base.param updated to planck 2015 likelihoods Jul 17, 2015
base2015.param added the base input files for Planck2015 Jun 3, 2015
base2015TTTEEE.param added the base input files for Planck2015 Jun 3, 2015
base2015lite.param updated to planck 2015 likelihoods Jul 17, 2015
base_actspt.param added param files for actstp+Planck Sep 11, 2014
bicep2.param Changed rights of the file May 13, 2014
changelog.dat updated changelog to 2.2.1 Oct 28, 2015
default.conf.template updated to planck 2015 likelihoods Jul 17, 2015
example.param Fixed example.param for the current list of experiments Apr 2, 2014
example_ns.param good version of NS, example with fake planck Nov 4, 2013
jla.param JLA fixed Sep 28, 2014
setup.cfg Basic layout for the test module - much work to be done still Feb 14, 2014 one more try for RTD Oct 22, 2014
test.param bug fix for IS, cosmo_arguments not ignored Nov 25, 2014
test_gaussian.param NS: test .param file for the test_gaussian likelihood improved. May 7, 2014
test_is.param bug fix for IS, cosmo_arguments not ignored Nov 25, 2014


[Archived] Please see the maintained Monte Python v3.0:

Author: Benjamin Audren <>

If you are searching for specific examples of a work session, please refer to the pdf documentation. The code is under the MIT license. As an additional clause, you are also required to cite the original release paper when using it in a scientific publication: Conservative Constraints on Early Cosmology (see the tail of this document)


  • You need the python program version 2.7 or above, but less than 3.0. Note that lower versions of python will work, down to 2.6 (tested), if you add manually two extra packages ( ordereddict and argparse).
  • Your python of choice must have numpy (version >= 1.4.1) and cython. The later is used to wrap CLASS in python.
  • [optional] If you want to use fully the plotting capabilities of Monte Python, you also need the scipy, with interpolate, and matplotlib modules.
  • [optional] You can now use Multi Nest and the CosmoHammer with Monte Python, though you need to install them. Please refer to the documentation.

The MontePython part

Move the .tar.bz2 file to the place of your convenience, untar its content

$ bunzip2 montepython-vx.y.tar.bz2
$ tar -xvf montepython-vx.y.tar

This will create a directory named montepython into your current directory. You can add the following line to your .bashrc file:

export PATH=/path/to/MontePython/montepython/:$PATH

to be able to call the program from anywhere.

You will need to adapt only two files to your local configuration. The first is the main file of the code montepython/, and it will be the only time you will have to edit it, and it is simply to accommodate different possible configurations of your computer.

Its first line reads


This should be changed to wherever is your preferred python distribution installed. For standard distribution, this should already be working. Now, you should be able to execute directly the file, i.e. instead of calling:

The second file to modify is located in the root directory of Monte Python : default.conf. This file will be read (and stored) whenever you execute the program, and will search for your cosmological code path, your data path, and your wmap wrapper path. You can alternatively create a second one, my.conf, containing your setup, and then run the code providing this file (with the flag --conf)

The Class part

Go to your class directory, and do make clean, then make. This builds the libclass.a, needed for the next step. From there,

$ cd python/
$ python build
$ python install --user

This will compile the file classy.pyx, which is the python wrapper for CLASS, into a library,, located in the build/ subdirectory. This is the library called in Monte Python afterwards.

If this step fails, check that you have cython installed, numpy (a numerical package for python), python (well... did I say this code was in python ?) with a version > 2.6. If this step fails again, kindly ask your system admin, (s)he is there for this, after all. Note that the installation (last command) is not strictly speaking mandatory.

Remember that if you modify CLASS to implement some new physics, you will need to perform this part again for the new CLASS.

The Planck likelihood part

The release of the Planck data comes with a likelihood program, called Clik, that one can recover from the ESA website, along with the data. Download all tar.gz files, extract them to the place of your convenience.

The Planck Likelihood Code (plc) is based on a library called clik. It will be extracted, alongside several .clik folders that contain the likelihoods. The installation of the code is described in the archive, and it uses an auto installer device, called waf.


Note that you are strongly advised to configure clik with the Intel mkl library, and not with lapack. There is a massive gain in execution time: without it, the code is dominated by the execution of the low-l polarisation data from WMAP.

Go to your plc folder, and execute the following line, taking into account the mkl installation

$ ./waf configure --install_all_deps --mkl=...

In your |MP| configuration file, to use this code, you should add the following line

path['clik'] = 'path/to/your/plc/folder/'

The four likelihoods defined in |MP| for Planck are Planck_highl, Planck_lowl, Planck_lensing, lowlike (the polarization data from WMAP). In each of the respective data files for these likelihood, please make sure that the line, for instance,

Planck_highl.path_clik = data.path['clik']+'../something.clik'

points to the correct clik file. Do not forget to source your Planck likelihood every time you want to use it:

$ source Your/Plc/bin/

You can put this line in your .bashrc file, and you should put it in your scripts for cluster computing.

Enjoying the difference

Now the code is installed. Go anywhere, and just call

$ python montepython/ --help
$ python montepython/ run --help
$ python montepython/ info --help

To see a list of all commands. For the run subcommand, there are two essential ones, without which the program will not start. At minimum, you should precise an output folder (-o) and a parameter file (-p). An example of parameter file is found in the main directory of MontePython (test.param, for instance).

A typical call would then be:

$ python montepython/ run -o test -p example.param

If non existent, the test/ folder will be created, and a run with the number of steps described in example.param will be started. To run a chain with more steps, one can type:

$ python montepython/ run -o test -p example.param -N 100

If you want to analyse the run, then just type

$ python montepython/ info test/

Note that you probably want more than a hundred points before analyzing a folder.

Details and Examples

Please refer to the pdf or online documentation for further details. The wiki contains additional details on installation. The forum also contains a collection of already answered questions, and can be used to discuss the code.

Bibtex entry

When using Monte Python in a publication, please acknowledge the code by citing the following paper. If you used Class, Nested Sampling or Cosmo Hammer, you should also cite the original works.

      author         = "Audren, Benjamin and Lesgourgues, Julien and Benabed,
                        Karim and Prunet, Simon",
      title          = "{Conservative Constraints on Early Cosmology: an
                        illustration of the Monte Python cosmological parameter
                        inference code}",
      journal        = "JCAP",
      volume         = "1302",
      pages          = "001",
      doi            = "10.1088/1475-7516/2013/02/001",
      year           = "2013",
      eprint         = "1210.7183",
      archivePrefix  = "arXiv",
      primaryClass   = "astro-ph.CO",
      reportNumber   = "CERN-PH-TH-2012-290, LAPTH-048-12",
      SLACcitation   = "%%CITATION = ARXIV:1210.7183;%%",