Skip to content

Commit

Permalink
make test use lensed Cls instead of unlensed ; update test values to …
Browse files Browse the repository at this point in the history
…reflect norm correction fix
  • Loading branch information
msyriac committed Feb 5, 2024
1 parent c8a855f commit b9adee7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 35 deletions.
27 changes: 15 additions & 12 deletions act_dr6_lenslike/tests/test_act.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
import unittest
import act_dr6_lenslike as alike
import numpy as np
data_dir = alike.data_dir
import os
file_dir = os.path.abspath(os.path.dirname(__file__))
version = alike.default_version
data_dir = f"{file_dir}/../data/{version}/"



class ACTLikeTest(unittest.TestCase):

def generic_call(self,variant,lens_only,exp_chisq=None,return_theory=False):
data_file = data_dir+'like_corrs/cosmo2017_10K_acc3_lenspotentialCls.dat'
try:
ell, cl_tt, cl_ee, cl_bb, cl_te, cl_pp, cl_tp, cl_ep= np.loadtxt(data_file, unpack=True)
ell, cl_tt, cl_ee, cl_bb, cl_te = np.loadtxt(data_dir+'like_corrs/cosmo2017_10K_acc3_lensedCls.dat', unpack=True)
ellp, _, _, _, _, cl_pp, _, _= np.loadtxt(data_dir+'like_corrs/cosmo2017_10K_acc3_lenspotentialCls.dat', unpack=True)
except OSError:
raise
finally:
print('Required data file not found at {}'.format(data_file))
print('Please obtain it and place it correctly.')
print('The script get-act-data.sh will download and place it.')
raise

prefac = 2*np.pi/ell/(ell+1.)
cl_kk=cl_pp/4*2*np.pi
cl_bb = cl_bb*prefac
cl_tt = cl_tt*prefac
cl_ee = cl_ee*prefac
cl_te = cl_te*prefac
data_dict = alike.load_data(variant,lens_only=lens_only,like_corrections=not(lens_only))
ell_kk = ell
data_dict = alike.load_data(variant,lens_only=lens_only,like_corrections=not(lens_only),version=version)
ell_kk = ellp
ell_cmb=ell

if return_theory:
Expand All @@ -37,21 +40,21 @@ def generic_call(self,variant,lens_only,exp_chisq=None,return_theory=False):
def test_act_baseline_lensonly(self):
self.generic_call('act_baseline',True,14.06)
def test_act_baseline(self):
self.generic_call('act_baseline',False,14.71)
self.generic_call('act_baseline',False,14.13)
def test_act_baseline_return_theory(self):
self.generic_call('act_baseline',False,14.71,return_theory=True)
self.generic_call('act_baseline',False,14.13,return_theory=True)
def test_actplanck_baseline_lensonly(self):
self.generic_call('actplanck_baseline',True,21.07)
def test_actplanck_baseline(self):
self.generic_call('actplanck_baseline',False,21.97)
self.generic_call('actplanck_baseline',False,21.46)
def test_act_extended_lensonly(self):
self.generic_call('act_extended',True,17.66)
def test_act_extended(self):
self.generic_call('act_extended',False,17.26)
self.generic_call('act_extended',False,17.72)
def test_actplanck_extended_lensonly(self):
self.generic_call('actplanck_extended',True,24.4)
def test_actplanck_extended(self):
self.generic_call('actplanck_extended',False,24.26)
self.generic_call('actplanck_extended',False,24.75)
def test_act_polonly_lensonly(self):
self.generic_call('act_polonly',True,309.71)
def test_act_cibdeproj_lensonly(self):
Expand Down
31 changes: 8 additions & 23 deletions act_dr6_lenslike/tests/test_cobaya.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
'omnuh2': 0.00064,
},
"theory" : {
"camb" : { 'extra_args' : {
"camb" : {
'ignore_obsolete': True,
'extra_args' : {
'lmax' : 10000,
'lens_margin' : 1250,
'lens_potential_accuracy' : 4,
Expand All @@ -31,16 +33,6 @@


class ACTLikeTest(unittest.TestCase):
# Note that tests marked: 'fail on new camb' have had the chi2 revised
# from the original number which was with respect to a simulated spectrum
# from this analysis: https://mapsims.readthedocs.io/en/latest/camb.html
# This spectrum is included as like_corrs/cosmo2017_10K_acc3_lenspotentialCls.dat
# and is used for the tests for the base python likelihood.
# If anyone can reproduce these numbers with settings for a modern camb,
# please get in touch!
# We do not believe this affects the validity of the results, as the chi2
# differences are small, and the previously compared spectrum was somewhat
# arbitray.

def initialize(self):
install({"likelihood": {"act_dr6_lenslike.ACTDR6LensLike": None}})
Expand All @@ -59,41 +51,34 @@ def generic_call(self,variant,lens_only,exp_chisq=None):
self.assertAlmostEqual(chisq, exp_chisq, 1)

def test_act_baseline_lensonly(self):
self.generic_call('act_baseline',True,14.06)
self.generic_call('act_baseline',True,14.00)

def test_act_baseline(self):
# self.generic_call('act_baseline',False,14.71) # fail on new camb
self.generic_call('act_baseline',False,14.07)
self.generic_call('act_baseline',False,14.00)

def test_actplanck_baseline_lensonly(self):
# self.generic_call('actplanck_baseline',True,21.07) # fail on new camb
self.generic_call('actplanck_baseline',True,20.97)

def test_actplanck_baseline(self):
# self.generic_call('actplanck_baseline',False,21.97) # fail on new camb
self.generic_call('actplanck_baseline',False,21.36)
self.generic_call('actplanck_baseline',False,21.20)

def test_act_extended_lensonly(self):
# self.generic_call('act_extended',True,17.66) # fail on new camb
self.generic_call('act_extended',True,17.84)

def test_act_extended(self):
# self.generic_call('act_extended',False,17.26) # fail on new camb
self.generic_call('act_extended',False,17.94)

def test_actplanck_extended_lensonly(self):
# self.generic_call('actplanck_extended',True,24.4) # fail on new camb
self.generic_call('actplanck_extended',True,24.52)

def test_actplanck_extended(self):
# self.generic_call('actplanck_extended',False,24.26) # fail on new camb
self.generic_call('actplanck_extended',False,24.91)
self.generic_call('actplanck_extended',False,24.77)

def test_act_polonly_lensonly(self):
self.generic_call('act_polonly',True,309.71)

def test_act_cibdeproj_lensonly(self):
self.generic_call('act_cibdeproj',True,15.16)
self.generic_call('act_cibdeproj',True,15.10)

def test_act_cinpaint_lensonly(self):
self.generic_call('act_cinpaint',True,15.94)
Expand Down

0 comments on commit b9adee7

Please sign in to comment.