diff --git a/src/theoretical/variogram/circular.jl b/src/theoretical/variogram/circular.jl index f7b6797..0e06cd8 100644 --- a/src/theoretical/variogram/circular.jl +++ b/src/theoretical/variogram/circular.jl @@ -9,6 +9,7 @@ struct CircularVariogram{V,B} <: Variogram sill::V nugget::V ball::B + CircularVariogram(sill::V, nugget::V, ball::B) where {V,B} = new{float(V),B}(sill, nugget, ball) end CircularVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = CircularVariogram(sill, nugget, ball) diff --git a/src/theoretical/variogram/cubic.jl b/src/theoretical/variogram/cubic.jl index b664c98..ce8d25b 100644 --- a/src/theoretical/variogram/cubic.jl +++ b/src/theoretical/variogram/cubic.jl @@ -13,6 +13,7 @@ struct CubicVariogram{V,B} <: Variogram sill::V nugget::V ball::B + CubicVariogram(sill::V, nugget::V, ball::B) where {V,B} = new{float(V),B}(sill, nugget, ball) end CubicVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = CubicVariogram(sill, nugget, ball) diff --git a/src/theoretical/variogram/exponential.jl b/src/theoretical/variogram/exponential.jl index aacc0de..135257d 100644 --- a/src/theoretical/variogram/exponential.jl +++ b/src/theoretical/variogram/exponential.jl @@ -13,6 +13,7 @@ struct ExponentialVariogram{V,B} <: Variogram sill::V nugget::V ball::B + ExponentialVariogram(sill::V, nugget::V, ball::B) where {V,B} = new{float(V),B}(sill, nugget, ball) end ExponentialVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = ExponentialVariogram(sill, nugget, ball) diff --git a/src/theoretical/variogram/gaussian.jl b/src/theoretical/variogram/gaussian.jl index 63d8c13..179c99a 100644 --- a/src/theoretical/variogram/gaussian.jl +++ b/src/theoretical/variogram/gaussian.jl @@ -13,6 +13,7 @@ struct GaussianVariogram{V,B} <: Variogram sill::V nugget::V ball::B + GaussianVariogram(sill::V, nugget::V, ball::B) where {V,B} = new{float(V),B}(sill, nugget, ball) end GaussianVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = GaussianVariogram(sill, nugget, ball) diff --git a/src/theoretical/variogram/matern.jl b/src/theoretical/variogram/matern.jl index 94de9f6..5e23bb9 100644 --- a/src/theoretical/variogram/matern.jl +++ b/src/theoretical/variogram/matern.jl @@ -15,6 +15,8 @@ struct MaternVariogram{V,O,B} <: Variogram nugget::V order::O ball::B + MaternVariogram(sill::V, nugget::V, order::O, ball::B) where {V,O,B} = + new{float(V),float(O),B}(sill, nugget, order, ball) end MaternVariogram(ball; sill=1.0, nugget=zero(typeof(sill)), order=1.0) = MaternVariogram(sill, nugget, order, ball) diff --git a/src/theoretical/variogram/nugget.jl b/src/theoretical/variogram/nugget.jl index 887b286..4b1b7e3 100644 --- a/src/theoretical/variogram/nugget.jl +++ b/src/theoretical/variogram/nugget.jl @@ -9,6 +9,7 @@ A pure nugget effect variogram with nugget `n`. """ struct NuggetEffect{V} <: Variogram nugget::V + NuggetEffect(nugget::V) where {V} = new{float(V)}(nugget) end NuggetEffect(; nugget=1.0) = NuggetEffect(nugget) diff --git a/src/theoretical/variogram/pentaspherical.jl b/src/theoretical/variogram/pentaspherical.jl index 1e372dd..cf3af98 100644 --- a/src/theoretical/variogram/pentaspherical.jl +++ b/src/theoretical/variogram/pentaspherical.jl @@ -13,6 +13,7 @@ struct PentasphericalVariogram{V,B} <: Variogram sill::V nugget::V ball::B + PentasphericalVariogram(sill::V, nugget::V, ball::B) where {V,B} = new{float(V),B}(sill, nugget, ball) end PentasphericalVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = PentasphericalVariogram(sill, nugget, ball) diff --git a/src/theoretical/variogram/power.jl b/src/theoretical/variogram/power.jl index afe8e2e..0c67956 100644 --- a/src/theoretical/variogram/power.jl +++ b/src/theoretical/variogram/power.jl @@ -11,6 +11,7 @@ struct PowerVariogram{V,E} <: Variogram scaling::V nugget::V exponent::E + PowerVariogram(scaling::V, nugget::V, exponent::E) where {V,E} = new{float(V),float(E)}(scaling, nugget, exponent) end PowerVariogram(; scaling=1.0, nugget=zero(typeof(scaling)), exponent=1.0) = PowerVariogram(scaling, nugget, exponent) diff --git a/src/theoretical/variogram/sinehole.jl b/src/theoretical/variogram/sinehole.jl index 5cf8ffe..2924892 100644 --- a/src/theoretical/variogram/sinehole.jl +++ b/src/theoretical/variogram/sinehole.jl @@ -13,6 +13,7 @@ struct SineHoleVariogram{V,B} <: Variogram sill::V nugget::V ball::B + SineHoleVariogram(sill::V, nugget::V, ball::B) where {V,B} = new{float(V),B}(sill, nugget, ball) end SineHoleVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = SineHoleVariogram(sill, nugget, ball) diff --git a/src/theoretical/variogram/spherical.jl b/src/theoretical/variogram/spherical.jl index 3421089..5f1d7e0 100644 --- a/src/theoretical/variogram/spherical.jl +++ b/src/theoretical/variogram/spherical.jl @@ -13,6 +13,7 @@ struct SphericalVariogram{V,B} <: Variogram sill::V nugget::V ball::B + SphericalVariogram(sill::V, nugget::V, ball::B) where {V,B} = new{float(V),B}(sill, nugget, ball) end SphericalVariogram(ball; sill=1.0, nugget=zero(typeof(sill))) = SphericalVariogram(sill, nugget, ball) diff --git a/test/theoretical/variogram.jl b/test/theoretical/variogram.jl index cc2b030..6d9154c 100644 --- a/test/theoretical/variogram.jl +++ b/test/theoretical/variogram.jl @@ -189,6 +189,39 @@ g = GeoStatsFunctions.scale(γ, 2) @test g == γ + # convert parameters to float + γ = CircularVariogram(sill=1, nugget=1) + @test sill(γ) isa Float64 + @test nugget(γ) isa Float64 + γ = CubicVariogram(sill=1, nugget=1) + @test sill(γ) isa Float64 + @test nugget(γ) isa Float64 + γ = ExponentialVariogram(sill=1, nugget=1) + @test sill(γ) isa Float64 + @test nugget(γ) isa Float64 + γ = GaussianVariogram(sill=1, nugget=1) + @test sill(γ) isa Float64 + @test nugget(γ) isa Float64 + γ = MaternVariogram(sill=1, nugget=1, order=1) + @test sill(γ) isa Float64 + @test nugget(γ) isa Float64 + @test γ.order isa Float64 + γ = NuggetEffect(nugget=1) + @test nugget(γ) isa Float64 + γ = PentasphericalVariogram(sill=1, nugget=1) + @test sill(γ) isa Float64 + @test nugget(γ) isa Float64 + γ = PowerVariogram(scaling=1, nugget=1, exponent=1) + @test γ.scaling isa Float64 + @test nugget(γ) isa Float64 + @test γ.exponent isa Float64 + γ = SineHoleVariogram(sill=1, nugget=1) + @test sill(γ) isa Float64 + @test nugget(γ) isa Float64 + γ = SphericalVariogram(sill=1, nugget=1) + @test sill(γ) isa Float64 + @test nugget(γ) isa Float64 + # shows γ = CircularVariogram() @test sprint(show, γ) == "CircularVariogram(sill: 1.0, nugget: 0.0, range: 1.0 m, distance: Euclidean)"