Skip to content

Commit

Permalink
Merge pull request #14 from JuliaEarth/up-makie-ext
Browse files Browse the repository at this point in the history
Update Makie.jl extension
  • Loading branch information
eliascarv authored May 29, 2024
2 parents bab58b6 + 32ef5b8 commit 31e7dcb
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 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 Unitful

import Makie
import GeoStatsFunctions: varioplot, varioplot!
Expand Down Expand Up @@ -43,8 +44,8 @@ function Makie.plot!(plot::VarioPlot{<:Tuple{EmpiricalVariogram}})

# get the data
xyn = Makie.@lift values($γ)
x = Makie.@lift $xyn[1]
y = Makie.@lift $xyn[2]
x = Makie.@lift ustrip.($xyn[1])
y = Makie.@lift ustrip.($xyn[2])
n = Makie.@lift $xyn[3]

# discard empty bins
Expand Down Expand Up @@ -86,12 +87,12 @@ function Makie.plot!(plot::VarioPlot{<:Tuple{EmpiricalVarioplane}})
θs = Makie.@lift $v.θs

# polar radius
rs = Makie.@lift values($γs[1])[1]
rs = Makie.@lift ustrip.(values($γs[1])[1])

# variogram values for all variograms
Z = Makie.@lift let
zs = map($γs) do γ
_, zs, __ = values(γ)
zs = ustrip.(values)[2])

# handle NaN values (i.e. empty bins)
isnan(zs[1]) && (zs[1] = 0)
Expand Down Expand Up @@ -119,7 +120,7 @@ function Makie.plot!(plot::VarioPlot{<:Tuple{EmpiricalVarioplane}})

# show model range
if rshow[]
ls = Makie.@lift [range(GeoStatsFunctions.fit($rmodel, γ)) for γ in $γs]
ls = Makie.@lift [ustrip(range(GeoStatsFunctions.fit($rmodel, γ))) for γ in $γs]
ls = Makie.@lift [$ls; $ls]
zs = Makie.@lift fill(maximum($Z) + 1, length($ls))
Makie.lines!(plot, θs, ls, zs, color=plot[:rcolor])
Expand Down Expand Up @@ -147,15 +148,15 @@ function Makie.plot!(plot::VarioPlot{<:Tuple{Variogram}})

# start at 1e-6 instead of 0 to avoid
# nugget artifact in visualization
x = Makie.@lift range(1e-6, stop=$L, length=100)
x = Makie.@lift range(1e-6, stop=ustrip($L), length=100)
y = Makie.@lift $γ.($x)

# visualize variogram
Makie.lines!(plot, x, y, color=plot[:vcolor])
end

_maxlag::Variogram) = 3range(γ)
_maxlag::PowerVariogram) = 3.0
_maxlag::NuggetEffect) = 3.0
_maxlag::PowerVariogram) = 3.0u"m"
_maxlag::NuggetEffect) = 3.0u"m"

end

0 comments on commit 31e7dcb

Please sign in to comment.