-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Basin / subgrid_time
table
#1975
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you document the construction of the new interpolation objects? That inner loop is opaque to me (with complexted indexlookups etc).
subgrid_id::Vector{Int32} | ||
basin_index::Vector{Int32} | ||
interpolations::Vector{ScalarInterpolation} | ||
# level of each subgrid (static and dynamic) ordered by subgrid_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# level of each subgrid (static and dynamic) ordered by subgrid_id | |
# current level of each subgrid (static and dynamic) ordered by subgrid_id |
level::Vector{Float64} | ||
# static |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# static | |
# Static part | |
# Static subgrid ids |
level_index_static::Vector{Int} | ||
# per subgrid one relation | ||
interpolations_static::Vector{ScalarInterpolation} | ||
# dynamic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# dynamic | |
# Dynamic part | |
# Dynamic subgrid ids |
subgrid_id = repeat(subgrid.subgrid_id; outer = ntsteps) | ||
subgrid_id = repeat( | ||
sort(vcat(subgrid.subgrid_id_static, subgrid.subgrid_id_time)); | ||
outer = ntsteps, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does time already account for the multiple possible timestates (i.e. duplicates already exist)?
function static_and_time_node_ids( | ||
db::DB, | ||
static::StructVector, | ||
time::StructVector, | ||
node_type::String, | ||
node_type::String; | ||
is_complete::Bool = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is undocumented (and unclear to me). I get that there's a state before/after, but not what the difference(s) are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned it at the callsite, but also added docs here.
subgrid_id = first(getproperty.(group, :subgrid_id)) | ||
node_id = NodeID(NodeType.Basin, first(getproperty.(group, :node_id)), db) | ||
node_id = first(getproperty.(group, :node_id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we away with NodeID here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It simplified the code, otherwise we needed to strip out the integers later on.
has_error && error("Invalid Basin / subgrid_time table.") | ||
level = fill(NaN, length(subgrid_id_static) + length(subgrid_id_time)) | ||
|
||
# Find the level indices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This static part can be moved up?
core/src/read.jl
Outdated
cache_parameters = true, | ||
) | ||
# # These should only be pushed when the subgrid_id has changed | ||
if subgrid_id_time[end] != subgrid_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, not sure if I get it, but if we group by subgrid_id, this will always be true?
@@ -114,6 +115,10 @@ const ScalarInterpolation = LinearInterpolation{ | |||
(1,), | |||
} | |||
|
|||
"ConstantInterpolation from a Float64 to an Int, used to look up indices" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ConstantInterpolation from a Float64 to an Int, used to look up indices" | |
"ConstantInterpolation from a Float64 to an Int, used to look up indices over time" |
@@ -187,11 +187,18 @@ function parse_static_and_time( | |||
return out, !errors | |||
end | |||
|
|||
""" | |||
Validate the split of node IDs between static and time tables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate the split of node IDs between static and time tables. | |
Retrieve and validate the split of node IDs between static and time tables. |
Fixes #1010
This adds
Basin / subgrid_time
. So far the only relation we could update over time wasQ(h)
(TabulatedRatingCurve / time
), and that is implemented differently. I wrote #1976 to get those more in line. It's good to read that since it explains the implementation here.Things I dislike:
Basin / subgrid_time
, just likeBasin / concentration_
.Basin / static
,Basin / time
. Since we already haveBasin / subgrid
we cannot do that.