%matplotlib widget
import matplotlib.pyplot as plt
plt.ioff()
# turn of warnings
import warnings
warnings.filterwarnings('ignore')
For many applications, the random fields are needed on an unstructured grid. Normally, such a grid would be read in, but we can simply generate one and then create a random field at those coordinates.
import numpy as np
import gstools as gs
Creating our own unstructured grid
seed = gs.random.MasterRNG(20220425)
rng = np.random.RandomState(seed())
x = rng.randint(0, 100, size=10000)
y = rng.randint(0, 100, size=10000)
model = gs.Exponential(dim=2, var=1, len_scale=[12, 3], angles=np.pi / 8)
srf = gs.SRF(model, seed=20220425)
field = srf((x, y))
srf.vtk_export("field")
'/Users/stevejpurves/dev/swung/gstools-transform22-tutorial/02_random_field/field.vtu'
ax = srf.plot(contour_plot=True)
ax.set_aspect("equal")
Loading...
Comparing this image to the previous one, you can see that be using the same seed, the same field can be computed on different grids.
mesh = srf.to_pyvista()
mesh.plot()
Loading...