Skip to content

Commit eaf1757

Browse files
committed
cosmo: reworked some planck tests
1 parent 6156b63 commit eaf1757

File tree

4 files changed

+155
-107
lines changed

4 files changed

+155
-107
lines changed

docs/src_examples/cosmo_basic/basic_classy.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ theory:
22
classy:
33
extra_args:
44
non linear: hmcode
5-
nonlinear_min_k_max: 20
65
N_ncdm: 1
76
N_ur: 2.0328
87
likelihood:

tests/common_cosmo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def body_of_test(
8787
if best_fit_derived[p][0] is None or p not in best_fit_derived:
8888
not_tested += [p]
8989
continue
90+
assert best_fit_derived[p][1] > 0, f"Derived parameter {p} error must be >0."
9091
rel = abs(derived[p] - best_fit_derived[p][0]) / best_fit_derived[p][1]
9192
if rel > tolerance_derived * (
9293
2 if p in ("YHe", "Y_p", "DH", "sigma8", "s8omegamp5", "thetastar") else 1

tests/test_cosmo_planck_2018.py

Lines changed: 65 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
"want_lcmb_full_limber": "no", # When it's on, it changes by chi2 ~ 0.5
4545
})
4646

47+
info_theory_camb = {"camb": {"extra_args": planck_2018_precision["camb"]}}
48+
info_theory_classy = {"classy": {"extra_args": planck_2018_precision["classy"]}}
49+
4750
# Small chi2 difference with CLASS (total still <0.35)
4851
classy_extra_tolerance = 0.25
4952

@@ -61,13 +64,12 @@ def test_planck_2018_t_camb(packages_path, skip_not_installed, clik=False):
6164
"planck_2018_lowl.TT"
6265
)
6366
chi2["planck_2018_lowl.TT_clik"] = chi2.pop("planck_2018_lowl.TT")
64-
info_theory = {"camb": {"extra_args": planck_2018_precision["camb"]}}
6567
best_fit_derived = derived_lowl_highTT_lensing
6668
body_of_test(
6769
packages_path,
6870
best_fit,
6971
info_likelihood,
70-
info_theory,
72+
info_theory_camb,
7173
chi2,
7274
best_fit_derived,
7375
skip_not_installed=skip_not_installed,
@@ -88,13 +90,12 @@ def test_planck_2018_p_camb(packages_path, skip_not_installed, clik=False):
8890
"planck_2018_lowl.EE"
8991
)
9092
chi2["planck_2018_lowl.EE_clik"] = chi2.pop("planck_2018_lowl.EE")
91-
info_theory = {"camb": {"extra_args": planck_2018_precision["camb"]}}
9293
best_fit_derived = derived_lowTE_highTTTEEE_lensingcmblikes
9394
body_of_test(
9495
packages_path,
9596
best_fit,
9697
info_likelihood,
97-
info_theory,
98+
info_theory_camb,
9899
chi2,
99100
best_fit_derived,
100101
skip_not_installed=skip_not_installed,
@@ -113,13 +114,12 @@ def test_planck_2018_t_lite_camb(packages_path, skip_not_installed, native=False
113114
best_fit.pop("H0")
114115
like_name = "planck_2018_highl_plik.TT_lite" + ("_native" if native else "")
115116
info_likelihood = {like_name: None}
116-
info_theory = {"camb": {"extra_args": planck_2018_precision["camb"]}}
117117
chi2 = {like_name: chi2_planck_2018_plikHM_highTT_lite, "tolerance": 0.01}
118118
body_of_test(
119119
packages_path,
120120
best_fit,
121121
info_likelihood,
122-
info_theory,
122+
info_theory_camb,
123123
chi2,
124124
skip_not_installed=skip_not_installed,
125125
)
@@ -136,13 +136,12 @@ def test_planck_2018_p_lite_camb(packages_path, skip_not_installed, native=False
136136
best_fit.pop("H0")
137137
like_name = "planck_2018_highl_plik.TTTEEE_lite" + ("_native" if native else "")
138138
info_likelihood = {like_name: None}
139-
info_theory = {"camb": {"extra_args": planck_2018_precision["camb"]}}
140139
chi2 = {like_name: chi2_planck_2018_plikHM_highTTTEEE_lite, "tolerance": 0.01}
141140
body_of_test(
142141
packages_path,
143142
best_fit,
144143
info_likelihood,
145-
info_theory,
144+
info_theory_camb,
146145
chi2,
147146
skip_not_installed=skip_not_installed,
148147
)
@@ -162,13 +161,12 @@ def test_planck_2018_t_unbinned_camb(packages_path, skip_not_installed):
162161
best_fit.pop("H0")
163162
like_name = "planck_2018_highl_plik.TT_unbinned"
164163
info_likelihood = {like_name: None}
165-
info_theory = {"camb": {"extra_args": planck_2018_precision["camb"]}}
166164
chi2 = {like_name: 8275.99, "tolerance": 0.03}
167165
body_of_test(
168166
packages_path,
169167
best_fit,
170168
info_likelihood,
171-
info_theory,
169+
info_theory_camb,
172170
chi2,
173171
skip_not_installed=skip_not_installed,
174172
)
@@ -179,13 +177,12 @@ def test_planck_2018_p_unbinned_camb(packages_path, skip_not_installed):
179177
best_fit.pop("H0")
180178
like_name = "planck_2018_highl_plik.TTTEEE_unbinned"
181179
info_likelihood = {like_name: None}
182-
info_theory = {"camb": {"extra_args": planck_2018_precision["camb"]}}
183180
chi2 = {like_name: 24125.92, "tolerance": 0.01}
184181
body_of_test(
185182
packages_path,
186183
best_fit,
187184
info_likelihood,
188-
info_theory,
185+
info_theory_camb,
189186
chi2,
190187
skip_not_installed=skip_not_installed,
191188
)
@@ -195,40 +192,29 @@ def test_planck_2018_p_unbinned_camb(packages_path, skip_not_installed):
195192

196193

197194
def test_planck_2018_t_CamSpec_camb(packages_path, skip_not_installed):
198-
name = "planck_2018_highl_CamSpec.TT"
199-
info_likelihood = {name: None}
200-
chi2 = {name: 7060.04, "tolerance": 0.2}
201-
best_fit = params_lowTE_highTTTEEE_lite_lensingcmblikes.copy()
202-
best_fit.update(
203-
{
204-
"aps100": 238.7887,
205-
"aps143": 41.31762,
206-
"aps217": 100.6226,
207-
"acib217": 44.96003,
208-
"asz143": 5.886124,
209-
"psr": 0.5820399,
210-
"cibr": 0.7912195,
211-
"ncib": 0.0,
212-
"cibrun": 0.0,
213-
"xi": 0.1248677,
214-
"aksz": 1.153473,
215-
"dust100": 1.010905,
216-
"dust143": 0.9905765,
217-
"dust217": 0.9658913,
218-
"dust143x217": 0.9946434,
219-
"cal0": 0.9975484,
220-
"cal2": 1.00139,
221-
"calTE": 1.0,
222-
"calEE": 1.0,
223-
}
195+
best_fit = deepcopy(params_t_CamSpec)
196+
best_fit.pop("H0")
197+
body_of_test(
198+
packages_path,
199+
best_fit,
200+
lik_info_t_CamSpec,
201+
info_theory_camb,
202+
chi2_t_CamSpec,
203+
skip_not_installed=skip_not_installed,
224204
)
225-
info_theory = {"camb": {"extra_args": planck_2018_precision["camb"]}}
205+
206+
def test_planck_2018_t_CamSpec_classy(packages_path, skip_not_installed):
207+
best_fit = deepcopy(params_t_CamSpec)
208+
best_fit.pop("theta_MC_100")
209+
chi2_t_CamSpec_classy = deepcopy(chi2_t_CamSpec)
210+
# TODO: find out the reason for the increased tolerance (plik case agrees very well)
211+
chi2_t_CamSpec_classy["tolerance"] += 1.30
226212
body_of_test(
227213
packages_path,
228214
best_fit,
229-
info_likelihood,
230-
info_theory,
231-
chi2,
215+
lik_info_t_CamSpec,
216+
info_theory_classy,
217+
chi2_t_CamSpec_classy,
232218
skip_not_installed=skip_not_installed,
233219
)
234220

@@ -249,12 +235,11 @@ def test_planck_2018_t_CamSpec2021_camb(packages_path, skip_not_installed):
249235
"n_143x217": 0.96638,
250236
}
251237
)
252-
info_theory = {"camb": {"extra_args": planck_2018_precision["camb"]}}
253238
body_of_test(
254239
packages_path,
255240
best_fit,
256241
info_likelihood,
257-
info_theory,
242+
info_theory_camb,
258243
chi2,
259244
skip_not_installed=skip_not_installed,
260245
)
@@ -288,12 +273,11 @@ def test_planck_2018_p_CamSpec_camb(packages_path, skip_not_installed):
288273
"calEE": 1.0,
289274
}
290275
)
291-
info_theory = {"camb": {"extra_args": planck_2018_precision["camb"]}}
292276
body_of_test(
293277
packages_path,
294278
best_fit,
295279
info_likelihood,
296-
info_theory,
280+
info_theory_camb,
297281
chi2,
298282
skip_not_installed=skip_not_installed,
299283
)
@@ -317,12 +301,11 @@ def test_planck_2018_p_CamSpec2021_camb(packages_path, skip_not_installed):
317301
"calEE": 1.00124,
318302
}
319303
)
320-
info_theory = {"camb": {"extra_args": planck_2018_precision["camb"]}}
321304
body_of_test(
322305
packages_path,
323306
best_fit,
324307
info_likelihood,
325-
info_theory,
308+
info_theory_camb,
326309
chi2,
327310
skip_not_installed=skip_not_installed,
328311
)
@@ -334,13 +317,12 @@ def test_planck_2018_p_CamSpec2021_camb(packages_path, skip_not_installed):
334317
def test_planck_2018_lcmbmarged_camb(packages_path, skip_not_installed):
335318
best_fit = params_lensing_cmbmarged
336319
info_likelihood = lik_info_lensing_cmbmarged.copy()
337-
info_theory = {"camb": {"extra_args": planck_2018_precision["camb"]}}
338320
best_fit_derived = {}
339321
body_of_test(
340322
packages_path,
341323
best_fit,
342324
info_likelihood,
343-
info_theory,
325+
info_theory_camb,
344326
chi2_lensing_cmbmarged,
345327
best_fit_derived,
346328
skip_not_installed=skip_not_installed,
@@ -355,7 +337,6 @@ def test_planck_2018_t_classy(packages_path, skip_not_installed):
355337
best_fit.pop("theta_MC_100")
356338
best_fit = params_lowl_highTT_lensing
357339
info_likelihood = lik_info_lowl_highTT_lensing.copy()
358-
info_theory = {"classy": {"extra_args": planck_2018_precision["classy"]}}
359340
best_fit_derived = deepcopy(derived_lowl_highTT_lensing)
360341
for p in classy_unknown:
361342
best_fit_derived.pop(p, None)
@@ -365,7 +346,7 @@ def test_planck_2018_t_classy(packages_path, skip_not_installed):
365346
packages_path,
366347
best_fit,
367348
info_likelihood,
368-
info_theory,
349+
info_theory_classy,
369350
chi2_lowl_highTT_classy,
370351
best_fit_derived,
371352
skip_not_installed=skip_not_installed,
@@ -376,7 +357,6 @@ def test_planck_2018_p_classy(packages_path, skip_not_installed):
376357
best_fit = deepcopy(params_lowTE_highTTTEEE_lensingcmblikes)
377358
best_fit.pop("theta_MC_100")
378359
info_likelihood = lik_info_lowTE_highTTTEEE_lensingcmblikes.copy()
379-
info_theory = {"classy": {"extra_args": planck_2018_precision["classy"]}}
380360
best_fit_derived = deepcopy(derived_lowTE_highTTTEEE_lensingcmblikes)
381361
for p in classy_unknown:
382362
best_fit_derived.pop(p, None)
@@ -386,7 +366,7 @@ def test_planck_2018_p_classy(packages_path, skip_not_installed):
386366
packages_path,
387367
best_fit,
388368
info_likelihood,
389-
info_theory,
369+
info_theory_classy,
390370
chi2_lowl_highTT_classy,
391371
best_fit_derived,
392372
skip_not_installed=skip_not_installed,
@@ -569,3 +549,34 @@ def test_planck_2018_p_classy(packages_path, skip_not_installed):
569549
"logA": 3.2528000e00,
570550
"ns": 9.6135180e-01,
571551
}
552+
553+
# Best fit CamSpec ############################################################
554+
555+
lik_info_t_CamSpec = {"planck_2018_highl_CamSpec.TT": None}
556+
557+
chi2_t_CamSpec = {"planck_2018_highl_CamSpec.TT": 7058.63, "tolerance": 0.2}
558+
559+
# Same point as the corresponding plik one
560+
params_t_CamSpec = params_lowl_highTT_lite_lensing.copy()
561+
562+
params_t_CamSpec.update({
563+
"aps100": 238.7887,
564+
"aps143": 41.31762,
565+
"aps217": 100.6226,
566+
"acib217": 44.96003,
567+
"asz143": 5.886124,
568+
"psr": 0.5820399,
569+
"cibr": 0.7912195,
570+
"ncib": 0.0,
571+
"cibrun": 0.0,
572+
"xi": 0.1248677,
573+
"aksz": 1.153473,
574+
"dust100": 1.010905,
575+
"dust143": 0.9905765,
576+
"dust217": 0.9658913,
577+
"dust143x217": 0.9946434,
578+
"cal0": 0.9975484,
579+
"cal2": 1.00139,
580+
"calTE": 1.0,
581+
"calEE": 1.0,
582+
})

0 commit comments

Comments
 (0)