Skip to content

mfgrdfile: add version and crs properties#2711

Merged
mjreno merged 8 commits into
modflowpy:developfrom
mjreno:grb_v2_verbose
Jun 30, 2026
Merged

mfgrdfile: add version and crs properties#2711
mjreno merged 8 commits into
modflowpy:developfrom
mjreno:grb_v2_verbose

Conversation

@mjreno

@mjreno mjreno commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

Add GRB v2 binary grid file support (CRS, version, export)

  • Adds version and crs properties to MfGrdFile for reading GRB v1 and v2 files
  • Extends MfGrdFile.export() to write GRB v2 files with embedded CRS; auto-detects output version based on CRS presence; supports int, str, and pyproj.CRS inputs via _crs_to_string()

Fixed issues:

  1. Header newline placement: write_line() was not placing \n at the fixed position 49; Fortran readers parse header and definition lines as fixed-length text records and require the newline exactly at the end position
  2. Array write order: arrays were flattened with order="F" (column-major); multi-dimensional arrays in _datadict (e.g. DISV BOTM, reshaped to (nlay, ncpl)) were written cell-major instead of layer-major; fixed to order="C" to match MF6 on-disk layout
  3. Variable list hardcoded shapes: develop's export() hardcoded per-grid-type variable lists with manually specified shapes; replaced with shapes derived from _recorddict (parsed source file structure), fixing incorrect DIS TOP array shape

@codecov

codecov Bot commented Feb 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.28571% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.5%. Comparing base (556c088) to head (01f785f).
⚠️ Report is 179 commits behind head on develop.

Files with missing lines Patch % Lines
flopy/mf6/utils/binarygrid_util.py 84.2% 11 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2711      +/-   ##
===========================================
+ Coverage     55.5%    72.5%   +17.0%     
===========================================
  Files          644      677      +33     
  Lines       124135   132721    +8586     
===========================================
+ Hits         68947    96354   +27407     
+ Misses       55188    36367   -18821     
Files with missing lines Coverage Δ
flopy/mf6/utils/binarygrid_util.py 89.5% <84.2%> (-1.3%) ⬇️

... and 579 files with indirect coverage changes

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

@mjreno mjreno changed the title fix grb v2 reading with verbose logging mfgrdfile: add version and crs properties Feb 13, 2026
@wpbonelli wpbonelli added this to the 3.11 milestone Feb 18, 2026
@mjreno mjreno merged commit 079298e into modflowpy:develop Jun 30, 2026
20 checks passed
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.

2 participants