2 from numpy.testing
import assert_allclose, run_module_suite
5 from os.path
import dirname, join, abspath
8 DISTANCES_TOLERANCE = 1e-4
13 DISTANCES_TOLERANCE_MNU = 1e-3
16 DISTANCES_TOLERANCE_CLASS = 1e-5
28 Omega_v_vals = np.array([0.7, 0.7, 0.7, 0.65, 0.75])
29 w0_vals = np.array([-1.0, -0.9, -0.9, -0.9, -0.9])
30 wa_vals = np.array([0.0, 0.0, 0.1, 0.1, 0.1])
33 [0.04, 0., 0.], [0.05, 0.01, 0.], [0.03, 0.02, 0.04], [0.05, 0., 0.],
42 """Calculate N_eff from the number of relativistic and massive neutrinos.""" 43 Neff = N_ur + N_ncdm * ccl.ccllib.TNCDM**4 / (4./11.)**(4./3.)
47 "flat_nonu" : {
"Omega_k" : 0.0,
49 "pos_curv_nonu" : {
"Omega_k" : 0.01,
51 "neg_curv_nonu" : {
"Omega_k" : -0.01,
53 "flat_massnu1" : {
"Omega_k" : 0.0,
55 "m_nu" : [0.0, 0.0, 0.1]},
56 "flat_massnu2" : {
"Omega_k" : 0.0,
58 "m_nu" : [0.03, 0.03, 0.1]},
59 "flat_massnu3" : {
"Omega_k" : 0.0,
61 "m_nu" : [0.03, 0.05, 0.1]},
62 "flat_manynu1" : {
"Omega_k" : 0.0,
64 "neg_curv_massnu1" : {
"Omega_k" : -0.01,
66 "m_nu" : [0.0, 0.03, 0.1]},
67 "pos_curv_manynu1" : {
"Omega_k" : 0.01,
69 "m_nu" : [0.03, 0.05, 0.1]},
70 "CCL1" : {
"Omega_k" : 0.0,
72 "CCL2" : {
"Omega_k" : 0.0,
76 "CCL3" : {
"Omega_k" : 0.0,
80 "CCL4" : {
"Omega_k" : 0.05,
84 "CCL5" : {
"Omega_k" : -0.05,
88 "CCL7" : {
"Omega_k" : 0.0,
90 "m_nu" : [0.04, 0.0, 0.0]},
91 "CCL8" : {
"Omega_k" : 0.0,
95 "m_nu" : [0.05, 0.01, 0.0]},
96 "CCL9" : {
"Omega_k" : 0.0,
100 "m_nu" : [0.03, 0.02, 0.04]},
101 "CCL10" : {
"Omega_k" : 0.05,
105 "m_nu" : [0.05, 0.0, 0.0]},
106 "CCL11" : {
"Omega_k" : -0.05,
110 "m_nu" : [0.03, 0.02, 0.0]},
114 path = dirname(abspath(__file__))
117 Read the file containing all the radial comoving distance benchmarks 118 (distances are in Mpc/h) 121 dat = np.genfromtxt(join(path,
"benchmark/chi_model1-5.txt")).T
122 assert(dat.shape == (6,6))
131 Read the file containing all the radial comoving distance benchmarks 132 (distances are in Mpc/h) 135 dat = np.genfromtxt(join(path,
"benchmark/chi_hiz_model1-3.txt")).T
136 assert(dat.shape == (4,7))
145 Read the file containing all the radial comoving distance benchmarks 146 with non-zero massive neutrinos 147 (distances are in Mpc) 150 dat = np.genfromtxt(join(path,
"benchmark/chi_mnu_model1-5.txt")).T
151 assert(dat.shape == (6,5))
160 Read the file containing all the radial comoving distance benchmarks 161 (distances are in Mpc/h) 164 dat = np.genfromtxt(join(path,
"benchmark/chi_hiz_model1-3.txt")).T
165 assert(dat.shape == (4,7))
174 Read the file containing all the radial comoving distance benchmarks 175 with non-zero massive neutrinos 176 (distances are in Mpc) 179 dat = np.genfromtxt(join(path,
"benchmark/chi_hiz_mnu_model1-5.txt")).T
180 assert(dat.shape == (6,7))
189 Read the file containing the radial comoving distance benchmarks from 190 CLASS for the CCL paper models. (distances are in Mpc) 193 dat = np.genfromtxt(join(path,
"benchmark/chi_class_allz.txt")).T
194 assert(dat.shape == (11, 10))
203 Read the file containing the radial comoving distance benchmarks from 204 CLASS additional massive neutrino models. (distances are in Mpc) 207 dat = np.genfromtxt(join(path,
"benchmark/chi_class_extra_mnu.txt")).T
208 assert(dat.shape == (10, 10))
217 Read the file containing all the distance modulus benchmarks 220 dat = np.genfromtxt(join(path,
"benchmark/dm_model1-5.txt")).T
221 assert(dat.shape == (6,6))
230 Read the file containing all the distance modulus benchmarks 231 for non-zero massive neutrinos. 234 dat = np.genfromtxt(join(path,
"benchmark/dm_mnu_model1-5.txt")).T
235 assert(dat.shape == (6,5))
244 Read the file containing all the distance modulus benchmarks 245 for non-zero massive neutrinos at high z. 248 dat = np.genfromtxt(join(path,
"benchmark/dm_hiz_mnu_model1-5.txt")).T
249 assert(dat.shape == (6,7))
258 Read the file containing the distance modulus benchmarks from 259 CLASS for the CCL paper models. 262 dat = np.genfromtxt(join(path,
"benchmark/dm_class_allz.txt")).T
263 assert(dat.shape == (11, 10))
272 Read the file containing the distance modulus benchmarks from 273 CLASS for additional massive neutrino models. 276 dat = np.genfromtxt(join(path,
"benchmark/dm_class_extra_mnu.txt")).T
277 assert(dat.shape == (10, 10))
299 Compare distances calculated by pyccl with the distances in the benchmark 301 This test is only valid when radiation is explicitly set to 0. 304 Omega_k = 1.0 - Omega_c - Omega_b - Omega_v
306 cosmo = ccl.Cosmology(Omega_c=Omega_c, Omega_b=Omega_b, Neff = Neff,
307 h=h, A_s=A_s, n_s=n_s, Omega_k=Omega_k,
308 w0=w0, wa=wa, Omega_g=0)
312 chi = ccl.comoving_radial_distance(cosmo, a) * h
314 assert_allclose(chi, chi_bench, atol=1e-12, rtol=DISTANCES_TOLERANCE)
317 a_not_one = (a!=1).nonzero()
318 dm = ccl.distance_modulus(cosmo,a[a_not_one])
320 assert_allclose(dm, dm_bench[a_not_one], atol=1e-3, rtol = DISTANCES_TOLERANCE*10)
324 Compare distances calculated by pyccl with the distances in the benchmark 326 This test is only valid when radiation is explicitly set to 0. 329 Omega_k = 1.0 - Omega_c - Omega_b - Omega_v
331 cosmo = ccl.Cosmology(Omega_c=Omega_c, Omega_b=Omega_b, Neff=Neff,
332 h=h, A_s=A_s, n_s=n_s, Omega_k=Omega_k,
333 w0=w0, wa=wa, Omega_g=0)
337 chi = ccl.comoving_radial_distance(cosmo, a) * h
339 assert_allclose(chi, chi_bench, atol=1e-12, rtol=DISTANCES_TOLERANCE)
341 @numpy.testing.dec.slow
344 Compare distances calculated by pyccl with the distances in the benchmark 348 Omega_k = 1.0 - Omega_c - Omega_b - Omega_v
350 cosmo = ccl.Cosmology(Omega_c=Omega_c, Omega_b=Omega_b, Neff=Neff_mnu,
351 h=h, A_s=A_s, n_s=n_s, Omega_k=Omega_k,
352 w0=w0, wa=wa, m_nu=mnu)
356 chi = ccl.comoving_radial_distance(cosmo, a)
358 assert_allclose(chi, chi_bench, atol=1e-12, rtol=DISTANCES_TOLERANCE_MNU)
361 a_not_one = (a!=1).nonzero()
362 dm = ccl.distance_modulus(cosmo,a[a_not_one])
364 assert_allclose(dm, dm_bench[a_not_one], atol=1e-3, rtol = DISTANCES_TOLERANCE_MNU)
366 @numpy.testing.dec.slow
369 Compare distances calculated by pyccl with the distances in the benchmark 373 Omega_k = 1.0 - Omega_c - Omega_b - Omega_v
375 cosmo = ccl.Cosmology(Omega_c=Omega_c, Omega_b=Omega_b, Neff=Neff,
376 h=h, A_s=A_s, n_s=n_s, Omega_k=Omega_k,
377 w0=w0, wa=wa, m_nu=mnu)
381 chi = ccl.comoving_radial_distance(cosmo, a)
383 assert_allclose(chi, chi_bench, atol=1e-12, rtol=DISTANCES_TOLERANCE_MNU)
386 a_not_one = (a!=1).nonzero()
387 dm = ccl.distance_modulus(cosmo,a[a_not_one])
389 assert_allclose(dm, dm_bench[a_not_one], atol=1e-3, rtol = DISTANCES_TOLERANCE_MNU)
392 Omega_k=0.0, w0=-1.0, wa=0.0):
394 Compare distances calculated by pyccl with the distances in the CLASS 397 cosmo = ccl.Cosmology(Omega_c=Omega_c, Omega_b=Omega_b, Neff=Neff,
398 h=h, A_s=A_s, n_s=n_s, Omega_k=Omega_k, m_nu=m_nu,
403 chi = ccl.comoving_radial_distance(cosmo, a)
405 assert_allclose(chi, chi_bench, rtol=DISTANCES_TOLERANCE_CLASS)
409 dm = ccl.distance_modulus(cosmo, a[a_not_one])
410 assert_allclose(dm, dm_bench[a_not_one], rtol=DISTANCES_TOLERANCE_CLASS)
447 compare_distances_mnu(znu, chi_nu[i],dm_nu[i], Omega_v_vals[i], w0_vals[i], wa_vals[i], Neff, mnu[i])
451 compare_distances_mnu(znu, chi_nu[i],dm_nu[i], Omega_v_vals[i], w0_vals[i], wa_vals[i], Neff, mnu[i])
455 compare_distances_mnu(znu, chi_nu[i],dm_nu[i], Omega_v_vals[i], w0_vals[i], wa_vals[i], Neff, mnu[i])
459 compare_distances_mnu(znu, chi_nu[i],dm_nu[i], Omega_v_vals[i], w0_vals[i], wa_vals[i], Neff, mnu[i])
463 compare_distances_mnu(znu, chi_nu[i],dm_nu[i], Omega_v_vals[i], w0_vals[i], wa_vals[i], Neff, mnu[i])
467 compare_distances_mnu(znuhi, chi_nu_hiz[i],dm_nu_hiz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i], Neff, mnu[i])
471 compare_distances_mnu(znuhi, chi_nu_hiz[i],dm_nu_hiz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i], Neff, mnu[i])
475 compare_distances_mnu(znuhi, chi_nu_hiz[i],dm_nu_hiz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i], Neff, mnu[i])
479 compare_distances_mnu(znuhi, chi_nu_hiz[i],dm_nu_hiz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i], Neff, mnu[i])
483 compare_distances_mnu(znuhi, chi_nu_hiz[i],dm_nu_hiz[i], Omega_v_vals[i], w0_vals[i], wa_vals[i], Neff, mnu[i])
561 if __name__ ==
"__main__":
def test_class_allz_distance_model_ccl9()
def test_distance_mnu_hiz_model_0()
def test_class_distance_model_flat_massnu2()
def read_chi_benchmark_file()
def test_class_distance_model_flat_massnu1()
def compare_distances(z, chi_bench, dm_bench, Omega_v, w0, wa)
def test_distance_mnu_hiz_model_2()
def test_distance_model_4()
def compare_distances_mnu_hiz(z, chi_bench, dm_bench, Omega_v, w0, wa, Neff_mnu, mnu)
def test_distance_mnu_model_4()
def read_chi_hiz_benchmark_file()
def test_class_allz_distance_model_ccl7()
def read_dm_benchmark_file()
def test_distance_mnu_model_0()
def test_distance_mnu_model_1()
def compare_distances_hiz(z, chi_bench, Omega_v, w0, wa)
def test_class_allz_distance_model_ccl5()
def read_dm_mnu_hiz_benchmark_file()
def test_class_allz_distance_model_ccl10()
def read_class_allz_dm_benchmark_file()
def compare_distances_mnu(z, chi_bench, dm_bench, Omega_v, w0, wa, Neff, mnu)
def test_class_distance_model_neg_curv_nonu()
def test_class_distance_model_neg_curv_massnu1()
def test_class_distance_model_flat_nonu()
def test_class_distance_model_flat_manynu1()
def test_class_allz_distance_model_ccl1()
def test_distance_model_2()
def read_chi_mnu_hiz_benchmark_file()
def test_distance_model_3()
def test_class_distance_model_pos_curv_massnu1()
def read_class_mnu_dm_benchmark_file()
def Neff_from_N_ur_N_ncdm(N_ur, N_ncdm)
def test_distance_mnu_hiz_model_1()
def test_distance_mnu_hiz_model_4()
def test_class_allz_distance_model_ccl8()
def test_distance_hiz_model_2()
def test_distance_model_0()
def test_distance_hiz_model_1()
def compare_class_distances(z, chi_bench, dm_bench, Neff=3.0, m_nu=0.0, Omega_k=0.0, w0=-1.0, wa=0.0)
def test_class_allz_distance_model_ccl11()
def test_distance_mnu_model_2()
def test_class_allz_distance_model_ccl3()
def test_class_distance_model_pos_curv_nonu()
def read_chi_mnu_benchmark_file()
def test_distance_mnu_hiz_model_3()
def test_class_allz_distance_model_ccl2()
def test_distance_model_1()
def test_class_allz_distance_model_ccl4()
def read_class_mnu_chi_benchmark_file()
def read_class_allz_chi_benchmark_file()
def test_distance_mnu_model_3()
def read_dm_mnu_benchmark_file()
def test_distance_hiz_model_0()
def test_class_distance_model_flat_massnu3()