Skip to content

Commit

Permalink
Fix water on street 1D2D preset when no 1D2D lines present.
Browse files Browse the repository at this point in the history
  • Loading branch information
arjanverkerk committed Oct 27, 2023
1 parent 964dc7b commit 1714bc0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
3.1.13 (unreleased)
-------------------

- Statistics: re-introduce fixed water_on_street preset
- Statistics: Add two water on street presets.


3.1.12 (2023-10-19)
Expand Down
12 changes: 8 additions & 4 deletions utils/threedi_result_aggregation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,15 +1078,19 @@ def aggregate_threedi_results(
if aggregation.threshold == THRESHOLD_DRAIN_LEVEL:
aggregation.threshold = nodes.drain_level
elif aggregation.threshold == THRESHOLD_EXCHANGE_LEVEL:
# set exchange level from dpumax of adjacent lines
# find adjacent lines
lines = filter_lines_by_node_ids(lines, nodes.id).subset("1D2D")

# make array to lookup thresholds by node id
max_node_id = max(nodes.id.max(), lines.line.max(initial=0))
threshold = np.full(max_node_id + 1, np.inf)

# populate lookup array with lowest dpumax
dpumax = lines.dpumax
begin, end = lines.line
# make threshold array big enough to fit all nodes in lines
threshold = np.full(lines.line.max() + 1, np.inf)
# populate with lowest dpumax per node
threshold[begin] = np.minimum(dpumax, threshold[begin])
threshold[end] = np.minimum(dpumax, threshold[end])

# set array with threshold per node on aggregation
aggregation.threshold = threshold[nodes.id]

Expand Down

0 comments on commit 1714bc0

Please sign in to comment.