Skip to content

Commit

Permalink
Refactor files
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Oct 15, 2024
1 parent 5c98686 commit 7a66c72
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 56 deletions.
1 change: 0 additions & 1 deletion src/empirical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ include("empirical/estimators.jl")
include("empirical/algorithms.jl")

include("empirical/variogram.jl")
include("empirical/partition.jl")
include("empirical/varioplane.jl")
55 changes: 0 additions & 55 deletions src/empirical/partition.jl

This file was deleted.

52 changes: 52 additions & 0 deletions src/empirical/variogram.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,58 @@ function EmpiricalVariogram(
EmpiricalVariogram(abscissa, ordinate, counts, distance, estim)
end

"""
EmpiricalVariogram(partition, var₁, var₂=var₁; [parameters])
Compute the empirical (cross-)variogram of the geospatial `partition` for
variables `var₁` and `var₂` as described in Hoffimann & Zadrozny 2019.
Optionally, forward `parameters` for the underlying [`EmpiricalVariogram`](@ref).
## References
* Hoffimann, J and Zadrozny, B. 2019. [Efficient variography with partition variograms]
(https://www.sciencedirect.com/science/article/pii/S0098300419302936)
"""
function EmpiricalVariogram(partition::Partition, var₁, var₂=var₁; kwargs...)
# retain geospatial data with at least 2 points
filtered = Iterators.filter(d -> nelements(domain(d)) > 1, partition)

@assert !isempty(filtered) "invalid partition of geospatial data"

γ(d) = EmpiricalVariogram(d, var₁, var₂; kwargs...)
tmapreduce(γ, merge, collect(filtered))
end

"""
DirectionalVariogram(direction, data, var₁, var₂=var₁; dtol=1e-6u"m", [parameters])
Computes the empirical (cross-)variogram for the variables `var₁` and `var₂` stored in
geospatial `data` along a given `direction` with band tolerance `dtol` in length units.
Optionally, forward `parameters` for the underlying [`EmpiricalVariogram`](@ref).
"""
function DirectionalVariogram(dir, data::AbstractGeoTable, var₁, var₂=var₁; dtol=1e-6u"m", kwargs...)
rng = MersenneTwister(123)
Π = partition(rng, data, DirectionPartition(dir; tol=dtol))
EmpiricalVariogram(Π, var₁, var₂; kwargs...)
end

"""
PlanarVariogram(normal, data, var₁, var₂=var₁; ntol=1e-6u"m", [parameters])
Computes the empirical (cross-)variogram for the variables `var₁` and `var₂` stored in
geospatial `data` along a plane perpendicular to a `normal` direction with plane
tolerance `ntol` in length units.
Optionally, forward `parameters` for the underlying [`EmpiricalVariogram`](@ref).
"""
function PlanarVariogram(normal, data::AbstractGeoTable, var₁, var₂=var₁; ntol=1e-6u"m", kwargs...)
rng = MersenneTwister(123)
Π = partition(rng, data, PlanePartition(normal; tol=ntol))
EmpiricalVariogram(Π, var₁, var₂; kwargs...)
end

"""
values(γ)
Expand Down

0 comments on commit 7a66c72

Please sign in to comment.