Skip to content

Commit

Permalink
Improve transioplot
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Oct 11, 2024
1 parent 97cf02c commit 29883de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions ext/GeoStatsFunctionsMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
module GeoStatsFunctionsMakieExt

using GeoStatsFunctions
using LinearAlgebra
using Unitful

import Makie
Expand Down
25 changes: 12 additions & 13 deletions ext/transioplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ function transioplot(
size=1.5,
maxlag=nothing
)
# effective ranges and variable levels
# effective ranges and labels
r = GeoStatsFunctions.ranges(t)
l = GeoStatsFunctions.levels(t)

# number of levels
# number of labels
L = length(l)

# retrieve maximum lag
Expand All @@ -27,27 +27,26 @@ function transioplot(
hs = range(zero(H), stop=H, length=100)
ts = t.(hs)

# approximate transiogram at h → ∞
t∞ = t(100H)
# relative proportions at h → ∞
p = normalize(diag(t(100H)), 1)

# base transiogram model
= ExponentialTransiogram(r, p)
t̂s = .(hs)

fig = Makie.Figure()
for i in 1:L, j in 1:L
lᵢ, lⱼ = l[i], l[j]
ax = Makie.Axis(fig[i, j])
ys = getindex.(ts, i, j)
Makie.lines!(ax, hs, ys, color=color, linewidth=size, label="$lᵢ$lⱼ")
Makie.lines!(ax, hs, getindex.(ts, i, j), color=color, linewidth=size, label="$lᵢ$lⱼ")
if i == j
# show mean length
Makie.lines!(ax, [zero(H), r[i]], [1.0, 0.0], color=color, linewidth=size, linestyle=:dash)
# show proportion
Makie.hlines!(ax, t∞[i, j], color=color, linewidth=size, linestyle=:dash)
Makie.hlines!(ax, p[i], color=color, linewidth=size, linestyle=:dash)
else
# show random transition model
pᵢ = t∞[i, i]
pⱼ = t∞[j, j]
tᵢᵢ = getindex.(ts, i, i)
rs = @. (1 - tᵢᵢ) * pⱼ / (1 - pᵢ)
Makie.lines!(ax, hs, rs, color=color, linewidth=size, linestyle=:dot)
# show base transiogram model
Makie.lines!(ax, hs, getindex.(t̂s, i, j), color=color, linewidth=size, linestyle=:dot)
end
Makie.axislegend(position=i == j ? :rt : :rb)
end
Expand Down

0 comments on commit 29883de

Please sign in to comment.