Skip to content

MontePython Contour Plotting

nicholasdeporzio edited this page Oct 30, 2019 · 17 revisions

The home page for MontePython is (https://baudren.github.io/montepython.html). Guides for using MontePython are here and here and here.

Activate Virtual Environment

Consider executing the steps below within a virtual environment. Montepython only works with python2. See the Virtual Environments page of this wiki.

Install Prerequisite Packages

Montepython requires numpy, scipy, and cython to be installed in your environment:

$ pip install numpy
$ pip install scipy
$ pip install cython
$ pip install matplotlib

Install CLASS with Python Wrapper

See the Installing Class page of this wiki.

Install MontePython

Only version 3.0.0 of MontePython has worked reliably. Install that version (which is not the most recent) like so:

$ git clone --branch 3.0.0 git@github.com:brinckmann/montepython_public.git
$ cd montepython_public
$ python setup.py install

Uninstall pymultinest

For whatever reason, you must uninstall pymultinest for Montepython to work correctly. Sure.

$ pip uninstall pymultinest

Plotting Chains

First, note that MontePython only seems to work properly using Python2. Put MCMC chains generated with MontePython in the folder /chains. Then:

$ montepython_public-3.0/montepython/MontePython.py info chains/

Plotting Contours on Chains

Contours from a Fisher matrix can be plotted on top of chains. First, create a file with the name inv_fisher.mat and place it in the same folder as your chains /chains. inv_fisher.mat should contain the inverse of the Fisher matrix you wish to plot contours for. The format of the file should be a single header line, beginning with # and then a space, , and then the name of each parameter as specified in the log.param file separated by a tab. Below this line should be the inverse of the fisher matrix in a tab separated format. Then, to plot the contours:

$ montepython_public-3.0/montepython/MontePython.py info chains/ --plot-fisher --center-fisher

The --center-fisher flag will center the ellipses on the maximum likelihood point of the underlying chains. Otherwise, MontePython will center the ellipses at the fiducial values specified in the log.param file.

MC Chains on Odyssey

/n/dvorkin_lab/Light-Relics/Montepython_JBM/montepython_public-3.0/chains_no_relicfast/CMBS4_desi_DH_small_step/