.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/03_variogram/05_auto_fit_variogram.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_03_variogram_05_auto_fit_variogram.py: Fit Variogram with automatic binning ------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 5-10 .. code-block:: Python import numpy as np import gstools as gs .. GENERATED FROM PYTHON SOURCE LINES 11-12 Generate a synthetic field with an exponential model. .. GENERATED FROM PYTHON SOURCE LINES 12-19 .. code-block:: Python x = np.random.RandomState(19970221).rand(1000) * 100.0 y = np.random.RandomState(20011012).rand(1000) * 100.0 model = gs.Exponential(dim=2, var=2, len_scale=8) srf = gs.SRF(model, mean=0, seed=19970221) field = srf((x, y)) print(field.var()) .. rst-class:: sphx-glr-script-out .. code-block:: none 1.6791948750716688 .. GENERATED FROM PYTHON SOURCE LINES 20-21 Estimate the variogram of the field with automatic binning. .. GENERATED FROM PYTHON SOURCE LINES 21-26 .. code-block:: Python bin_center, gamma = gs.vario_estimate((x, y), field) print("estimated bin number:", len(bin_center)) print("maximal bin distance:", max(bin_center)) .. rst-class:: sphx-glr-script-out .. code-block:: none estimated bin number: 21 maximal bin distance: 45.88516574202333 .. GENERATED FROM PYTHON SOURCE LINES 27-28 Fit the variogram with a stable model (no nugget fitted). .. GENERATED FROM PYTHON SOURCE LINES 28-33 .. code-block:: Python fit_model = gs.Stable(dim=2) fit_model.fit_variogram(bin_center, gamma, nugget=False) print(fit_model) .. rst-class:: sphx-glr-script-out .. code-block:: none Stable(dim=2, var=1.85, len_scale=7.42, alpha=1.09) .. GENERATED FROM PYTHON SOURCE LINES 34-35 Plot the fitting result. .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: Python ax = fit_model.plot(x_max=max(bin_center)) ax.scatter(bin_center, gamma) .. image-sg:: /examples/03_variogram/images/sphx_glr_05_auto_fit_variogram_001.png :alt: 05 auto fit variogram :srcset: /examples/03_variogram/images/sphx_glr_05_auto_fit_variogram_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.210 seconds) .. _sphx_glr_download_examples_03_variogram_05_auto_fit_variogram.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 05_auto_fit_variogram.ipynb <05_auto_fit_variogram.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 05_auto_fit_variogram.py <05_auto_fit_variogram.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 05_auto_fit_variogram.zip <05_auto_fit_variogram.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_