-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issues with heterogeneous soil profile types
- Loading branch information
1 parent
5b5e700
commit c49143c
Showing
10 changed files
with
47 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "CryoGrid" | ||
uuid = "a535b82e-5f3d-4d97-8b0b-d6483f5bebd5" | ||
authors = ["Brian Groenke <[email protected]>", "Jan Nitzbon <[email protected]>", "Moritz Langer <[email protected]>"] | ||
version = "0.20.2" | ||
version = "0.20.3" | ||
|
||
[deps] | ||
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
struct ProfileKnot{D,V} | ||
depth::D | ||
value::V | ||
end | ||
Base.iterate(knot::ProfileKnot) = iterate((knot.depth, knot.value)) | ||
Base.iterate(knot::ProfileKnot, state) = iterate((knot.depth, knot.value), state) | ||
Base.show(io::IO, knot::ProfileKnot) = print(io, "$(knot.depth): $(knot.value)") | ||
struct Profile{N,V,D} | ||
knots::NTuple{N,ProfileKnot{D,V}} | ||
Profile(::Tuple{}) = new{0,Nothing,Nothing}(()) | ||
Profile(knots::Tuple{Vararg{ProfileKnot{D,V},N}}) where {N,D,V} = new{N,V,D}(knots) | ||
Profile(pairs::Tuple{Vararg{Pair}}) = Profile(map(Base.splat(ProfileKnot), pairs)) | ||
""" | ||
Profile{N,idxTypes,valTypes} | ||
Represents a "profile" of values indexed typically over depth, i.e: | ||
x₁: value 1 | ||
x₂: value 2 | ||
... | ||
where xᵢ are the indices. | ||
""" | ||
struct Profile{N,idxTypes,valTypes} | ||
indices::idxTypes | ||
values::valTypes | ||
Profile(::Tuple{}) = new{0,Tuple{},Tuple{}}((),()) | ||
Profile(indices::NTuple{N,Any}, values::NTuple{N,Any}) where {N} = new{N,typeof(indices),typeof(values)}(indices, values) | ||
Profile(pairs::Tuple{Vararg{Pair}}) = Profile(map(first, pairs), map(last, pairs)) | ||
Profile(pairs::Pair...) = Profile(pairs) | ||
end | ||
function Base.show(io::IO, mime::MIME"text/plain", profile::Profile) | ||
for knot in profile | ||
show(io, mime, knot) | ||
for (d,v) in profile | ||
print("$d ") | ||
show(io, mime, v) | ||
println(io) | ||
end | ||
end | ||
Base.length(::Profile{N}) where N = N | ||
Base.iterate(profile::Profile) = iterate(profile.knots) | ||
Base.iterate(profile::Profile, state) = iterate(profile.knots, state) | ||
Base.map(f, profile::Profile) = Profile(map(knot -> ProfileKnot(knot.depth, f(knot.value)), profile.knots)) | ||
Base.getindex(profile::Profile, itrv::Interval) = Profile(Tuple(knot for knot in profile.knots if knot.depth ∈ itrv)) | ||
Base.getindex(profile::Profile, i::Int) = profile.knots[i] | ||
Base.getindex(profile::Profile, i) = Profile(profile.knots[i]) | ||
Base.lastindex(profile::Profile) = lastindex(profile.knots) | ||
StructTypes.StructType(::Type{<:Profile}) = StructTypes.UnorderedStruct() | ||
Base.keys(profile::Profile) = profile.indices | ||
Base.values(profile::Profile) = profile.values | ||
Base.iterate(profile::Profile) = iterate(map(Pair, profile.indices, profile.values)) | ||
Base.iterate(profile::Profile, state) = iterate(map(Pair, profile.indices, profile.values), state) | ||
Base.map(f, profile::Profile) = Profile(map((i,v) -> i => f(v), profile.indices, profile.values)) | ||
Base.getindex(profile::Profile, itrv::Interval) = Profile(Tuple(i => v for (i,v) in profile if i ∈ itrv)) | ||
Base.getindex(profile::Profile, i::Int) = profile.indices[i] => profile.values[i] | ||
Base.getindex(profile::Profile, i) = Profile(profile.indices[i], profile.values[i]) | ||
Base.lastindex(profile::Profile) = lastindex(profile.indices) | ||
StructTypes.StructType(::Type{<:Profile}) = StructTypes.UnorderedStruct() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters