Getting Started#
Load the class and data#
The main class of scikit-gstat is the Variogram. It can directly be imported
from the module, called skgstat. The main class can easily be demonstrated on
the data module available with version >=0.5.5
.
In [1]: import skgstat as skg
In [2]: import numpy as np
In [3]: import matplotlib.pyplot as plt
In [4]: plt.style.use('ggplot')
In [5]: data = skg.data.pancake(N=500, seed=42)
In [6]: print(data.get('origin'))
Image of a pancake with apparent spatial structure.
Copyright Mirko Mälicke, 2020. If you use this data cite SciKit-GStat:
Mälicke, M.: SciKit-GStat 1.0: a SciPy-flavored geostatistical variogram estimation
toolbox written in Python, Geosci. Model Dev., 15, 2505–2532,
https://doi.org/10.5194/gmd-15-2505-2022, 2022.
In [7]: coordinates, values = data.get('sample')
The Variogram needs at least an array of coordinates and an array of values on instantiation.
In [8]: V = skg.Variogram(coordinates=coordinates, values=values)
In [9]: print(V)
spherical Variogram
-------------------
Estimator: matheron
Effective Range: 311.76
Sill: 1210.20
Nugget: 0.00
Plot#
The Variogram class has its own plotting method.
In [10]: V.plot()
Out[10]: <Figure size 800x500 with 2 Axes>
In [11]: plt.close()

With version 0.2, the histogram plot can also be disabled. This is most
useful, when the binning method for the lag classes is changed from 'even'
step classes to 'uniform'
distribution in the lag classes.
In [12]: V.set_bin_func('uniform')
In [13]: V.plot(hist=False)
Out[13]: <Figure size 800x400 with 1 Axes>
In [14]: plt.close()

Mutating#
One of the main strenghs of Variogram
is its
ability to change arguments in place. Any dependent result or parameter
will be invalidated and re-caluculated.
You can i.e. increase the number of lag classes:
In [15]: V.n_lags = 25
In [16]: V.maxlag = 500
In [17]: V.bin_func = 'kmeans'
In [18]: V.plot()
Out[18]: <Figure size 800x500 with 2 Axes>
In [19]: plt.close()

Note, how the experimental variogram was updated and the model was fitted to the new data automatically.