A Very Simple Example
%matplotlib widget import matplotlib.pyplot as plt plt.ioff() # turn of warnings import warnings warnings.filterwarnings('ignore')
We are going to start with a very simple example of a spatial random field with an isotropic Gaussian covariance model and following parameters:
- correlation length
First, we set things up and create the axes for the field. We are going to need the
SRF class for the actual generation of the spatial random field.
SRF also needs a covariance model and we will simply take the
import gstools as gs x = y = range(101)
Now we create the covariance model with the parameters and
and hand it over to :any:
SRF. By specifying a seed,
we make sure to create reproducible results:
model = gs.Gaussian(dim=2, var=1, len_scale=10, nugget=0) srf = gs.SRF(model, seed=20220425)
With these simple steps, everything is ready to create our first random field.
We will create the field on a structured grid (as you might have guessed from
y), which makes it easier to plot.
field = srf.structured([x, y]) srf.plot()
Wow, that was pretty easy!