ACTCollaboration / actpols2_like_py

ACTPol S2 Likelihood written in Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is a Python port of software used by the ACTPol collaboration to compute the likelihood of cosmological models, using the small-scale CMB power spectrum from 350 < l <4000 measured by ACTPol, derived from the 2 seasons of polarization data. This spectrum has already been marginalized over SZ and foreground emission, and an overall calibration error is propagated to the covariance matrix in the likelihood code. The polarization efficiency is the only nuisance parameter required to be sampled. It is based on the WMAP and ACT team's likelihood software.

Usage

General Use

Put the repository's code in the directory of your Python scripts, and then import it.

import act_like

You then create an instance of the Python class, making sure to specify the directory of the ACTPol data. This is the data folder in this repository!

data_dir = '/Users/zequnl/Projects/actpols2_like_py/data/'
act = act_like.ACTPol_s2(data_dir)

With some Cls in lists (default is l=2 to l=6000) and some value of the nuisance parameter yp (use a prior of 0.9 to 1.0 for yp), you just call the likelihood function. Important: I follow the convention of working with CMB spectra in the (l(l+1)/2pi) C_l form, and that's what this likelihood takes as input.

like = act.loglike(cell_tt, cell_te, cell_ee, yp)

You can make sure the likelihood code is doing things properly by running the included test function.

act.test()

For a working example, see the heavily-commented example_planck.py.

Monte Python

Please refer to the Wiki.

Requirements

You'll need a relatively modern installation of numpy and scipy, since this code uses a lot of array manipulation and Cholesky decomposition to take an inverse.

Performance

I did some very basic tests for computation time, by calling CLASS (through its Python wrapper), the Fortran likelihood, and this Python likelihood. I ran this on my MacBook with 10,000 calls each (maybe not the most scientific way to do this).

CLASS: 29.8s

Python Likelihood: 25.7s
Fortran Likelihood: 9.7s

The pure Fortran is about 3x faster, but since CLASS dominates the computation time, the total impact on computation time is probably an additional 30-40% if you use this code instead of the Fortran.

Citation

Please reference Louis et al. 2016 if you use this code.

The original Fortran code was written by E. Calabrese and J. Dunkley.

About

ACTPol S2 Likelihood written in Python.


Languages

Language:Python 100.0%