[FEATURE] - Add reader for LAK STAGE FILEOUT binary file
@JoerivanEngelen is already working on this.
Since Jan 14, 2026.
Assessment
This issue has not been assessed yet.
Description
Title
Feature request: imod.mf6 utility to read LAK stagefile.bin into an xarray object
Problem
To visualise seasonal lake dynamics, we need time series of lake stage per stress period.
When lake.lak, options contains 'STAGE FILEOUT C:/.../stagefile.bin', then MF6 writes the binary file stagefile.bin. Alas, iMOD Python lacks a function to read the written binary file.
Solution
Proposed API
• imod.mf6.read_lak_stage(path, nlakes=None) -> xr.DataArray
o dims: ("time", "lake")
o coords: time from tdis, lake as 1..NLAKES (or names if available)
o dtype: float64
Reference structure (tested)
Each record contains:
• int32 kstp, int32 kper, float64 pertim, float64 totim
• 16-char text label ("STAGE")
• int32 n1, int32 n2, int32 n3 (counters)
• then float64 stage values (NLAKES entries)
Minimal reader we used (works for 1 lake)
import struct
from pathlib import Path
def read_lak_stagebin(bin_path: Path):
recs = []
with open(bin_path, "rb") as f:
while True:
hdr = f.read(24)
if len(hdr) < 24:
break
kstp, kper, pertim, totim = struct.unpack("<iid d".replace(" ",""), hdr)
label = f.read(16).decode("ascii", "ignore").strip()
if label.upper() != "STAGE":
raise ValueError(f"Unexpected label: {label!r}")
f.read(12) # three int32
stage = struct.unpack("<d", f.read(8))[0]
recs.append((kper, kstp, pertim, totim, stage))
return recs
- Dominant language
- Python
- Stars
- 41
- Forks
- 12
- Avg merge
- 20h 23m
- Merged PRs (30d)
- 2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Deltares/imod-python
-
ci
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Deltares/imod-python#1891 ·
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Deltares/imod-python#1843 ·
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Deltares/imod-python#1684 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Deltares/imod-python#1911 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Deltares/imod-python#1910 ·
All issues in Deltares/imod-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100