Ejemplo n.º 1
0
def test_inverse_distance_to_grid(method, test_data, test_grid):
    r"""Test inverse distance interpolation to grid function."""
    xp, yp, z = test_data
    xg, yg = test_grid

    extra_kw = {}
    if method == 'cressman':
        extra_kw['r'] = 20
        extra_kw['min_neighbors'] = 1
        test_file = 'cressman_r20_mn1.npz'
    elif method == 'barnes':
        extra_kw['r'] = 40
        extra_kw['kappa'] = 100
        test_file = 'barnes_r40_k100.npz'

    img = inverse_distance_to_grid(xp, yp, z, xg, yg, kind=method, **extra_kw)

    with get_test_data(test_file) as fobj:
        truth = np.load(fobj)['img']

    assert_array_almost_equal(truth, img)
Ejemplo n.º 2
0
def test_inverse_distance_to_grid(method, test_data, test_grid):
    r"""Test inverse distance interpolation to grid function."""
    xp, yp, z = test_data
    xg, yg = test_grid

    extra_kw = {}
    if method == 'cressman':
        extra_kw['r'] = 20
        extra_kw['min_neighbors'] = 1
        test_file = 'cressman_r20_mn1.npz'
    elif method == 'barnes':
        extra_kw['r'] = 40
        extra_kw['kappa'] = 100
        test_file = 'barnes_r40_k100.npz'

    img = inverse_distance_to_grid(xp, yp, z, xg, yg, kind=method, **extra_kw)

    with get_test_data(test_file) as fobj:
        truth = np.load(fobj)['img']

    assert_array_almost_equal(truth, img)