DHI / DHI/modelskill

from_res1d cannot reach EPANET link quantities — no breakpoint for single-gridpoint reaches

Open
#680 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
56
Forks
9
Avg merge
57m
Merged PRs (30d)
3

Description

## Summary

`from_res1d` can't reach EPANET link quantities, because EPANET-style water distribution links never get a breakpoint to match against.

## Root cause

`Res1DReach.__init__` (`src/modelskill/model/adapters/_res1d.py:77-109`) only creates intermediate breakpoints when a reach has more than 2 gridpoints:

```python
intermediate_gridpoints = (
reach.gridpoints[1:-1] if len(reach.gridpoints) > 2 else [] # line 95-97
)
```

EPANET-style links typically have exactly 2 gridpoints (start and end only, no intermediate H-points), so `intermediate_gridpoints` is always empty and `Res1DReach.breakpoints` is always `[]` for these links. As a result, `NetworkModelResult._extract_reach` (`src/modelskill/model/network.py:212-281`) can never find data to match a `ReachObservation` against such a link, and always falls through to the `ValueError` at lines 277-281.

## Request

Treat a 2-gridpoint reach as having one implicit mid-reach breakpoint. This fits the existing `ReachBreakPoint`/`BasicReach` data model without changing it. A proof of concept for this already exists.

## Relevant extension points

- `ReachBreakPoint` (`src/modelskill/network.py:81-138`)
- `BasicReach` (`network.py:270-323`)

Found by a test user evaluating the network functionality ahead of a 1.4.0 release.

Contributor guide

Open the contributing guide

Research direction

Start in src/modelskill/model/adapters/_res1d.py at Res1DReach.__init__, then review ReachBreakPoint and BasicReach in src/modelskill/network.py. Trace NetworkModelResult._extract_reach in src/modelskill/model/network.py; done means a two-gridpoint EPANET link exposes an implicit mid-reach breakpoint and its link quantities can be matched without the current ValueError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.