Example #1
0
def check_neutrinos():
    """
    Check that neutrino-related functions can be run.
    """
    z = 0.
    z_arr = np.linspace(0., 2., 10)
    a = 1.
    a_arr = 1. / (1. + z_arr)
    a_lst = [_a for _a in a_arr]

    T_CMB = 2.725
    N_nu_mass = 3
    mnu = [0.02, 0.02, 0.02]

    # Omeganuh2
    assert_(all_finite(ccl.Omeganuh2(a, mnu, T_CMB)))
    assert_(all_finite(ccl.Omeganuh2(a_lst, mnu, T_CMB)))
    assert_(all_finite(ccl.Omeganuh2(a_arr, mnu, T_CMB)))

    OmNuh2 = 0.01

    # Omeganuh2_to_Mnu
    assert_(all_finite(ccl.nu_masses(OmNuh2, 'normal', T_CMB)))
    assert_(all_finite(ccl.nu_masses(OmNuh2, 'inverted', T_CMB)))
    assert_(all_finite(ccl.nu_masses(OmNuh2, 'equal', T_CMB)))
    assert_(all_finite(ccl.nu_masses(OmNuh2, 'sum', T_CMB)))

    # Check that the right exceptions are raised
    assert_raises(ValueError,
                  ccl.Cosmology,
                  Omega_c=0.27,
                  Omega_b=0.045,
                  h=0.67,
                  A_s=1e-10,
                  n_s=0.96,
                  m_nu=[0.1, 0.2, 0.3, 0.4])
    assert_raises(ValueError,
                  ccl.Cosmology,
                  Omega_c=0.27,
                  Omega_b=0.045,
                  h=0.67,
                  A_s=1e-10,
                  n_s=0.96,
                  m_nu=[0.1, 0.2, 0.3],
                  mnu_type="sum")
    assert_raises(ValueError,
                  ccl.Cosmology,
                  Omega_c=0.27,
                  Omega_b=0.045,
                  h=0.67,
                  A_s=1e-10,
                  n_s=0.96,
                  m_nu=42)
Example #2
0
def test_omnuh2_smoke(a, m):
    om = ccl.Omeganuh2(a, m)
    assert np.all(np.isfinite(om))
    assert np.shape(om) == np.shape(a)
Example #3
0
def test_nu_mass_consistency(a, split):
    m = ccl.nu_masses(0.1, split)
    assert np.allclose(ccl.Omeganuh2(a, m), 0.1, rtol=0, atol=1e-4)