Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_core_adjust_for_anisotropy():
X = np.array([[1.0, 0.0, -1.0, 0.0], [0.0, 1.0, 0.0, -1.0]]).T
X_adj = core._adjust_for_anisotropy(X, [0.0, 0.0], [2.0], [90.0])
assert_allclose(X_adj[:, 0], np.array([0.0, 1.0, 0.0, -1.0]), **allclose_pars)
assert_allclose(X_adj[:, 1], np.array([-2.0, 0.0, 2.0, 0.0]), **allclose_pars)
),
)
assert ss[2, 5] <= 1e-15
assert not np.allclose(ss, 0.0)
z, ss = core._krige(
np.vstack((data[:, 0], data[:, 1])).T,
data[:, 2],
np.array([1.0, 1.0]),
variogram_models.linear_variogram_model,
[1.0, 1.0],
"euclidean",
)
assert z == approx(2.0)
assert ss == approx(0.0)
z, ss = core._krige(
np.vstack((data[:, 0], data[:, 1])).T,
data[:, 2],
np.array([1.0, 2.0]),
variogram_models.linear_variogram_model,
[1.0, 1.0],
"euclidean",
)
assert ss != approx(0.0)
data = np.zeros((50, 3))
x, y = np.meshgrid(np.arange(0.0, 10.0, 1.0), np.arange(0.0, 10.0, 2.0))
data[:, 0] = np.ravel(x)
data[:, 1] = np.ravel(y)
data[:, 2] = np.ravel(x) * np.ravel(y)
ok = OrdinaryKriging(
data[:, 0],
)
print("Range:", self.variogram_model_parameters[1])
print("Nugget:", self.variogram_model_parameters[2], "\n")
if self.enable_plotting:
self.display_variogram_model()
if self.verbose:
print("Calculating statistics on variogram model fit...")
self.delta, self.sigma, self.epsilon = _find_statistics(
np.vstack((self.X_ADJUSTED, self.Y_ADJUSTED)).T,
self.Z,
self.variogram_function,
self.variogram_model_parameters,
self.coordinates_type,
)
self.Q1 = core.calcQ1(self.epsilon)
self.Q2 = core.calcQ2(self.epsilon)
self.cR = core.calc_cR(self.Q2, self.sigma)
if self.verbose:
print("Q1 =", self.Q1)
print("Q2 =", self.Q2)
print("cR =", self.cR, "\n")
print("Range:", self.variogram_model_parameters[1])
print("Nugget:", self.variogram_model_parameters[2], "\n")
if self.enable_plotting:
self.display_variogram_model()
if self.verbose:
print("Calculating statistics on variogram model fit...")
if enable_statistics:
self.delta, self.sigma, self.epsilon = _find_statistics(
np.vstack((self.X_ADJUSTED, self.Y_ADJUSTED)).T,
self.Z,
self.variogram_function,
self.variogram_model_parameters,
self.coordinates_type,
)
self.Q1 = core.calcQ1(self.epsilon)
self.Q2 = core.calcQ2(self.epsilon)
self.cR = core.calc_cR(self.Q2, self.sigma)
if self.verbose:
print("Q1 =", self.Q1)
print("Q2 =", self.Q2)
print("cR =", self.cR, "\n")
else:
self.delta, self.sigma, self.epsilon, self.Q1, self.Q2, self.cR = [None] * 6
)
print("Range:", self.variogram_model_parameters[1])
print("Nugget:", self.variogram_model_parameters[2], "\n")
if self.enable_plotting:
self.display_variogram_model()
if self.verbose:
print("Calculating statistics on variogram model fit...")
self.delta, self.sigma, self.epsilon = _find_statistics(
np.vstack((self.X_ADJUSTED, self.Y_ADJUSTED, self.Z_ADJUSTED)).T,
self.VALUES,
self.variogram_function,
self.variogram_model_parameters,
"euclidean",
)
self.Q1 = core.calcQ1(self.epsilon)
self.Q2 = core.calcQ2(self.epsilon)
self.cR = core.calc_cR(self.Q2, self.sigma)
if self.verbose:
print("Q1 =", self.Q1)
print("Q2 =", self.Q2)
print("cR =", self.cR, "\n")
)
print("Range:", self.variogram_model_parameters[1])
print("Nugget:", self.variogram_model_parameters[2], "\n")
if self.enable_plotting:
self.display_variogram_model()
if self.verbose:
print("Calculating statistics on variogram model fit...")
self.delta, self.sigma, self.epsilon = _find_statistics(
np.vstack((self.X_ADJUSTED, self.Y_ADJUSTED)).T,
self.Z,
self.variogram_function,
self.variogram_model_parameters,
"euclidean",
)
self.Q1 = core.calcQ1(self.epsilon)
self.Q2 = core.calcQ2(self.epsilon)
self.cR = core.calc_cR(self.Q2, self.sigma)
if self.verbose:
print("Q1 =", self.Q1)
print("Q2 =", self.Q2)
print("cR =", self.cR, "\n")
if self.verbose:
print("Initializing drift terms...")
# Note that the regional linear drift values will be based
# on the adjusted coordinate system, Really, it doesn't actually
# matter which coordinate system is used here.
if "regional_linear" in drift_terms:
self.regional_linear_drift = True
if self.verbose:
print("Nugget:", self.variogram_model_parameters[2], "\n")
if self.enable_plotting:
self.display_variogram_model()
if self.verbose:
print("Calculating statistics on variogram model fit...")
self.delta, self.sigma, self.epsilon = _find_statistics(
np.vstack((self.X_ADJUSTED, self.Y_ADJUSTED)).T,
self.Z,
self.variogram_function,
self.variogram_model_parameters,
"euclidean",
)
self.Q1 = core.calcQ1(self.epsilon)
self.Q2 = core.calcQ2(self.epsilon)
self.cR = core.calc_cR(self.Q2, self.sigma)
if self.verbose:
print("Q1 =", self.Q1)
print("Q2 =", self.Q2)
print("cR =", self.cR, "\n")
print("Nugget:", self.variogram_model_parameters[2], "\n")
if self.enable_plotting:
self.display_variogram_model()
if self.verbose:
print("Calculating statistics on variogram model fit...")
self.delta, self.sigma, self.epsilon = _find_statistics(
np.vstack((self.X_ADJUSTED, self.Y_ADJUSTED, self.Z_ADJUSTED)).T,
self.VALUES,
self.variogram_function,
self.variogram_model_parameters,
"euclidean",
)
self.Q1 = core.calcQ1(self.epsilon)
self.Q2 = core.calcQ2(self.epsilon)
self.cR = core.calc_cR(self.Q2, self.sigma)
if self.verbose:
print("Q1 =", self.Q1)
print("Q2 =", self.Q2)
print("cR =", self.cR, "\n")
)
print("Range:", self.variogram_model_parameters[1])
print("Nugget:", self.variogram_model_parameters[2], "\n")
if self.enable_plotting:
self.display_variogram_model()
if self.verbose:
print("Calculating statistics on variogram model fit...")
self.delta, self.sigma, self.epsilon = _find_statistics(
np.vstack((self.X_ADJUSTED, self.Y_ADJUSTED, self.Z_ADJUSTED)).T,
self.VALUES,
self.variogram_function,
self.variogram_model_parameters,
"euclidean",
)
self.Q1 = core.calcQ1(self.epsilon)
self.Q2 = core.calcQ2(self.epsilon)
self.cR = core.calc_cR(self.Q2, self.sigma)
if self.verbose:
print("Q1 =", self.Q1)
print("Q2 =", self.Q2)
print("cR =", self.cR, "\n")
if self.verbose:
print("Initializing drift terms...")
# Note that the regional linear drift values will be based on the
# adjusted coordinate system. Really, it doesn't actually matter
# which coordinate system is used here.
if "regional_linear" in drift_terms:
self.regional_linear_drift = True
if self.verbose: