How to use the gstools.covmodel.CovModel function in gstools

To help you get started, we’ve selected a few gstools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GeoStat-Framework / GSTools / gstools / covmodel / models.py View on Github external
1 + 0.5 / self.alpha * (r / self.len_scale) ** 2, -self.alpha
        )

    def calc_integral_scale(self):  # noqa: D102
        return (
            self.len_scale
            * np.sqrt(np.pi * self.alpha * 0.5)
            * sps.gamma(self.alpha - 0.5)
            / sps.gamma(self.alpha)
        )


# Stable Model ################################################################


class Stable(CovModel):
    r"""The stable covariance model.

    Notes
    -----
    This model is given by the following correlation function:

    .. math::
       \rho(r) =
       \exp\left(- \left(\frac{r}{\ell}\right)^{\alpha}\right)

    :math:`\alpha` is a shape parameter with :math:`\alpha\in(0,2]`

    Other Parameters
    ----------------
    **opt_arg
        The following parameters are covered by these keyword arguments
github GeoStat-Framework / GSTools / gstools / covmodel / models.py View on Github external
.. math::
           \rho(r) =
           \exp\left(- \left(\frac{r}{\ell}\right)^{\alpha}\right)
        """
        r = np.array(np.abs(r), dtype=np.double)
        return np.exp(-np.power(r / self.len_scale, self.alpha))

    def calc_integral_scale(self):  # noqa: D102
        return self.len_scale * sps.gamma(1.0 + 1.0 / self.alpha)


# Matérn Model ################################################################


class Matern(CovModel):
    r"""The Matérn covariance model.

    Notes
    -----
    This model is given by the following correlation function:

    .. math::
       \rho(r) =
       \frac{2^{1-\nu}}{\Gamma\left(\nu\right)} \cdot
       \left(\sqrt{\nu}\cdot\frac{r}{\ell}\right)^{\nu} \cdot
       \mathrm{K}_{\nu}\left(\sqrt{\nu}\cdot\frac{r}{\ell}\right)

    Where :math:`\Gamma` is the gamma function and :math:`\mathrm{K}_{\nu}`
    is the modified Bessel function of the second kind.

    :math:`\nu` is a shape parameter and should be >= 0.2.
github GeoStat-Framework / GSTools / gstools / covmodel / models.py View on Github external
2
            / np.pi
            * (
                np.arccos(r_low / self.len_scale)
                - r_low
                / self.len_scale
                * np.sqrt(1 - (r_low / self.len_scale) ** 2)
            )
        )
        return res


# Spherical Model #############################################################


class Spherical(CovModel):
    r"""The Spherical covariance model.

    This model is derived from the relative intersection area of
    two spheres in 3D, where the middle points have a distance of :math:`r`
    and the diameters are given by :math:`\ell`.

    Notes
    -----
    This model is given by the following correlation function:

    .. math::
       \rho(r) =
       \begin{cases}
       1-\frac{3}{2}\cdot\frac{r}{\ell} +
       \frac{1}{2}\cdot\left(\frac{r}{\ell}\right)^{3}
       & r<\ell\\
github GeoStat-Framework / GSTools / gstools / covmodel / tpl_models.py View on Github external
{\ell_{\mathrm{up}}^{2H}-\ell_{\mathrm{low}}^{2H}}
        """
        # if lower limit is 0 we use the simplified version (faster)
        if np.isclose(self.len_low, 0.0):
            return tplstable_cor(r, self.len_scale, self.hurst, 2)
        return (
            self.len_up ** (2 * self.hurst)
            * tplstable_cor(r, self.len_up, self.hurst, 2)
            - self.len_low ** (2 * self.hurst)
            * tplstable_cor(r, self.len_low, self.hurst, 2)
        ) / (
            self.len_up ** (2 * self.hurst) - self.len_low ** (2 * self.hurst)
        )


class TPLExponential(CovModel):
    r"""Truncated-Power-Law with Exponential modes.

    Notes
    -----
    The truncated power law is given by a superposition of scale-dependent
    variograms:

    .. math::
       \gamma_{\ell_{\mathrm{low}},\ell_{\mathrm{up}}}(r) =
       \intop_{\ell_{\mathrm{low}}}^{\ell_{\mathrm{up}}}
       \gamma(r,\lambda) \frac{\rm d \lambda}{\lambda}

    with `Exponential` modes on each scale:

    .. math::
       \gamma(r,\lambda) &=
github GeoStat-Framework / GSTools / gstools / covmodel / models.py View on Github external
0 & r\geq\ell
           \end{cases}
        """
        r = np.array(np.abs(r), dtype=np.double)
        res = np.zeros_like(r)
        r_ll = r < self.len_scale
        r_low = r[r_ll]
        res[r_ll] = (
            1.0
            - 3.0 / 2.0 * r_low / self.len_scale
            + 1.0 / 2.0 * (r_low / self.len_scale) ** 3
        )
        return res


class Intersection(CovModel):
    r"""The Intersection covariance model.

    This model is derived from the relative intersection area of
    two d-dimensional spheres,
    where the middle points have a distance of :math:`r`
    and the diameters are given by :math:`\ell`.

    In 1D this is the Linear model, in 2D this is the Circular model
    and in 3D this is the Spherical model.

    Notes
    -----
    This model is given by the following correlation functions.

    In 1D:
github GeoStat-Framework / GSTools / gstools / covmodel / tpl_models.py View on Github external
{\ell_{\mathrm{up}}^{2H}-\ell_{\mathrm{low}}^{2H}}
        """
        # if lower limit is 0 we use the simplified version (faster)
        if np.isclose(self.len_low, 0.0):
            return tplstable_cor(r, self.len_scale, self.hurst, 1)
        return (
            self.len_up ** (2 * self.hurst)
            * tplstable_cor(r, self.len_up, self.hurst, 1)
            - self.len_low ** (2 * self.hurst)
            * tplstable_cor(r, self.len_low, self.hurst, 1)
        ) / (
            self.len_up ** (2 * self.hurst) - self.len_low ** (2 * self.hurst)
        )


class TPLStable(CovModel):
    r"""Truncated-Power-Law with Stable modes.

    Notes
    -----
    The truncated power law is given by a superposition of scale-dependent
    variograms:

    .. math::
       \gamma_{\ell_{\mathrm{low}},\ell_{\mathrm{up}}}(r) =
       \intop_{\ell_{\mathrm{low}}}^{\ell_{\mathrm{up}}}
       \gamma(r,\lambda) \frac{\rm d \lambda}{\lambda}

    with `Stable` modes on each scale:

    .. math::
       \gamma(r,\lambda) &=
github GeoStat-Framework / GSTools / gstools / covmodel / models.py View on Github external
if self.dim == 2:
            return np.sqrt(np.pi) / self.len_scale * np.sqrt(-np.log(1.0 - u))
        return None

    def _has_ppf(self):
        # since the ppf is not analytical for dim=3, we have to state that
        return False if self.dim == 3 else True

    def calc_integral_scale(self):  # noqa: D102
        return self.len_scale


# Exponential Model ###########################################################


class Exponential(CovModel):
    r"""The Exponential covariance model.

    Notes
    -----
    This model is given by the following correlation function:

    .. math::
       \rho(r) =
       \exp\left(- \frac{r}{\ell} \right)

    """

    def correlation(self, r):
        r"""Exponential correlation function.

        .. math::
github GeoStat-Framework / GSTools / gstools / covmodel / tpl_models.py View on Github external
TPLStable
"""
# pylint: disable=C0103, E1101

import warnings
import numpy as np
from gstools.covmodel import CovModel
from gstools.tools.special import tplstable_cor

__all__ = ["TPLGaussian", "TPLExponential", "TPLStable"]


# Truncated power law #########################################################


class TPLGaussian(CovModel):
    r"""Truncated-Power-Law with Gaussian modes.

    Notes
    -----
    The truncated power law is given by a superposition of scale-dependent
    variograms:

    .. math::
       \gamma_{\ell_{\mathrm{low}},\ell_{\mathrm{up}}}(r) =
       \intop_{\ell_{\mathrm{low}}}^{\ell_{\mathrm{up}}}
       \gamma(r,\lambda) \frac{\rm d \lambda}{\lambda}

    with `Gaussian` modes on each scale:

    .. math::
       \gamma(r,\lambda) &=
github GeoStat-Framework / GSTools / gstools / covmodel / models.py View on Github external
* np.log(1.0 + (k * self.len_scale) ** 2 / self.nu)
            + sps.loggamma(self.nu + self.dim / 2.0)
            - sps.loggamma(self.nu)
            - self.dim * np.log(np.sqrt(self.nu))
        )

    def calc_integral_scale(self):  # noqa: D102
        return (
            self.len_scale * np.pi / np.sqrt(self.nu) / sps.beta(self.nu, 0.5)
        )


# Bounded linear Model ########################################################


class Linear(CovModel):
    r"""The bounded linear covariance model.

    This model is derived from the relative intersection area of
    two lines in 1D, where the middle points have a distance of :math:`r`
    and the line lengths are :math:`\ell`.

    Notes
    -----
    This model is given by the following correlation function:

    .. math::
       \rho(r) =
       \begin{cases}
       1-\frac{r}{\ell}
       & r<\ell\\
       0 & r\geq\ell
github GeoStat-Framework / GSTools / gstools / covmodel / models.py View on Github external
"Gaussian",
    "Exponential",
    "Matern",
    "Stable",
    "Rational",
    "Linear",
    "Circular",
    "Spherical",
    "Intersection",
]


# Gaussian Model ##############################################################


class Gaussian(CovModel):
    r"""The Gaussian covariance model.

    Notes
    -----
    This model is given by the following correlation function:

    .. math::
       \rho(r) =
       \exp\left(- \frac{\pi}{4} \cdot \left(\frac{r}{\ell}\right)^2\right)

    """

    def correlation(self, r):
        r"""Gaussian correlation function.

        .. math::