Example #1
0
def test_symmetry_function():
    # Check the consistency of abel.benchmark.is_symmetric

    # checking all combination of odd and even images
    for n, m in [(11, 11), (10, 10), (10, 12), (11, 12), (10, 13), (11, 13)]:
        x = np.linspace(-np.pi, np.pi, n)
        y = np.linspace(-np.pi, np.pi, m)

        XX, YY = np.meshgrid(x, y)

        f1 = np.cos(XX) * np.cos(YY)
        assert_equal(
            is_symmetric(f1, i_sym=True, j_sym=True), True,
            'Checking f1 function for polar symmetry n={},m={}'.format(n, m))

        f2 = np.cos(XX) * np.sin(YY)
        assert_equal(
            is_symmetric(f2, i_sym=True, j_sym=False), True,
            'Checking f2 function for i symmetry n={},m={}'.format(n, m))

        f3 = np.sin(XX) * np.cos(YY)
        assert_equal(
            is_symmetric(f3, i_sym=False, j_sym=True), True,
            'Checking f3 function for j symmetry n={},m={}'.format(n, m))

        assert_equal(
            is_symmetric(f3, i_sym=True, j_sym=False), False,
            'Checking that f3 function does not have i symmetry n={},m={}'.
            format(n, m))

    for n in [10, 11]:
        x = np.linspace(-np.pi, np.pi, n)
        f1 = np.cos(x)
        assert_equal( is_symmetric(f1, i_sym=True, j_sym=False), True,\
              'Checking f1 function for symmetry in 1D n={},m={}'.format(n,m))
Example #2
0
def test_centering_function():
    # ni -> original shape of the data is (ni, ni)
    # n_c  -> the image center is (n_c, n_c)
    # n  -> after the centering function, the array has a shape (n, n)

    for (ni, n_c, n) in [
        (9, 5, 3),
        (9, 5, 4),
    ]:
        arr = np.zeros((ni, ni))

        if n % 2 == 1:
            arr[n_c - 1:n_c + 2, n_c - 1:n_c + 2] = 1
        else:
            arr[n_c - 1:n_c + 1, n_c - 1:n_c + 1] = 1

        res = center_image(arr, (n_c, n_c), n)
        # The print statements  below can be commented after we fix the centering issue
        # print('Original array')
        # print(arr)
        # print('Centered array')
        # print(res)

        assert_equal( is_symmetric(res), True,\
            'Validating the centering function for ni={}, n_c={}, n={}'.format(ni, n_c, n))
Example #3
0
def test_symmetry_function():
    # Check the consistency of abel.benchmark.is_symmetric

    # checking all combination of odd and even images
    for n, m in [(11, 11),
                 (10, 10),
                 (10, 12),
                 (11, 12),
                 (10, 13),
                 (11, 13)
                 ]:
        x = np.linspace(-np.pi, np.pi, n)
        y = np.linspace(-np.pi, np.pi, m)

        XX, YY = np.meshgrid(x, y)


        f1 = np.cos(XX)*np.cos(YY)
        assert_equal( is_symmetric(f1, i_sym=True, j_sym=True), True,
              'Checking f1 function for polar symmetry n={},m={}'.format(n,m))

        f2 = np.cos(XX)*np.sin(YY)
        assert_equal( is_symmetric(f2, i_sym=True, j_sym=False), True,
              'Checking f2 function for i symmetry n={},m={}'.format(n,m))

        f3 = np.sin(XX)*np.cos(YY)
        assert_equal( is_symmetric(f3, i_sym=False, j_sym=True), True,
              'Checking f3 function for j symmetry n={},m={}'.format(n,m))

        assert_equal( is_symmetric(f3, i_sym=True, j_sym=False), False,
              'Checking that f3 function does not have i symmetry n={},m={}'.format(n,m))

    for n in [10, 11]:
        x = np.linspace(-np.pi, np.pi, n)
        f1 = np.cos(x)
        assert_equal( is_symmetric(f1, i_sym=True, j_sym=False), True,\
              'Checking f1 function for symmetry in 1D n={},m={}'.format(n,m))
Example #4
0
def test_centering_function():
    # ni  -> original shape of the data is (ni, ni)
    # n_c -> the image origin is (n_c, n_c)

    for (ni, n_c) in [(10, 5), (10, 5)]:
        arr = np.zeros((ni, ni))

        # arr[n_c-1:n_c+2,n_c-1:n_c+2] = 1
        # # else:
        arr[n_c - 1:n_c + 1, n_c - 1:n_c + 1] = 1.0

        res = abel.tools.center.center_image(arr, (n_c, n_c), odd_size=False)
        # The print statements  below can be commented after we fix the centering issue
        # print('Original array')
        # print(arr)
        # print('Centered array')
        # print(res)

        assert_equal( is_symmetric(res), True,\
            'Validating the centering function for ni={}, n_c={}'.format(ni, n_c))
Example #5
0
def test_centering_function():
    # ni -> original shape of the data is (ni, ni)
    # n_c  -> the image center is (n_c, n_c)

    for (ni, n_c) in [(10, 5),
                         (10,  5),
                         ]:
        arr = np.zeros((ni, ni))

        # arr[n_c-1:n_c+2,n_c-1:n_c+2] = 1
        # # else:
        arr[n_c-1:n_c+1,n_c-1:n_c+1] = 1.0

        res = abel.tools.center.center_image(arr, (n_c, n_c), odd_size=False)
        # The print statements  below can be commented after we fix the centering issue
        # print('Original array')
        # print(arr)
        # print('Centered array')
        # print(res)

        assert_equal( is_symmetric(res), True,\
            'Validating the centering function for ni={}, n_c={}'.format(ni, n_c))
Example #6
0
def test_centering_function():
    # ni -> original shape of the data is (ni, ni)
    # n_c  -> the image center is (n_c, n_c)
    # n  -> after the centering function, the array has a shape (n, n)

    for (ni, n_c, n) in [(9, 5, 3),
                         (9, 5, 4),
                         ]:
        arr = np.zeros((ni, ni))

        if n % 2 == 1:
            arr[n_c-1:n_c+2,n_c-1:n_c+2] = 1
        else:
            arr[n_c-1:n_c+1,n_c-1:n_c+1] = 1

        res = center_image(arr, (n_c, n_c), n)
        # The print statements  below can be commented after we fix the centering issue
        # print('Original array')
        # print(arr)
        # print('Centered array')
        # print(res)

        assert_equal( is_symmetric(res), True,\
            'Validating the centering function for ni={}, n_c={}, n={}'.format(ni, n_c, n))