Skip to content

feat(binaryfile): add write methods#2722

Open
wpbonelli wants to merge 18 commits intomodflowpy:developfrom
wpbonelli:binary-write
Open

feat(binaryfile): add write methods#2722
wpbonelli wants to merge 18 commits intomodflowpy:developfrom
wpbonelli:binary-write

Conversation

@wpbonelli
Copy link
Member

@wpbonelli wpbonelli commented Feb 27, 2026

Add instance write() methods to

  • MfGrdFile
  • HeadFile
  • CellBudgetFile

Grid files

from flopy.mf6.utils.binarygrid_util import MfGrdFile

grb = MfGrdFile("model.grb")
grb.write("output.grb") # identical
grb.write("output_single.grb", precision="single") # different precision

Head/budget files

from flopy.utils.binaryfile import HeadFile, CellBudgetFile

# head file
hds = HeadFile("model.hds")
hds.write("output.hds")
hds.write("filtered.hds", kstpkper=[(1, 0), (1, 1)])  # specific time steps
hds.write("output_single.hds", precision="single")  # different precision

# budget file
cbc = CellBudgetFile("model.cbc")
cbc.write("output.cbc")
# specific budget terms
cbc.write("flowja_only.cbc", text="FLOW-JA-FACE")
cbc.write("subset.cbc", text=["STORAGE", "CONSTANT HEAD"])
# specific time steps and terms
cbc.write("filtered.cbc", kstpkper=[(1, 0)], text="FLOW-JA-FACE")

Close #2717

@wpbonelli wpbonelli added this to the 3.11 milestone Feb 27, 2026
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 62.50000% with 105 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.8%. Comparing base (556c088) to head (f6df750).
⚠️ Report is 143 commits behind head on develop.

Files with missing lines Patch % Lines
flopy/utils/binaryfile/__init__.py 52.1% 89 Missing ⚠️
flopy/mf6/utils/binarygrid_util.py 82.4% 13 Missing ⚠️
flopy/utils/utils_def.py 85.0% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           develop    #2722     +/-   ##
==========================================
- Coverage     55.5%    52.8%   -2.8%     
==========================================
  Files          644      674     +30     
  Lines       124135   131134   +6999     
==========================================
+ Hits         68947    69265    +318     
- Misses       55188    61869   +6681     
Files with missing lines Coverage Δ
flopy/utils/utils_def.py 90.3% <85.0%> (+4.3%) ⬆️
flopy/mf6/utils/binarygrid_util.py 89.8% <82.4%> (-0.9%) ⬇️
flopy/utils/binaryfile/__init__.py 78.9% <52.1%> (-5.6%) ⬇️

... and 500 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wpbonelli wpbonelli marked this pull request as ready for review February 27, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: support writing MF6 binary output files

1 participant