Skip to content

Commit

Permalink
Refactor plot recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Feb 11, 2025
1 parent 5305f5b commit d947604
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/GeoStatsFunctionsMakieExt/funplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function funplot(
ns = f.counts

# retrieve maximum lag
hmax = isnothing(maxlag) ? last(hs) : _addunit(maxlag, u"m")
hmax = isnothing(maxlag) ? _maxlag(f) : _addunit(maxlag, u"m")

# discard empty bins
hs = hs[ns .> 0]
Expand Down
10 changes: 10 additions & 0 deletions ext/GeoStatsFunctionsMakieExt/surfplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,19 @@ function surfplot(
# function values
zs = f.zs

# maximum lag
hmax = isnothing(maxlag) ? _maxlag(f) : _addunit(maxlag, u"m")

# exploit symmetry
if issymmetric(f)
θs = range(0, stop=2π, length=2length(θs))
zs = [zs; zs]
end

# discard above maximum lag
is = findall((hmax), rs)
rs = rs[is]

# hide hole at center
rs = [zero(eltype(rs)); rs]

Expand All @@ -124,6 +131,9 @@ function surfplot(
Zᵢⱼ = _istransiogram(f) ? getindex.(zs, i, j) : zs
Z = reduce(hcat, Zᵢⱼ)

# discard above maximum lag
Z = Z[is, :]

# hide hole at center
Z = [Z[1:1, :]; Z]

Expand Down
2 changes: 2 additions & 0 deletions ext/GeoStatsFunctionsMakieExt/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ _maxlag(::PowerVariogram) = 3.0u"m"
_maxlag(::NuggetEffect) = 3.0u"m"
_maxlag(t::MatrixExponentialTransiogram) = 3maximum(meanlengths(t))
_maxlag(t::PiecewiseLinearTransiogram) = last(t.abscissas)
_maxlag(f::EmpiricalGeoStatsFunction) = last(f.abscissas)
_maxlag(f::EmpiricalGeoStatsSurface) = last(f.rs)

_addunit(x::Number, u) = x * u
_addunit(x::Len, _) = x
Expand Down

0 comments on commit d947604

Please sign in to comment.