gstools.variogram

GStools subpackage providing tools for estimating and fitting variograms.

Variogram estimation

vario_estimate_unstructured(pos, field, …) Estimates the variogram on a unstructured grid.
vario_estimate_structured(field[, …]) Estimates the variogram on a regular grid.

gstools.variogram.vario_estimate_unstructured(pos, field, bin_edges, sampling_size=None, sampling_seed=None, estimator='matheron')[source]

Estimates the variogram on a unstructured grid.

The algorithm calculates following equation:

\gamma(r_k) = \frac{1}{2 N(r_k)} \sum_{i=1}^{N(r_k)} (z(\mathbf x_i) -
z(\mathbf x_i'))^2 \; ,

with r_k \leq \| \mathbf x_i - \mathbf x_i' \| < r_{k+1} being the bins.

Or if the estimator “cressie” was chosen:

\gamma(r_k) = \frac{\frac{1}{2}\left(\frac{1}{N(r_k)}\sum_{i=1}^{N(r_k)}
\left|z(\mathbf x_i) - z(\mathbf x_i')\right|^{0.5}\right)^4}
{0.457 + 0.494 / N(r_k) + 0.045 / N^2(r_k)} \; ,

with r_k \leq \| \mathbf x_i - \mathbf x_i' \| < r_{k+1} being the bins. The Cressie estimator is more robust to outliers.

Notes

Internally uses double precision and also returns doubles.

Parameters:
  • pos (list) – the position tuple, containing main direction and transversal directions
  • field (numpy.ndarray) – the spatially distributed data
  • bin_edges (numpy.ndarray) – the bins on which the variogram will be calculated
  • sampling_size (int or None, optional) – for large input data, this method can take a long time to compute the variogram, therefore this argument specifies the number of data points to sample randomly Default: None
  • sampling_seed (int or None, optional) – seed for samples if sampling_size is given. Default: None
  • estimator (str, optional) –

    the estimator function, possible choices:

    • ”matheron”: the standard method of moments of Matheron
    • ”cressie”: an estimator more robust to outliers

    Default: “matheron”

Returns:

the estimated variogram and the bin centers

Return type:

tuple of numpy.ndarray

gstools.variogram.vario_estimate_structured(field, direction='x', estimator='matheron')[source]

Estimates the variogram on a regular grid.

The indices of the given direction are used for the bins. The algorithm calculates following equation:

\gamma(r_k) = \frac{1}{2 N(r_k)} \sum_{i=1}^{N(r_k)} (z(\mathbf x_i) -
z(\mathbf x_i'))^2 \; ,

with r_k \leq \| \mathbf x_i - \mathbf x_i' \| < r_{k+1} being the bins.

Or if the estimator “cressie” was chosen:

\gamma(r_k) = \frac{\frac{1}{2}\left(\frac{1}{N(r_k)}\sum_{i=1}^{N(r_k)}
\left|z(\mathbf x_i) - z(\mathbf x_i')\right|^{0.5}\right)^4}
{0.457 + 0.494 / N(r_k) + 0.045 / N^2(r_k)} \; ,

with r_k \leq \| \mathbf x_i - \mathbf x_i' \| < r_{k+1} being the bins. The Cressie estimator is more robust to outliers.

Warning

It is assumed that the field is defined on an equidistant Cartesian grid.

Notes

Internally uses double precision and also returns doubles.

Parameters:
  • field (numpy.ndarray) – the spatially distributed data
  • direction (str) – the axis over which the variogram will be estimated (x, y, z)
  • estimator (str, optional) –

    the estimator function, possible choices:

    • ”mathoron”: the standard method of moments of Matheron
    • ”cressie”: an estimator more robust to outliers

    Default: “matheron”

Returns:

the estimated variogram along the given direction.

Return type:

numpy.ndarray