Beispiel #1
0
def test_xi_mm_at_R_exact():
    #List vs. numpy.array
    npt.assert_array_equal(xi.xi_mm_at_R(Ra, knl, pnl, exact=True), xi.xi_mm_at_R(Ra.tolist(), knl, pnl, exact=True))
    #Single value vs numpy.array
    arr1 = xi.xi_mm_at_R(Ra, knl, pnl, exact=True)
    arr2 = np.array([xi.xi_mm_at_R(Ri, knl, pnl, exact=True) for Ri in Ra])
    npt.assert_array_equal(arr1, arr2)
Beispiel #2
0
def test_combination():
    xinfw = xi.xi_nfw_at_R(Ra, Mass, conc, Omega_m)
    ximm = xi.xi_mm_at_R(Ra, knl, pnl)
    from cluster_toolkit import bias
    b = bias.bias_at_M(Mass, klin, plin, Omega_m)
    xi2h = xi.xi_2halo(b, ximm)
    xihm = xi.xi_hm(xinfw, xi2h)
    xihm2 = xi.xi_hm(xinfw, xi2h, combination='max')
    npt.assert_array_equal(xihm, xihm2)
    xihm2 = xi.xi_hm(xinfw, xi2h, combination='sum')
    npt.assert_raises(AssertionError, npt.assert_array_equal, xihm, xihm2)
    with pytest.raises(Exception):
        xi.xi_hm(xinfw, xi2h, combination='blah')
Beispiel #3
0
def calc_ximm(cosmos, zs, k, p):
    Nc = len(cosmos)
    Nz = len(zs)
    xis = np.zeros((Nc, Nz, len(r)))
    for i in range(Nc):
        obh2, och2, w, ns, ln10As, H0, Neff, s8 = cosmos[i]
        h = H0 / 100.
        kh = k / h  #now h/Mpc
        for j in range(Nz):
            ph3 = p[i, j] * h**3  #now (Mpc/h)^3
            xis[i, j] = ctxi.xi_mm_at_R(r, kh, ph3)  #, exact=True)
            continue
        print("Finished ximm box %d" % i)
    return xis
import pytest
from cluster_toolkit import xi
import numpy as np
import matplotlib.pyplot as plt

R = np.logspace(-1, 3, 100)
k = np.loadtxt("k.txt")
p = np.loadtxt("p.txt")

for i in range(-5, 5, 1):
    ximm = xi.xi_mm_at_R(R, k, p, step=0.005 + i * 0.001)
    plt.loglog(R, ximm, label='%d' % i)
plt.legend()
plt.show()

for i in range(195, 205, 1):
    ximm = xi.xi_mm_at_R(R, k, p, N=i)
    plt.loglog(R, ximm, label='%d' % i)
plt.legend()
plt.show()