diff --git a/examples/02_cov_model/README.rst b/examples/02_cov_model/README.rst index 7c9c413c2..7df22e62d 100644 --- a/examples/02_cov_model/README.rst +++ b/examples/02_cov_model/README.rst @@ -64,6 +64,7 @@ The following standard covariance models are provided by GSTools Matern Stable Rational + Cubic Linear Circular Spherical diff --git a/gstools/__init__.py b/gstools/__init__.py index c29faee16..a23a8dfd2 100644 --- a/gstools/__init__.py +++ b/gstools/__init__.py @@ -55,8 +55,9 @@ Gaussian Exponential Matern - Rational Stable + Rational + Cubic Linear Circular Spherical @@ -127,8 +128,9 @@ Gaussian, Exponential, Matern, - Rational, Stable, + Rational, + Cubic, Linear, Circular, Spherical, @@ -155,8 +157,9 @@ "Gaussian", "Exponential", "Matern", - "Rational", "Stable", + "Rational", + "Cubic", "Linear", "Circular", "Spherical", diff --git a/gstools/covmodel/__init__.py b/gstools/covmodel/__init__.py index fef7ff4b0..d672e769a 100644 --- a/gstools/covmodel/__init__.py +++ b/gstools/covmodel/__init__.py @@ -29,8 +29,9 @@ Gaussian Exponential Matern - Rational Stable + Rational + Cubic Linear Circular Spherical @@ -54,8 +55,9 @@ Gaussian, Exponential, Matern, - Rational, Stable, + Rational, + Cubic, Linear, Circular, Spherical, @@ -75,8 +77,9 @@ "Gaussian", "Exponential", "Matern", - "Rational", "Stable", + "Rational", + "Cubic", "Linear", "Circular", "Spherical", diff --git a/gstools/covmodel/models.py b/gstools/covmodel/models.py index f7ac5a1fb..a41415cc9 100644 --- a/gstools/covmodel/models.py +++ b/gstools/covmodel/models.py @@ -12,6 +12,7 @@ Matern Stable Rational + Cubic Linear Circular Spherical @@ -33,6 +34,7 @@ "Matern", "Stable", "Rational", + "Cubic", "Linear", "Circular", "Spherical", @@ -433,6 +435,36 @@ def calc_integral_scale(self): # noqa: D102 ) +class Cubic(CovModel): + r"""The Cubic covariance model. + + A model with reverse curvature near the origin and a finite range of + correlation. + + Notes + ----- + This model is given by the following correlation function: + + .. math:: + \rho(r) = + \begin{cases} + 1- 7 \left(s\cdot\frac{r}{\ell}\right)^{2} + + \frac{35}{4} \left(s\cdot\frac{r}{\ell}\right)^{3} + - \frac{7}{2} \left(s\cdot\frac{r}{\ell}\right)^{5} + + \frac{3}{4} \left(s\cdot\frac{r}{\ell}\right)^{7} + & r<\frac{\ell}{s}\\ + 0 & r\geq\frac{\ell}{s} + \end{cases} + + Where the standard rescale factor is :math:`s=1`. + """ + + def cor(self, h): + """Spherical normalized correlation function.""" + h = np.minimum(np.abs(h, dtype=np.double), 1.0) + return 1.0 - 7 * h ** 2 + 8.75 * h ** 3 - 3.5 * h ** 5 + 0.75 * h ** 7 + + class Linear(CovModel): r"""The bounded linear covariance model. diff --git a/tests/test_covmodel.py b/tests/test_covmodel.py index d67301672..727ea64ae 100644 --- a/tests/test_covmodel.py +++ b/tests/test_covmodel.py @@ -13,8 +13,9 @@ CovModel, Gaussian, Exponential, - Rational, Stable, + Rational, + Cubic, Matern, Linear, Circular, @@ -68,8 +69,9 @@ def setUp(self): self.std_cov_models = [ Gaussian, Exponential, - Rational, Stable, + Rational, + Cubic, Matern, Linear, Circular,