예제 #1
0
def test_cl2xi_cl_dim():
    """Test that cl2xi raises an exception when cl is a not a 1D array."""

    cl = np.zeros((10, 10))

    with np.testing.assert_raises_regex(Exception, '1D'):
        cov.cl2xi_theta(cl, 0)
예제 #2
0
def test_cl2xi_theta_dim():
    """Test that cl2xi raises an exception when thetas is a not a 2D array."""

    cl = np.zeros(10)
    thetas = np.linspace(0, np.pi, 100).reshape([10, -1])

    with np.testing.assert_raises_regex(Exception, '0D or 1D'):
        cov.cl2xi_theta(cl, thetas)
예제 #3
0
def test_cl2xi_dipole():
    """Test that cl2xi has opposite sign correlation at poles and zero at equator for dipole power spectrum."""

    cl = np.zeros(1000)
    cl[1] = 1
    theta = np.linspace(0, np.pi, 1000)

    xi = cov.cl2xi_theta(cl, theta)

    np.testing.assert_almost_equal(xi[0], -xi[-1])
    np.testing.assert_almost_equal(cov.cl2xi_theta(cl, np.pi / 2), 0)
예제 #4
0
def test_cl2xi_zero():
    """Tests that the cl2xi_theta returns zero for zero input power spectrum."""

    cl = np.zeros(1000)
    theta = np.linspace(0, np.pi, 1000)

    xi = cov.cl2xi_theta(cl, theta)

    np.testing.assert_almost_equal(xi, 0)
예제 #5
0
def test_cl2xi_monopole():
    """Test that cl2xi has constant correlation over all separations for monopole power spectrum."""

    cl = np.zeros(1000)
    cl[0] = 1
    theta = np.linspace(0, np.pi, 1000)

    xi = cov.cl2xi_theta(cl, theta)

    np.testing.assert_almost_equal(xi, xi[0])
예제 #6
0
def test_cl2cov_log():
    """Test that cl2cov raises an exception when log covariance is requested but no shift is specified."""
    nside = 16

    cl = [1]

    xi_ii = cov.cl2xi_theta(cl, 0)
    cov_mat = cov.cl2cov_mat(cl, nside, log=True, shift=1)

    np.testing.assert_almost_equal(cov_mat, np.log(xi_ii + 1))