Transform 22
Tutorials

Fit Variogram

%matplotlib widget
import matplotlib.pyplot as plt
plt.ioff()
# turn of warnings
import warnings
warnings.filterwarnings('ignore')
import numpy as np
import gstools as gs

Generate a synthetic field with an exponential model.

x = np.random.RandomState(20220425).rand(1000) * 100.0
y = np.random.RandomState(20220426).rand(1000) * 100.0

model = gs.Exponential(dim=2, var=2, len_scale=8)
srf = gs.SRF(model, mean=1, seed=20220425)
field = srf((x, y))
# scatter plot
fig, ax = plt.subplots()
ax.scatter(x, y, c=field)
ax.set_aspect("equal")
fig.show()
Loading...

Estimate and fit the variogram with a stable model (no nugget fitted).

# estimate
bin_center, gamma = gs.vario_estimate((x, y), field)
# fit
fit_model = gs.Stable(dim=2)
fit_model.fit_variogram(bin_center, gamma, nugget=False)
ax = fit_model.plot(x_max=max(bin_center))
ax.scatter(bin_center, gamma)
print(fit_model)
Loading...