Beispiel #1
0
def kriging_eq(simple_model_2_internals):
    sp_internal, ori_internal, options = simple_model_2_internals

    A_matrix = yield_covariance(InterpInput(sp_internal, ori_internal,
                                            options))
    b_vector = yield_b_vector(ori_internal, A_matrix.shape[0])
    return A_matrix, b_vector
    def test_reduction(self, internals):
        sp_internals, ori_internals, options = internals
        # Test cov
        cov = yield_covariance(InterpInput(sp_internals, ori_internals, options))
        print("\n")
        print(cov)

        np.testing.assert_array_almost_equal(np.asarray(cov), cov_sol, decimal=3)

        # Test weights and b vector
        b_vec = yield_b_vector(ori_internals, cov.shape[0])
        weights = kernel_reduction(cov, b_vec)
        print(weights)

        weights_gempy_v2 = [6.402e+00, -1.266e+01, 2.255e-15, -2.784e-15, 1.236e+01, 2.829e+01, -6.702e+01, -6.076e+02,
                            1.637e+03, 1.053e+03, 2.499e+02, -2.266e+03]
        np.testing.assert_allclose(np.asarray(weights), weights_gempy_v2, rtol=2)
Beispiel #3
0
def test_covariance_cubic_kernel(simple_model_2):
    # Cubic kernel
    # Euclidean distance

    l = np.load(dir_name + '/../solutions/test_kernel_numeric2.npy')
    surface_points = simple_model_2[0]
    orientations = simple_model_2[1]
    options = simple_model_2[2]
    tensors_structure = simple_model_2[3]
    sp_internals = surface_points_preprocess(surface_points, tensors_structure.number_of_points_per_surface)
    ori_internals = orientations_preprocess(orientations)

    cov = yield_covariance(InterpInput(sp_internals, ori_internals, options))
    print(cov)
    print(l)

    np.testing.assert_array_almost_equal(np.asarray(cov), l, decimal=3)
                               gi_res=1,
                               number_dimensions=2)

    _ = np.ones(3)
    tensor_structure = TensorsStructure(np.array([3, 2]))

    return spi, ori_i, kri, tensor_structure


BackendTensor.change_backend(AvailableBackends.numpy,
                             use_gpu=True,
                             pykeops_enabled=True)

surface_points, orientations, options, tensors_structure = simple_model_2()

sp_internals = surface_points_preprocess(
    surface_points, tensors_structure.number_of_points_per_surface)
ori_internals = orientations_preprocess(orientations)
kernel_data = cov_vectors_preparation(sp_internals, ori_internals, options)

cov = yield_covariance(sp_internals, ori_internals, options)

cov_grad = _test_covariance_items(kernel_data, options, "cov_grad")

#cov_grad = _test_covariance_items(kernel_data, options, "cov_grad")

# Compile and run cov sum axis 0
#print(cov.sum(axis=0))

# TODO: Compile and run solver
 def weights(self, internals):
     sp_internals, ori_internals, options = internals
     cov = yield_covariance(InterpInput(sp_internals, ori_internals, options))
     b_vec = yield_b_vector(ori_internals, cov.shape[0])
     weights = kernel_reduction(cov, b_vec)
     return weights