Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
data, _, (ok_test_answer, gridx, gridy) = validation_ref
ok = OrdinaryKriging(
data[:, 0],
data[:, 1],
data[:, 2],
variogram_model="exponential",
variogram_parameters=_variogram_parameters,
)
# Get the variogram points from the UniversalKriging instance
lags, calculated_variogram = ok.get_variogram_points()
# Generate the expected variogram points according to the
# exponential variogram model
expected_variogram = variogram_models.exponential_variogram_model(
_variogram_parameters, lags
)
assert_allclose(calculated_variogram, expected_variogram)
uk = UniversalKriging(
data[:, 0],
data[:, 1],
data[:, 2],
variogram_model="exponential",
variogram_parameters=_variogram_parameters,
drift_terms=["regional_linear"],
)
# Get the variogram points from the UniversalKriging instance
lags, calculated_variogram = uk.get_variogram_points()
# Generate the expected variogram points according to the
# exponential variogram model
expected_variogram = variogram_models.exponential_variogram_model(
_variogram_parameters, lags
)
assert_allclose(calculated_variogram, expected_variogram)
assert_allclose(res, np.array([1.0, 1.5, 0.0]), 0.001, 0.001)
res = core._calculate_variogram_model(
np.array([1.0, 2.0, 3.0, 4.0]),
np.array([1.0, 1.4142, 1.7321, 2.0]),
"power",
variogram_models.power_variogram_model,
False,
)
assert_allclose(res, np.array([1.0, 0.5, 0.0]), 0.001, 0.001)
res = core._calculate_variogram_model(
np.array([1.0, 2.0, 3.0, 4.0]),
np.array([1.2642, 1.7293, 1.9004, 1.9634]),
"exponential",
variogram_models.exponential_variogram_model,
False,
)
assert_allclose(res, np.array([2.0, 3.0, 0.0]), 0.001, 0.001)
res = core._calculate_variogram_model(
np.array([1.0, 2.0, 3.0, 4.0]),
np.array([0.5769, 1.4872, 1.9065, 1.9914]),
"gaussian",
variogram_models.gaussian_variogram_model,
False,
)
assert_allclose(res, np.array([2.0, 3.0, 0.0]), 0.001, 0.001)
res = core._calculate_variogram_model(
np.array([1.0, 2.0, 3.0, 4.0]),
np.array([3.33060952, 3.85063879, 3.96667301, 3.99256374]),
assert_allclose(res, np.array([2.0, 3.0, 0.0]), 0.001, 0.001)
res = core._calculate_variogram_model(
np.array([1.0, 2.0, 3.0, 4.0]),
np.array([0.5769, 1.4872, 1.9065, 1.9914]),
"gaussian",
variogram_models.gaussian_variogram_model,
False,
)
assert_allclose(res, np.array([2.0, 3.0, 0.0]), 0.001, 0.001)
res = core._calculate_variogram_model(
np.array([1.0, 2.0, 3.0, 4.0]),
np.array([3.33060952, 3.85063879, 3.96667301, 3.99256374]),
"exponential",
variogram_models.exponential_variogram_model,
False,
)
assert_allclose(res, np.array([3.0, 2.0, 1.0]), 0.001, 0.001)
res = core._calculate_variogram_model(
np.array([1.0, 2.0, 3.0, 4.0]),
np.array([2.60487044, 3.85968813, 3.99694817, 3.99998564]),
"gaussian",
variogram_models.gaussian_variogram_model,
False,
)
assert_allclose(res, np.array([3.0, 2.0, 1.0]), 0.001, 0.001)
enable_plotting : bool, optional
Enables plotting to display variogram. Default is False (off).
References
----------
.. [1] P.K. Kitanidis, Introduction to Geostatistcs: Applications in
Hydrogeology, (Cambridge University Press, 1997) 272 p.
"""
eps = 1.0e-10 # Cutoff for comparison to zero
variogram_dict = {
"linear": variogram_models.linear_variogram_model,
"power": variogram_models.power_variogram_model,
"gaussian": variogram_models.gaussian_variogram_model,
"spherical": variogram_models.spherical_variogram_model,
"exponential": variogram_models.exponential_variogram_model,
"hole-effect": variogram_models.hole_effect_variogram_model,
}
def __init__(
self,
x,
y,
z,
val,
variogram_model="linear",
variogram_parameters=None,
variogram_function=None,
nlags=6,
weight=False,
anisotropy_scaling_y=1.0,
anisotropy_scaling_z=1.0,
References
----------
.. [1] P.K. Kitanidis, Introduction to Geostatistcs: Applications in
Hydrogeology, (Cambridge University Press, 1997) 272 p.
"""
UNBIAS = True # This can be changed to remove the unbiasedness condition
# Really for testing purposes only...
eps = 1.0e-10 # Cutoff for comparison to zero
variogram_dict = {
"linear": variogram_models.linear_variogram_model,
"power": variogram_models.power_variogram_model,
"gaussian": variogram_models.gaussian_variogram_model,
"spherical": variogram_models.spherical_variogram_model,
"exponential": variogram_models.exponential_variogram_model,
"hole-effect": variogram_models.hole_effect_variogram_model,
}
def __init__(
self,
x,
y,
z,
variogram_model="linear",
variogram_parameters=None,
variogram_function=None,
nlags=6,
weight=False,
anisotropy_scaling=1.0,
anisotropy_angle=0.0,
drift_terms=None,
References
----------
.. [1] P.K. Kitanidis, Introduction to Geostatistcs: Applications in
Hydrogeology, (Cambridge University Press, 1997) 272 p.
"""
UNBIAS = True # This can be changed to remove the unbiasedness condition
# Really for testing purposes only...
eps = 1.0e-10 # Cutoff for comparison to zero
variogram_dict = {
"linear": variogram_models.linear_variogram_model,
"power": variogram_models.power_variogram_model,
"gaussian": variogram_models.gaussian_variogram_model,
"spherical": variogram_models.spherical_variogram_model,
"exponential": variogram_models.exponential_variogram_model,
"hole-effect": variogram_models.hole_effect_variogram_model,
}
def __init__(
self,
x,
y,
z,
val,
variogram_model="linear",
variogram_parameters=None,
variogram_function=None,
nlags=6,
weight=False,
anisotropy_scaling_y=1.0,
anisotropy_scaling_z=1.0,
coordinates, both given in degree. Longitudes are expected in
[0, 360] and latitudes in [-90, 90]. Default is 'euclidean'.
References
----------
.. [1] P.K. Kitanidis, Introduction to Geostatistcs: Applications in
Hydrogeology, (Cambridge University Press, 1997) 272 p.
"""
eps = 1.0e-10 # Cutoff for comparison to zero
variogram_dict = {
"linear": variogram_models.linear_variogram_model,
"power": variogram_models.power_variogram_model,
"gaussian": variogram_models.gaussian_variogram_model,
"spherical": variogram_models.spherical_variogram_model,
"exponential": variogram_models.exponential_variogram_model,
"hole-effect": variogram_models.hole_effect_variogram_model,
}
def __init__(
self,
x,
y,
z,
variogram_model="linear",
variogram_parameters=None,
variogram_function=None,
nlags=6,
weight=False,
anisotropy_scaling=1.0,
anisotropy_angle=0.0,
verbose=False,