def test_eisenstein_hu(): # We first define equivalent CCL and jax_cosmo cosmologies cosmo_ccl = ccl.Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Neff=0, transfer_function="eisenstein_hu", matter_power_spectrum="linear", ) cosmo_jax = Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Omega_k=0.0, w0=-1.0, wa=0.0, ) # Test array of scales k = np.logspace(-4, 2, 512) # Computing matter power spectrum pk_ccl = ccl.linear_matter_power(cosmo_ccl, k, 1.0) pk_jax = (power.linear_matter_power(cosmo_jax, k / cosmo_jax.h, a=1.0) / cosmo_jax.h**3) assert_allclose(pk_ccl, pk_jax, rtol=0.5e-2)
def test_growth_rate(): # We first define equivalent CCL and jax_cosmo cosmologies cosmo_ccl = ccl.Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Neff=0, transfer_function="eisenstein_hu", matter_power_spectrum="linear", ) cosmo_jax = Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Omega_k=0.0, w0=-1.0, wa=0.0, ) # Test array of scale factors a = np.linspace(0.01, 1.0) fccl = ccl.growth_rate(cosmo_ccl, a) fjax = bkgrd.growth_rate(cosmo_jax, a) assert_allclose(fccl, fjax, rtol=1e-2)
def test_growth_rate_gamma(): # We test consistency of both effective growth # parametrisation for LCDM cosmo_ccl = ccl.Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Neff=0, transfer_function="eisenstein_hu", matter_power_spectrum="linear", ) cosmo_jax = Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Omega_k=0.0, w0=-1.0, wa=0.0, gamma=0.55, ) # Test array of scale factors a = np.linspace(0.01, 1.0) fccl = ccl.growth_rate(cosmo_ccl, a) fjax = bkgrd.growth_rate(cosmo_jax, a) assert_allclose(fccl, fjax, rtol=1e-2)
def test_growth(): # We first define equivalent CCL and jax_cosmo cosmologies cosmo_ccl = ccl.Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8 = 0.8, n_s=0.96, Neff=0, transfer_function='eisenstein_hu', matter_power_spectrum='linear') cosmo_jax = Cosmology(Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8 = 0.8, n_s=0.96, Omega_k=0., w0=-1., wa=0.) # Test array of scale factors a = np.linspace(0.1, 1.) gccl = ccl.growth_factor(cosmo_ccl, a) gjax = bkgrd.growth_factor(cosmo_jax, a) assert_allclose(gccl, gjax, rtol=1e-3)
def test_clustering_cl(): # We first define equivalent CCL and jax_cosmo cosmologies cosmo_ccl = ccl.Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Neff=0, transfer_function="eisenstein_hu", matter_power_spectrum="halofit", ) cosmo_jax = Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Omega_k=0.0, w0=-1.0, wa=0.0, ) # Define a redshift distribution nz = smail_nz(1.0, 2.0, 1.0) # And a bias model bias = constant_linear_bias(1.0) z = np.linspace(0, 5.0, 1024) tracer_ccl = ccl.NumberCountsTracer(cosmo_ccl, has_rsd=False, dndz=(z, nz(z)), bias=(z, bias(cosmo_jax, z))) tracer_jax = probes.NumberCounts([nz], bias) # Get an ell range for the cls ell = np.logspace(0.1, 4) # Compute the cls cl_ccl = ccl.angular_cl(cosmo_ccl, tracer_ccl, tracer_ccl, ell) cl_jax = angular_cl(cosmo_jax, ell, [tracer_jax]) assert_allclose(cl_ccl, cl_jax[0], rtol=0.5e-2)
def test_lensing_cl_IA(): # We first define equivalent CCL and jax_cosmo cosmologies cosmo_ccl = ccl.Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Neff=0, transfer_function="eisenstein_hu", matter_power_spectrum="halofit", ) cosmo_jax = Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Omega_k=0.0, w0=-1.0, wa=0.0, ) # Define a redshift distribution nz = smail_nz(1.0, 2.0, 1.0) z = np.linspace(0, 5.0, 1024) # Pretty big IA to highlight potential differences stemming from IA # implementation bias = inverse_growth_linear_bias(10.0) tracer_ccl = ccl.WeakLensingTracer(cosmo_ccl, (z, nz(z)), ia_bias=(z, bias(cosmo_jax, z))) tracer_jax = probes.WeakLensing([nz], bias) # Get an ell range for the cls ell = np.logspace(0.1, 4) # Compute the cls cl_ccl = ccl.angular_cl(cosmo_ccl, tracer_ccl, tracer_ccl, ell) cl_jax = angular_cl(cosmo_jax, ell, [tracer_jax]) assert_allclose(cl_ccl, cl_jax[0], rtol=1e-2)
def test_distances_flat(): # We first define equivalent CCL and jax_cosmo cosmologies cosmo_ccl = ccl.Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Neff=0, transfer_function="eisenstein_hu", matter_power_spectrum="linear", ) cosmo_jax = Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Omega_k=0.0, w0=-1.0, wa=0.0, ) # Test array of scale factors a = np.linspace(0.01, 1.0) chi_ccl = ccl.comoving_radial_distance(cosmo_ccl, a) chi_jax = bkgrd.radial_comoving_distance(cosmo_jax, a) / cosmo_jax.h assert_allclose(chi_ccl, chi_jax, rtol=0.5e-2) chi_ccl = ccl.comoving_angular_distance(cosmo_ccl, a) chi_jax = bkgrd.transverse_comoving_distance(cosmo_jax, a) / cosmo_jax.h assert_allclose(chi_ccl, chi_jax, rtol=0.5e-2) chi_ccl = ccl.angular_diameter_distance(cosmo_ccl, a) chi_jax = bkgrd.angular_diameter_distance(cosmo_jax, a) / cosmo_jax.h assert_allclose(chi_ccl, chi_jax, rtol=0.5e-2)
def test_lensing_cl(): # We first define equivalent CCL and jax_cosmo cosmologies cosmo_ccl = ccl.Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Neff=0, transfer_function="eisenstein_hu", matter_power_spectrum="halofit", ) cosmo_jax = Cosmology( Omega_c=0.3, Omega_b=0.05, h=0.7, sigma8=0.8, n_s=0.96, Omega_k=0.0, w0=-1.0, wa=0.0, ) # Define a redshift distribution nz = smail_nz(1.0, 2.0, 1.0) z = np.linspace(0, 5.0, 1024) tracer_ccl = ccl.WeakLensingTracer(cosmo_ccl, (z, nz(z)), use_A_ia=False) tracer_jax = probes.WeakLensing([nz]) # Get an ell range for the cls ell = np.logspace(0.1, 4) # Compute the cls cl_ccl = ccl.angular_cl(cosmo_ccl, tracer_ccl, tracer_ccl, ell) cl_jax = angular_cl(cosmo_jax, ell, [tracer_jax]) assert_allclose(cl_ccl, cl_jax[0], rtol=0.5e-2)