def test_camb_extrapolation(): t = Transfer(transfer_params={"extrapolate_with_eh": True}, transfer_model="CAMB") k = np.logspace(1.5, 2, 20) eh = t.transfer._eh.lnt(np.log(k)) camb = t.transfer.lnt(np.log(k)) eh += eh[0] - camb[0] assert np.isclose(eh[-1], camb[-1], rtol=1e-1)
def test_setting_kmax(): t = Transfer( transfer_params={ "extrapolate_with_eh": True, "kmax": 1.0 }, transfer_model="CAMB", ) assert t.transfer.params["camb_params"].Transfer.kmax == 1.0 camb_transfers = camb.get_transfer_functions( t.transfer.params["camb_params"]) T = camb_transfers.get_matter_transfer_data().transfer_data assert np.max(T[0]) < 2.0
def test_data(datadir): import camb from astropy.cosmology import LambdaCDM cp = camb.CAMBparams() cp.set_matter_power(kmax=100.0) t = Transfer( cosmo_model=LambdaCDM(Om0=0.3, Ode0=0.7, H0=70.0, Ob0=0.05), sigma_8=0.8, n=1, transfer_params={"camb_params": cp}, lnk_min=np.log(1e-11), lnk_max=np.log(1e11), ) pdata = np.genfromtxt(datadir / "power_for_hmf_tests.dat") assert np.sqrt(np.mean(np.square(t.power - pdata[:, 1]))) < 0.001
def test_bondefs(): t = Transfer(transfer_model="BondEfs") print(np.exp(t._unnormalised_lnT)) assert np.isclose(np.exp(t._unnormalised_lnT[0]), 1, rtol=1e-5)
def test_ehnobao(): t = Transfer(transfer_model="EH") tnobao = Transfer(transfer_model="EH_NoBAO") assert np.isclose(t._unnormalised_lnT[0], tnobao._unnormalised_lnT[0], rtol=1e-5)
def test_halofit(): t = Transfer(lnk_min=-20, lnk_max=20, dlnk=0.05, transfer_model="EH") print(EH_BAO._defaults) print("in test_transfer, params are: ", t.transfer_params) assert np.isclose(t.power[0], t.nonlinear_power[0]) assert 5 * t.power[-1] < t.nonlinear_power[-1]
def transfers(): return Transfer(), Transfer()
def t_lcdm(lcdm): return Transfer(cosmo_model=lcdm)
def t_wcdm(wcdm): return Transfer(cosmo_model=wcdm)
def transfers(): return Transfer(transfer_model="EH"), Transfer(transfer_model="EH")