.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/05_kriging/05_universal_kriging.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_05_kriging_05_universal_kriging.py: Universal Kriging ----------------- You can give a polynomial order or a list of self defined functions representing the internal drift of the given values. This drift will be fitted internally during the kriging interpolation. In the following we are creating artificial data, where a linear drift was added. The resulting samples are then used as input for Universal kriging. The "linear" drift is then estimated during the interpolation. To access only the estimated mean/drift, we provide a switch `only_mean` in the call routine. .. GENERATED FROM PYTHON SOURCE LINES 16-42 .. image-sg:: /examples/05_kriging/images/sphx_glr_05_universal_kriging_001.png :alt: Field 1D: (151,) :srcset: /examples/05_kriging/images/sphx_glr_05_universal_kriging_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np from gstools import SRF, Gaussian, krige # synthetic condtions with a drift drift_model = Gaussian(dim=1, var=0.1, len_scale=2) drift = SRF(drift_model, seed=101) cond_pos = np.linspace(0.1, 8, 10) cond_val = drift(cond_pos) + cond_pos * 0.1 + 1 # resulting grid gridx = np.linspace(0.0, 15.0, 151) drift_field = drift(gridx) + gridx * 0.1 + 1 # kriging model = Gaussian(dim=1, var=0.1, len_scale=2) krig = krige.Universal(model, cond_pos, cond_val, "linear") krig(gridx) ax = krig.plot() ax.scatter(cond_pos, cond_val, color="k", zorder=10, label="Conditions") ax.plot(gridx, gridx * 0.1 + 1, ":", label="linear drift") ax.plot(gridx, drift_field, "--", label="original field") mean = krig(gridx, only_mean=True) ax.plot(gridx, mean, label="estimated drift") ax.legend() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.066 seconds) .. _sphx_glr_download_examples_05_kriging_05_universal_kriging.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 05_universal_kriging.ipynb <05_universal_kriging.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 05_universal_kriging.py <05_universal_kriging.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 05_universal_kriging.zip <05_universal_kriging.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_