This repository has been archived by the owner on Jan 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpartition.jl
57 lines (45 loc) · 2.26 KB
/
partition.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# ------------------------------------------------------------------
# Licensed under the ISC License. See LICENSE in the project root.
# ------------------------------------------------------------------
"""
EmpiricalVariogram(partition, var₁, var₂=var₁; [parameters])
Compute the empirical (cross-)variogram of the spatial `partition` for
variables `var₁` and `var₂`.
## References
* Hoffimann, J and Zadrozny, B. 2019. [Efficient variography with partition variograms]
(https://www.sciencedirect.com/science/article/pii/S0098300419302936)
"""
function EmpiricalVariogram(partition::SpatialPartition,
var₁::Symbol, var₂::Symbol=var₁; kwargs...)
# retain spatial data with at least 2 points
filtered = Iterators.filter(d -> npoints(d) > 1, partition)
@assert !isempty(filtered) "invalid partition of spatial data"
f(d) = EmpiricalVariogram(d, var₁, var₂; kwargs...)
reduce(merge, Map(f), collect(filtered))
end
"""
DirectionalVariogram(direction, sdata, var₁, var₂=var₁; dtol=1e-6, [parameters])
Computes the empirical (cross-)variogram for the variables `var₁` and `var₂` stored in
spatial data `sdata` along a given `direction`.
Optional parameters include the parameters for [`EmpiricalVariogram`](@ref) and the
parameters for [`DirectionPartitioner`](@ref).
"""
function DirectionalVariogram(direction::NTuple, sdata,
var₁::Symbol, var₂::Symbol=var₁;
dtol=1e-6, kwargs...)
p = partition(sdata, DirectionPartitioner(direction; tol=dtol))
EmpiricalVariogram(p, var₁, var₂; kwargs...)
end
"""
PlanarVariogram(normal, sdata, var₁, var₂=var₁; ntol=1e-6, [parameters])
Computes the empirical (cross-)variogram for the variables `var₁` and `var₂` stored in
spatial data `sdata` along a plane perpendicular to a `normal` direction.
Optional parameters include the parameters for [`EmpiricalVariogram`](@ref) and the
parameters for [`PlanePartitioner`](@ref).
"""
function PlanarVariogram(normal::NTuple, sdata,
var₁::Symbol, var₂::Symbol=var₁;
ntol=1e-6, kwargs...)
p = partition(sdata, PlanePartitioner(normal; tol=ntol))
EmpiricalVariogram(p, var₁, var₂; kwargs...)
end