docs(lakpak_utils): add embedded lake connection examples - #2793
docs(lakpak_utils): add embedded lake connection examples#2793jdhughes-dev wants to merge 3 commits into
Conversation
get_lak_connections builds the Lake Package connection data for a lake embedded in the model domain, and support for a vertex grid was added in modflowpy#2786, but no notebook showed either one. Two notebooks are added. The first embeds a lake in a structured grid, and the second embeds the same lake in the equivalent vertex grid and checks that the two give the same connections. Both run the model and put the lake stage into the head array so that a single map shows the water surface across the lake and the aquifer rather than leaving a hole where the lake is.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2793 +/- ##
===========================================
+ Coverage 55.5% 72.8% +17.2%
===========================================
Files 644 662 +18
Lines 124135 133001 +8866
===========================================
+ Hits 68947 96828 +27881
+ Misses 55188 36173 -19015 🚀 New features to boost your workflow:
|
The two notebooks were written in an impersonal voice and never named MODFLOW 6, unlike the notebooks added alongside them. They now use the first person for what the notebook does and name the program whose package input is being built.
There was a problem hiding this comment.
Pull request overview
Adds two executable Jupytext example notebooks to the FloPy docs demonstrating how to generate MODFLOW 6 LAK connection data for an embedded lake in both a structured grid (DIS) and an equivalent vertex grid (DISV), including running a small model and visualizing a combined water-surface map by embedding lake stage into the head array.
Changes:
- Add a structured-grid embedded lake example (
dis_lake_connections_example.py) usingget_lak_connections(). - Add a vertex-grid counterpart (
disv_lake_connections_example.py) that builds an equivalentVertexGridand checks connections against the structured case. - Run MODFLOW 6 in both notebooks and plot a single “water surface” map by filling inactive lake cells with simulated stage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| .docs/Notebooks/dis_lake_connections_example.py | New structured-grid example notebook for embedded lake connections and head/stage visualization. |
| .docs/Notebooks/disv_lake_connections_example.py | New vertex-grid example notebook, including a structured-vs-vertex connection equivalence check and DISV model run. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import sys | ||
| from pathlib import Path | ||
| from tempfile import TemporaryDirectory |
There was a problem hiding this comment.
Removed in df277c1.
Worth noting it would not have tripped this repository, since F401 is in the ruff ignore list in pyproject.toml, so ruff check passed on it. It was still dead code in a notebook people read, which is the part that mattered.
| return (lakeno, *cellid, claktype, connlen, connwidth) | ||
|
|
||
|
|
||
| assert sorted(map(normalize, dis_data)) == sorted(map(normalize, disv_data)) |
There was a problem hiding this comment.
Changed in df277c1. The cells and the connection types are still compared exactly, and the lengths and widths with np.allclose. The sort key is the discrete part only, so the ordering cannot shift with the floats.
For the record the two grids agree exactly on this geometry, maximum difference 0.0 over all 21 connections, so the comparison was not failing. The tolerance is there because the widths come from np.linalg.norm on the vertex grid and from delr/delc on the structured grid, and the notebook runs on three platforms.
…lerance The structured notebook imported Path without using it. The vertex notebook compared the connection lengths and widths of the two grids for exact equality, which is brittle because the two grids compute them differently. The cells and the connection types are still compared exactly, and the lengths and widths to within rounding.
get_lak_connectionssupport added in feat(lakpak_utils): add support for VertexGrid embedded lakes #2786