GSTools: A Geostatistical Toolbox

raw JSON →
1.7.0 verified Fri May 01 auth: no python

GSTools is a Python library for geostatistical modeling and random field generation. It provides covariance models, variogram estimation, kriging, and conditional/unconditional random field simulation. Current version is 1.7.0, with releases approximately every 3-6 months. Requires Python >=3.8.

pip install gstools
error ModuleNotFoundError: No module named 'gstools'
cause Package not installed.
fix
Run pip install gstools or conda install -c conda-forge gstools.
error ImportError: cannot import name 'Gaussian' from 'gstools'
cause Incorrect import path. Gaussian is a covariance model class.
fix
Use from gstools import Gaussian.
error ValueError: The 'seed' argument must be a MasterRNG instance, not an integer.
cause Using a plain integer as seed in SRF.
fix
Use gs.random.MasterRNG(seed_value) to wrap the seed.
breaking In v1.7.0, the Cython code has been outsourced to a separate package GSTools-Cython. If you had a direct dependency on compiled extensions, you may need to install gstools-cython explicitly.
fix Use pip install gstools (auto-installs gstools-cython on most platforms) or install gstools-cython manually for non-standard environments.
deprecated The 'temporal' flag in CovModel is deprecated since v1.5.0. Use the explicit spatio-temporal model classes instead.
fix Use gs.SpatioTemporal models (e.g., gs.SpatioTemporalGaussian) instead of setting temporal=True.
gotcha Random field generation requires a seed object from gstools.random.MasterRNG, not a plain integer. Using an integer may cause non-reproducible results.
fix Always wrap your seed in gs.random.MasterRNG(seed_value).
conda install -c conda-forge gstools

Basic random field generation with Gaussian covariance model.

import gstools as gs
import numpy as np

# Create a Gaussian covariance model
model = gs.Gaussian(dim=2, var=1.0, len_scale=10.0)

# Generate a random field
x = np.linspace(0, 100, 50)
y = np.linspace(0, 100, 50)
seed = gs.random.MasterRNG(20170519)
field = gs.SRF(model, seed=seed)

# Evaluate field on a grid
pos = (x, y)
field(pos)
print(field.field.shape)  # Should be (50, 50)