def test_bmin():
    # nonzero bmin
    ell, dell_tt, dell_te, dell_ee = get_example_spectra()
    like = pyactlike.ACTPowerSpectrumData(bmin=24)
    chi2 = -2 * like.loglike(dell_tt, dell_te, dell_ee, 1.003)
    print("ACTPol chi2 = " + "{0:.12f}".format(chi2))
    print("Expected:     235.146031846935")
    assert np.isclose(chi2, 235.146031846935)
def test_TTTEEE():
    """This function tests out the basic functionality of this likelihood code."""

    ell, dell_tt, dell_te, dell_ee = get_example_spectra()
    like = pyactlike.ACTPowerSpectrumData()
    chi2 = -2 * like.loglike(dell_tt, dell_te, dell_ee, 1.003)
    print("ACTPol chi2 = " + "{0:.12f}".format(chi2))
    print("Expected:     288.252869629064")
    assert np.isclose(chi2, 288.252869629064)
def get_example_spectra():
    like = pyactlike.ACTPowerSpectrumData()
    filename = like.data_dir + "bf_ACTPol_WMAP_lcdm.minimum.theory_cl"
    tt_lmax = 5000
    ell, dell_tt, dell_te, dell_ee = np.genfromtxt(
        filename,
        delimiter=None,
        unpack=True,
        max_rows=tt_lmax - 1,
        usecols=(0, 1, 2, 3),
    )
    return ell, dell_tt, dell_te, dell_ee
def test_single_channel():
    """This function tests out the single channels functionality of this likelihood code."""

    # TT only
    like = pyactlike.ACTPowerSpectrumData(use_tt=True,
                                          use_te=False,
                                          use_ee=False)
    ell, dell_tt, dell_te, dell_ee = get_example_spectra()
    chi2 = -2 * like.loglike(dell_tt, dell_te, dell_ee, 1.003)
    assert np.isclose(chi2, 97.4331220842641)

    # TE only
    like = pyactlike.ACTPowerSpectrumData(use_tt=False,
                                          use_te=True,
                                          use_ee=False)
    chi2 = -2 * like.loglike(dell_tt, dell_te, dell_ee, 1.003)
    assert np.isclose(chi2, 81.6194890026420)

    # EE only
    like = pyactlike.ACTPowerSpectrumData(use_tt=False,
                                          use_te=False,
                                          use_ee=True)
    chi2 = -2 * like.loglike(dell_tt, dell_te, dell_ee, 1.003)
    assert np.isclose(chi2, 98.5427508626497)
    def __init__(self, path, data, command_line):

        Likelihood.__init__(self, path, data, command_line)

        self.need_cosmo_arguments(
            data,
            {
                "lensing": "yes",
                "output": "tCl lCl pCl",
                "l_max_scalars": 6000,
                "modes": "s",
            },
        )

        self.need_update = True
        self.use_nuisance = ["yp2"]
        self.nuisance = ["yp2"]

        self.act = pyactlike.ACTPowerSpectrumData()

        # \ell values 2, 3, ... 6000
        self.xx = np.array(range(2, 6001))
Exemple #6
0
import pyactlike
import numpy as np

### Some important variables ###
use_tt = False
use_te = True
use_ee = False
tt_lmax = 5000
bmin = 0
like = pyactlike.ACTPowerSpectrumData(
    use_tt=use_tt,
    use_te=use_te,
    use_ee=use_ee,
    tt_lmax=tt_lmax,
    bmin=bmin,
)


### ACTPol lite DR4 likelihood
def get_loglike(class_input, likes_input, class_run):
    ell = class_run.lensed_cl()['ell'][2:]
    f = ell * (ell + 1.) / 2. / np.pi
    dell_tt = f * 0.
    dell_te = f * class_run.lensed_cl()['te'][2:] * 1e12 * class_run.T_cmb(
    )**2.
    dell_ee = f * 0.
    return like.loglike(dell_tt, dell_te, dell_ee, likes_input['yp2'])