Why Krige returns 2d Gaussian model one len_scale? #321
-
Hi, import numpy as np
import gstools as gs
cond_x = [0.3, 1.9, 1.1, 3.3, 4.7]
cond_y = [1.2, 0.6, 3.2, 4.4, 3.8]
cond_val = [0.47, 0.56, 0.74, 1.47, 1.74]
gridx = np.arange(0.0, 5.5, 0.1)
gridy = np.arange(0.0, 6.5, 0.1)
model2 = gs.Gaussian(
dim=2, len_scale=[1,4], anis=0.2, angles=-0.5, var=0.5, nugget=0.1
)
OK2 = gs.krige.Ordinary(model2, [cond_x, cond_y], cond_val, exact=True, fit_variogram=True) The original model is In another trying, I found the len_scale is quite different. import numpy as np
from matplotlib import pyplot as plt
import gstools as gs
cond_x = [0.3, 1.9, 1.1, 3.3, 4.7]
cond_y = [1.2, 0.6, 3.2, 4.4, 3.8]
cond_val = [0.47, 0.56, 0.74, 1.47, 1.74]
gridx = np.arange(0.0, 5.5, 0.1)
gridy = np.arange(0.0, 6.5, 0.1)
model2 = gs.Gaussian(dim=2, len_scale=[1,4], var=0.5)
OK2 = gs.krige.Ordinary(model2, [cond_x, cond_y], cond_val, exact=True, fit_variogram=True)
ff2 = OK2.structured([gridx, gridy])
fig, ax = plt.subplots()
herten_trans_skip = ff2[0]
gamma_x = gs.vario_estimate_axis(herten_trans_skip, direction="x")[0:50]
gamma_y = gs.vario_estimate_axis(herten_trans_skip, direction="y")[0:50]
x_plot = np.arange(len(gamma_x))
y_plot = np.arange(len(gamma_y))
fit_model_x = gs.Gaussian(dim=2)
fit_model_x.fit_variogram(x_plot, gamma_x)
fit_model_y = gs.Gaussian(dim=2)
fit_model_y.fit_variogram(y_plot, gamma_y)
ax.scatter(x_plot, gamma_x, label="estimated variogram in x-dir")
ax.plot(
x_plot,
fit_model_x.variogram(x_plot),
linestyle="--",
label="variogram in x-dir",
)
ax.scatter(y_plot, gamma_y, label="estimated variogram in y-dir")
ax.plot(
y_plot,
fit_model_y.variogram(y_plot),
linestyle="--",
label="variogram in y-dir",
)
ax.legend(loc="lower right")
ax.set_title("Fitting an anisotropic model")
plt.show() the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey there, first, setting Second, there are to few data points to estimate a variogram. You could see that by doing the variogram estimation by hand: import gstools as gs
from matplotlib import pyplot as plt
cond_x = [0.3, 1.9, 1.1, 3.3, 4.7]
cond_y = [1.2, 0.6, 3.2, 4.4, 3.8]
cond_val = [0.47, 0.56, 0.74, 1.47, 1.74]
bins, gamma = gs.vario_estimate((cond_x, cond_y), cond_val)
plt.scatter(bins, gamma)
plt.show() This means, the variogram can't be fitted correctly. Why do you expect the model to be the same when you set Same problem occurs in the second example. Since the model is automatically fitted to the estimated variogram of the conditioning data, the anisotropy and length scales are way of, since the data doesn't carry enough information for that. Subsequently estimating these values on the kriged field results in useless parameters. So, if you don't want, that the model is altered, don't set Hope that helps, |
Beta Was this translation helpful? Give feedback.
Hey there,
first, setting
len_scale=[1,4], anis=0.2
is redundant, sinceanis
will be set to4
from the given length scales.Second, there are to few data points to estimate a variogram. You could see that by doing the variogram estimation by hand:
This means, the variogram can't be fitted correctly.
Why do you expect the model to be the same when you set
fit_variogram=True
? This will alter the model inplace, so the paramete…