예제 #1
0
def test_xi():
    positions = np.random.rand(10, 3) * 20

    # Build reference
    c = Correlator(quiet=True)
    c.add_point([0, 0, 0], ["hessian"], 5)
    for x in positions:
        c.add_point(x, ["delta"], 5)
    ref = c.cov[:6, 6:]

    # Build answer
    WG = filters.GaussianFilter(radius=5)
    fh = FieldHandler(Ndim=3,
                      Lbox=2,
                      dimensions=128,
                      filter=WG,
                      Pk=(c.k, c.Pk))
    c_hess = C.HessianConstrain([0, 0, 0],
                                filter=WG,
                                field_handler=fh,
                                value=None)

    order = [0, 3, 5, 1, 2, 4]
    ans = (c_hess.xi(positions) / (fh.sigma(0) * fh.sigma(2)))[:, 0, order].T

    # Check
    assert_allclose(ref, ans, rtol=5e-2)
예제 #2
0
def test_field_sigma():
    fh = FieldHandler(Ndim=3, Lbox=100, dimensions=128, Pk=(k, Pk))

    smoothing_scales = np.geomspace(5, 10, 20)
    sigma_th = [fh.sigma(0, filters.TopHatFilter(R)) for R in smoothing_scales]
    sigma_exp = [
        fh.get_smoothed(filters.TopHatFilter(R)).std() for R in smoothing_scales
    ]

    # Check the field variance
    assert_allclose(sigma_th, sigma_exp, rtol=5e-2)