Skip to content

Commit

Permalink
Merge pull request #122 from GeoStat-Framework/add_cubic_model
Browse files Browse the repository at this point in the history
Add Cubic covariance model
  • Loading branch information
MuellerSeb authored Dec 9, 2020
2 parents b56a1b3 + d9cd3d0 commit 473ce01
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 8 deletions.
1 change: 1 addition & 0 deletions examples/02_cov_model/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ The following standard covariance models are provided by GSTools
Matern
Stable
Rational
Cubic
Linear
Circular
Spherical
Expand Down
9 changes: 6 additions & 3 deletions gstools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@
Gaussian
Exponential
Matern
Rational
Stable
Rational
Cubic
Linear
Circular
Spherical
Expand Down Expand Up @@ -127,8 +128,9 @@
Gaussian,
Exponential,
Matern,
Rational,
Stable,
Rational,
Cubic,
Linear,
Circular,
Spherical,
Expand All @@ -155,8 +157,9 @@
"Gaussian",
"Exponential",
"Matern",
"Rational",
"Stable",
"Rational",
"Cubic",
"Linear",
"Circular",
"Spherical",
Expand Down
9 changes: 6 additions & 3 deletions gstools/covmodel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
Gaussian
Exponential
Matern
Rational
Stable
Rational
Cubic
Linear
Circular
Spherical
Expand All @@ -54,8 +55,9 @@
Gaussian,
Exponential,
Matern,
Rational,
Stable,
Rational,
Cubic,
Linear,
Circular,
Spherical,
Expand All @@ -75,8 +77,9 @@
"Gaussian",
"Exponential",
"Matern",
"Rational",
"Stable",
"Rational",
"Cubic",
"Linear",
"Circular",
"Spherical",
Expand Down
32 changes: 32 additions & 0 deletions gstools/covmodel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Matern
Stable
Rational
Cubic
Linear
Circular
Spherical
Expand All @@ -33,6 +34,7 @@
"Matern",
"Stable",
"Rational",
"Cubic",
"Linear",
"Circular",
"Spherical",
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions tests/test_covmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
CovModel,
Gaussian,
Exponential,
Rational,
Stable,
Rational,
Cubic,
Matern,
Linear,
Circular,
Expand Down Expand Up @@ -68,8 +69,9 @@ def setUp(self):
self.std_cov_models = [
Gaussian,
Exponential,
Rational,
Stable,
Rational,
Cubic,
Matern,
Linear,
Circular,
Expand Down

0 comments on commit 473ce01

Please sign in to comment.