Repository navigation
Update openBoreHoles plugin to current mikeio API - #13
Merged
Merged
Conversation
The dfs0 result writing used the legacy Dataset(data=, time=, items=) constructor, which was removed in mikeio 3. Calling it raises "TypeError: Dataset.__init__() got an unexpected keyword argument 'time'". Because the write happens in preLeaveSimulator(), the failure hit at the very end of a run and discarded all bore hole heads collected during the simulation. Build one DataArray per bore hole and pass the list to Dataset, matching the pattern already used by the other plugins in this folder. Verified against mikeio 3.0.1 on python 3.14, including NaN series (as the closed solution can produce) and non-equidistant time steps. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Documents the three execution models (engine plugins, MShePy driver scripts, standalone file tools), the plugin hook lifecycle, the result file naming convention, the (x,y,z) vs (time,z,y,x) axis-order difference between MShePy and mikeio, and the non-reentrancy constraint on running simulations in parallel. Includes a note to check mikeio signatures against the installed version, prompted by the Dataset constructor removal fixed in the previous commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates the openBoreHoles MIKE SHE plugin to be compatible with the current mikeio API, preventing an end-of-run failure when writing buffered bore hole heads to dfs0.
Changes:
- Replaced legacy
mikeio.Dataset(data=..., time=..., items=...)usage with a list of per-boreholemikeio.DataArrayobjects passed intomikeio.Dataset. - Added a “last tested” note to the
openBoreHoles.pyheader. - Added
CLAUDE.mdrepository orientation documentation (separate from the functional fix).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Plugins/openBoreHoles.py | Updates dfs0 writing to the current mikeio Dataset/DataArray construction pattern to avoid runtime TypeError. |
| CLAUDE.md | Adds repository guidance documenting script/plugin execution model and environment constraints (incl. mikeio API churn context). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Collaborator
Author
|
Tested locally on a real mshe setup, still runs and produces plausible output |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A user reported that
Plugins/openBoreHoles.pyfails against a current mikeio.The dfs0 result writing in
preLeaveSimulator()used mikeio''s legacy constructor:Dataset.__init__now accepts only a mapping or sequence ofDataArray, so this raises:This is a fatal end-of-run failure: the heads are buffered in memory for the whole simulation and
written only at
preLeaveSimulator(), so a full simulation completes and then throws away everybore hole head it collected.
Fix
Build one
DataArrayper bore hole, each carrying its own time axis andItemInfo, and pass thelist to
Dataset— the same idiom the other plugins inPlugins/already use.Checked but unchanged
Still valid in mikeio 3, so left alone:
read_layer_bottoms():mikeio.read(fn, items=item)[0].values[0]still yields(z, y, x), so theexisting
np.transposeto(x, y, z)stays correct.ItemInfo(name, itemtype=EUMType.Water_Level)— unchanged signature.to_dfs(fname, title=title)—titlestill reacheswrite_dfs0via**kwargs.A grep of the repo confirms
openBoreHoles.pywas the only file using the removed constructor.Verification
Ran the patched block verbatim against mikeio 3.0.1 on python 3.14 with stub bore holes, covering a
NaNseries (which__closed_solutionproduces when no layer has leakage) and non-equidistant timesteps. Round trip gives correct item names,
Water Level/metertyping, correct timestamps, andvalues matching to float32 with
NaNpreserved.Not run: a full MIKE SHE simulation with a real bore hole config — worth a smoke test on a real setup
before merge.
Note on the second commit
CLAUDE.md(repo orientation for Claude Code) is a separate commit and unrelated to the mikeio fixbeyond one paragraph about mikeio version churn. Drop that commit if you would rather it went in on
its own.
🤖 Generated with Claude Code