.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/11_plurigaussian/00_simple.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_11_plurigaussian_00_simple.py: A First and Simple Example -------------------------- As a first example, we will create a two dimensional plurigaussian field (PGS). Thus, we need two spatial random fields(SRF) and on top of that, we need a field describing the categorical data and its spatial relation. We will start off by creating the two SRFs with a Gaussian variogram, which makes the fields nice and smooth. But before that, we will import all necessary libraries and define a few variables, like the number of grid cells in each dimension. .. GENERATED FROM PYTHON SOURCE LINES 13-26 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import gstools as gs dim = 2 # no. of cells in both dimensions N = [180, 140] x = np.arange(N[0]) y = np.arange(N[1]) .. GENERATED FROM PYTHON SOURCE LINES 27-30 In this first example we will use the same geostatistical parameters for both fields for simplicity. Thus, we can use the same SRF instance for the two fields. .. GENERATED FROM PYTHON SOURCE LINES 30-36 .. code-block:: Python model = gs.Gaussian(dim=dim, var=1, len_scale=10) srf = gs.SRF(model) field1 = srf.structured([x, y], seed=20170519) field2 = srf.structured([x, y], seed=19970221) .. GENERATED FROM PYTHON SOURCE LINES 37-42 Now, we will create the lithotypes field describing the categorical data. For now, we will only have two categories and we will address them by the integers 0 and 1. We start off by creating a matrix of 0s from which we will select a rectangle and fill that with 1s. This field does not have to match the shape of the SRFs. .. GENERATED FROM PYTHON SOURCE LINES 42-54 .. code-block:: Python centroid = [200, 160] # size of the rectangle rect = [40, 32] lithotypes = np.zeros(centroid) lithotypes[ centroid[0] // 2 - rect[0] // 2 : centroid[0] // 2 + rect[0] // 2, centroid[1] // 2 - rect[1] // 2 : centroid[1] // 2 + rect[1] // 2, ] = 1 .. GENERATED FROM PYTHON SOURCE LINES 55-58 With the two SRFs and the L-field ready, we can create our first PGS. First, we set up an instance of the PGS class and then we are ready to calculate the field by calling the instance and handing over the L-field. .. GENERATED FROM PYTHON SOURCE LINES 58-62 .. code-block:: Python pgs = gs.PGS(dim, [field1, field2]) P = pgs(lithotypes) .. GENERATED FROM PYTHON SOURCE LINES 63-65 Finally, we can plot the PGS, but we will also show the L-field and the two original Gaussian fields. .. GENERATED FROM PYTHON SOURCE LINES 65-76 .. code-block:: Python fig, axs = plt.subplots(2, 2) axs[0, 0].imshow(field1, cmap="copper", origin="lower") axs[0, 1].imshow(field2, cmap="copper", origin="lower") axs[1, 0].imshow(lithotypes, cmap="copper", origin="lower") axs[1, 1].imshow(P, cmap="copper", origin="lower") # For more information on Plurigaussian fields and how they naturally extend # truncated Gaussian fields, we can recommend the book # [Plurigaussian Simulations in Geosciences](https://doi.org/10.1007/978-3-642-19607-2) .. image-sg:: /examples/11_plurigaussian/images/sphx_glr_00_simple_001.png :alt: 00 simple :srcset: /examples/11_plurigaussian/images/sphx_glr_00_simple_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.550 seconds) .. _sphx_glr_download_examples_11_plurigaussian_00_simple.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 00_simple.ipynb <00_simple.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 00_simple.py <00_simple.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 00_simple.zip <00_simple.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_