diff --git a/src/variogram/circular.jl b/src/variogram/circular.jl index 8956d83..9b0ab5d 100644 --- a/src/variogram/circular.jl +++ b/src/variogram/circular.jl @@ -15,6 +15,10 @@ CircularVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = CircularVariogram CircularVariogram(; range=1.0, sill=1.0, nugget=zero(typeof(sill))) = CircularVariogram(sill, nugget, MetricBall(range)) +variotype(::CircularVariogram) = CircularVariogram + +isstationary(::Type{<:CircularVariogram}) = true + function (γ::CircularVariogram)(h) r = radius(γ.ball) s = γ.sill @@ -22,7 +26,3 @@ function (γ::CircularVariogram)(h) v = h ≤ r ? 1 - (2 / π) * acos(h / r) + (2h / (π * r)) * sqrt(1 - (h^2 / r^2)) : one(h) (s - n) * v + (h > zero(h)) * n end - -variotype(::CircularVariogram) = CircularVariogram - -isstationary(::Type{<:CircularVariogram}) = true diff --git a/src/variogram/cubic.jl b/src/variogram/cubic.jl index 15f5483..06e8421 100644 --- a/src/variogram/cubic.jl +++ b/src/variogram/cubic.jl @@ -19,6 +19,10 @@ CubicVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = CubicVariogram(sill, CubicVariogram(; range=1.0, sill=1.0, nugget=zero(typeof(sill))) = CubicVariogram(sill, nugget, MetricBall(range)) +variotype(::CubicVariogram) = CubicVariogram + +isstationary(::Type{<:CubicVariogram}) = true + function (γ::CubicVariogram)(h::T) where {T} r = radius(γ.ball) s = γ.sill @@ -33,7 +37,3 @@ function (γ::CubicVariogram)(h::T) where {T} (h < r) * (s - n) * s1 + (h ≥ r) * (s - n) * s2 + (h > 0) * n end - -variotype(::CubicVariogram) = CubicVariogram - -isstationary(::Type{<:CubicVariogram}) = true diff --git a/src/variogram/exponential.jl b/src/variogram/exponential.jl index 4f07718..ec57bba 100644 --- a/src/variogram/exponential.jl +++ b/src/variogram/exponential.jl @@ -20,13 +20,13 @@ ExponentialVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = ExponentialVar ExponentialVariogram(; range=1.0, sill=1.0, nugget=zero(typeof(sill))) = ExponentialVariogram(sill, nugget, MetricBall(range)) +variotype(::ExponentialVariogram) = ExponentialVariogram + +isstationary(::Type{<:ExponentialVariogram}) = true + function (γ::ExponentialVariogram)(h) r = radius(γ.ball) s = γ.sill n = γ.nugget (s - n) * (1 - exp(-3(h / r))) + (h > 0) * n end - -variotype(::ExponentialVariogram) = ExponentialVariogram - -isstationary(::Type{<:ExponentialVariogram}) = true diff --git a/src/variogram/gaussian.jl b/src/variogram/gaussian.jl index 1eb5edf..2d1c110 100644 --- a/src/variogram/gaussian.jl +++ b/src/variogram/gaussian.jl @@ -19,6 +19,10 @@ GaussianVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = GaussianVariogram GaussianVariogram(; range=1.0, sill=1.0, nugget=zero(typeof(sill))) = GaussianVariogram(sill, nugget, MetricBall(range)) +variotype(::GaussianVariogram) = GaussianVariogram + +isstationary(::Type{<:GaussianVariogram}) = true + function (γ::GaussianVariogram)(h) # add small eps to nugget # for numerical stability @@ -27,7 +31,3 @@ function (γ::GaussianVariogram)(h) n = γ.nugget + typeof(s)(1e-6) (s - n) * (1 - exp(-3(h / r)^2)) + (h > 0) * n end - -variotype(::GaussianVariogram) = GaussianVariogram - -isstationary(::Type{<:GaussianVariogram}) = true diff --git a/src/variogram/matern.jl b/src/variogram/matern.jl index 86cdf3e..7ddf81c 100644 --- a/src/variogram/matern.jl +++ b/src/variogram/matern.jl @@ -22,6 +22,10 @@ MaternVariogram(ball; sill=1.0, nugget=zero(typeof(sill)), order=1.0) = MaternVa MaternVariogram(; range=1.0, sill=1.0, nugget=zero(typeof(sill)), order=1.0) = MaternVariogram(sill, nugget, order, MetricBall(range)) +variotype(::MaternVariogram) = MaternVariogram + +isstationary(::Type{<:MaternVariogram}) = true + function (γ::MaternVariogram)(h::T) where {T} r = radius(γ.ball) s = γ.sill @@ -38,7 +42,3 @@ function (γ::MaternVariogram)(h::T) where {T} (s - n) * (1 - 2^(1 - ν) / Γ * δ^ν * Β) + (h > 0) * n end - -variotype(::MaternVariogram) = MaternVariogram - -isstationary(::Type{<:MaternVariogram}) = true diff --git a/src/variogram/nugget.jl b/src/variogram/nugget.jl index 8d934e4..6e3bbba 100644 --- a/src/variogram/nugget.jl +++ b/src/variogram/nugget.jl @@ -13,16 +13,16 @@ end NuggetEffect(; nugget=1.0) = NuggetEffect(nugget) -(γ::NuggetEffect)(h) = (h > 0) * γ.nugget +variotype(::NuggetEffect) = NuggetEffect -(γ::NuggetEffect)(u::Point, v::Point) = ifelse(u == v, zero(γ.nugget), γ.nugget) +isstationary(::Type{<:NuggetEffect}) = true -Base.range(::NuggetEffect{T}) where {T} = zero(T) +isisotropic(::NuggetEffect) = true sill(γ::NuggetEffect) = γ.nugget -variotype(::NuggetEffect) = NuggetEffect +Base.range(::NuggetEffect{T}) where {T} = zero(T) -isstationary(::Type{<:NuggetEffect}) = true +(γ::NuggetEffect)(h) = (h > 0) * γ.nugget -isisotropic(::NuggetEffect) = true +(γ::NuggetEffect)(u::Point, v::Point) = ifelse(u == v, zero(γ.nugget), γ.nugget) diff --git a/src/variogram/pentaspherical.jl b/src/variogram/pentaspherical.jl index 5b817a0..a423a57 100644 --- a/src/variogram/pentaspherical.jl +++ b/src/variogram/pentaspherical.jl @@ -20,6 +20,10 @@ PentasphericalVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = Pentaspheri PentasphericalVariogram(; range=1.0, sill=1.0, nugget=zero(typeof(sill))) = PentasphericalVariogram(sill, nugget, MetricBall(range)) +variotype(::PentasphericalVariogram) = PentasphericalVariogram + +isstationary(::Type{<:PentasphericalVariogram}) = true + function (γ::PentasphericalVariogram)(h::T) where {T} r = radius(γ.ball) s = γ.sill @@ -34,7 +38,3 @@ function (γ::PentasphericalVariogram)(h::T) where {T} (h < r) * (s - n) * s1 + (h ≥ r) * (s - n) * s2 + (h > 0) * n end - -variotype(::PentasphericalVariogram) = PentasphericalVariogram - -isstationary(::Type{<:PentasphericalVariogram}) = true diff --git a/src/variogram/power.jl b/src/variogram/power.jl index b976193..3ff349e 100644 --- a/src/variogram/power.jl +++ b/src/variogram/power.jl @@ -15,6 +15,12 @@ end PowerVariogram(; scaling=1.0, nugget=zero(typeof(scaling)), exponent=1.0) = PowerVariogram(scaling, nugget, exponent) +variotype(::PowerVariogram) = PowerVariogram + +isstationary(::Type{<:PowerVariogram}) = false + +isisotropic(::PowerVariogram) = true + function (γ::PowerVariogram)(h) s = γ.scaling a = γ.exponent @@ -29,9 +35,3 @@ function (γ::PowerVariogram)(u::Point, v::Point) h = evaluate(d, x, y) γ(h) end - -variotype(::PowerVariogram) = PowerVariogram - -isstationary(::Type{<:PowerVariogram}) = false - -isisotropic(::PowerVariogram) = true diff --git a/src/variogram/sinehole.jl b/src/variogram/sinehole.jl index 1faf9fa..5664abe 100644 --- a/src/variogram/sinehole.jl +++ b/src/variogram/sinehole.jl @@ -19,6 +19,10 @@ SineHoleVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = SineHoleVariogram SineHoleVariogram(; range=1.0, sill=1.0, nugget=zero(typeof(sill))) = SineHoleVariogram(sill, nugget, MetricBall(range)) +variotype(::SineHoleVariogram) = SineHoleVariogram + +isstationary(::Type{<:SineHoleVariogram}) = true + function (γ::SineHoleVariogram)(h::T) where {T} r = radius(γ.ball) s = γ.sill @@ -31,7 +35,3 @@ function (γ::SineHoleVariogram)(h::T) where {T} (s - n) * (1 - sin(c * h′ / r) / (c * h′ / r)) + (h′ > 0) * n end - -variotype(::SineHoleVariogram) = SineHoleVariogram - -isstationary(::Type{<:SineHoleVariogram}) = true diff --git a/src/variogram/spherical.jl b/src/variogram/spherical.jl index ba3a999..b7bbdd4 100644 --- a/src/variogram/spherical.jl +++ b/src/variogram/spherical.jl @@ -20,6 +20,10 @@ SphericalVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = SphericalVariogr SphericalVariogram(; range=1.0, sill=1.0, nugget=zero(typeof(sill))) = SphericalVariogram(sill, nugget, MetricBall(range)) +variotype(::SphericalVariogram) = SphericalVariogram + +isstationary(::Type{<:SphericalVariogram}) = true + function (γ::SphericalVariogram)(h::T) where {T} r = radius(γ.ball) s = γ.sill @@ -33,7 +37,3 @@ function (γ::SphericalVariogram)(h::T) where {T} (h < r) * (s - n) * s1 + (h ≥ r) * (s - n) * s2 + (h > 0) * n end - -variotype(::SphericalVariogram) = SphericalVariogram - -isstationary(::Type{<:SphericalVariogram}) = true