.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/05_kriging/08_measurement_errors.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_08_measurement_errors.py: Incorporating measurement errors -------------------------------- To incorporate the nugget effect and/or given measurement errors, one can set `exact` to `False` and provide either individual measurement errors for each point or set the nugget as a constant measurement error everywhere. In the following we will show the influence of the nugget and measurement errors. .. GENERATED FROM PYTHON SOURCE LINES 12-26 .. code-block:: Python import numpy as np import gstools as gs # condtions cond_pos = [0.3, 1.1, 1.9, 3.3, 4.7] cond_val = [0.47, 0.74, 0.56, 1.47, 1.74] cond_err = [0.01, 0.0, 0.1, 0.05, 0] # resulting grid gridx = np.linspace(0.0, 15.0, 151) # spatial random field class model = gs.Gaussian(dim=1, var=0.9, len_scale=1, nugget=0.1) .. GENERATED FROM PYTHON SOURCE LINES 27-29 Here we will use Simple kriging (`unbiased=False`) to interpolate the given conditions. .. GENERATED FROM PYTHON SOURCE LINES 29-41 .. code-block:: Python krig = gs.Krige( model=model, cond_pos=cond_pos, cond_val=cond_val, mean=1, unbiased=False, exact=False, cond_err=cond_err, ) krig(gridx) .. GENERATED FROM PYTHON SOURCE LINES 42-45 Let's plot the data. You can see, that the estimated values differ more from the input, when the given measurement errors get bigger. In addition we plot the standard deviation. .. GENERATED FROM PYTHON SOURCE LINES 45-57 .. code-block:: Python ax = krig.plot() ax.scatter(cond_pos, cond_val, color="k", zorder=10, label="Conditions") ax.fill_between( gridx, # plus/minus standard deviation (70 percent confidence interval) krig.field - np.sqrt(krig.krige_var), krig.field + np.sqrt(krig.krige_var), alpha=0.3, label="Standard deviation", ) ax.legend() .. image-sg:: /examples/05_kriging/images/sphx_glr_08_measurement_errors_001.png :alt: Field 1D: (151,) :srcset: /examples/05_kriging/images/sphx_glr_08_measurement_errors_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.051 seconds) .. _sphx_glr_download_examples_05_kriging_08_measurement_errors.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 08_measurement_errors.ipynb <08_measurement_errors.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 08_measurement_errors.py <08_measurement_errors.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 08_measurement_errors.zip <08_measurement_errors.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_