From d9476047e8a49bba0d56a31991b36bbcf789c982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Hoffimann?= Date: Tue, 11 Feb 2025 11:19:36 -0300 Subject: [PATCH] Refactor plot recipes --- ext/GeoStatsFunctionsMakieExt/funplot.jl | 2 +- ext/GeoStatsFunctionsMakieExt/surfplot.jl | 10 ++++++++++ ext/GeoStatsFunctionsMakieExt/utils.jl | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ext/GeoStatsFunctionsMakieExt/funplot.jl b/ext/GeoStatsFunctionsMakieExt/funplot.jl index 6fc382d..cad2342 100644 --- a/ext/GeoStatsFunctionsMakieExt/funplot.jl +++ b/ext/GeoStatsFunctionsMakieExt/funplot.jl @@ -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] diff --git a/ext/GeoStatsFunctionsMakieExt/surfplot.jl b/ext/GeoStatsFunctionsMakieExt/surfplot.jl index d8dd19c..d02fb6d 100644 --- a/ext/GeoStatsFunctionsMakieExt/surfplot.jl +++ b/ext/GeoStatsFunctionsMakieExt/surfplot.jl @@ -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] @@ -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] diff --git a/ext/GeoStatsFunctionsMakieExt/utils.jl b/ext/GeoStatsFunctionsMakieExt/utils.jl index c5db111..997129c 100644 --- a/ext/GeoStatsFunctionsMakieExt/utils.jl +++ b/ext/GeoStatsFunctionsMakieExt/utils.jl @@ -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