.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/02_cov_model/05_additional_para.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_02_cov_model_05_additional_para.py: Additional Parameters ===================== Let's pimp our self-defined model ``Gau`` from the introductory example by setting the exponent as an additional parameter: .. math:: \rho(r) := \exp\left(-\left(\frac{r}{\ell}\right)^{\alpha}\right) This leads to the so called **stable** covariance model and we can define it by .. GENERATED FROM PYTHON SOURCE LINES 13-27 .. code-block:: Python import numpy as np import gstools as gs class Stab(gs.CovModel): def default_opt_arg(self): return {"alpha": 1.5} def cor(self, h): return np.exp(-(h**self.alpha)) .. GENERATED FROM PYTHON SOURCE LINES 28-34 As you can see, we override the method :any:`CovModel.default_opt_arg` to provide a standard value for the optional argument ``alpha``. We can access it in the correlation function by ``self.alpha`` Now we can instantiate this model by either setting alpha implicitly with the default value or explicitly: .. GENERATED FROM PYTHON SOURCE LINES 34-40 .. code-block:: Python model1 = Stab(dim=2, var=2.0, len_scale=10) model2 = Stab(dim=2, var=2.0, len_scale=10, alpha=0.5) ax = model1.plot() model2.plot(ax=ax) .. image-sg:: /examples/02_cov_model/images/sphx_glr_05_additional_para_001.png :alt: 05 additional para :srcset: /examples/02_cov_model/images/sphx_glr_05_additional_para_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 41-48 Apparently, the parameter alpha controls the slope of the variogram and consequently the roughness of a generated random field. .. note:: You don't have to override the :any:`CovModel.default_opt_arg`, but you will get a ValueError if you don't set it on creation. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.066 seconds) .. _sphx_glr_download_examples_02_cov_model_05_additional_para.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 05_additional_para.ipynb <05_additional_para.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 05_additional_para.py <05_additional_para.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 05_additional_para.zip <05_additional_para.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_