Skip to content

Conversation

@mjreno
Copy link
Contributor

@mjreno mjreno commented Jul 25, 2025

MODFLOW 6 netcdf file info via MFModel / MFPackage. Static and instance methods support retrieving attribute dictionaries for LAYERED MESH (UGRID) or non-mesh netcdf files. The attributes in the returned dictionary are those required for a MODFLOW 6 compliant netcdf model input file. Non-mesh examples follow.

Static model attribute dictionary:

from flopy.mf6.mfmodel import MFModel
MFModel.netcdf_attrs(mname='GWF01', mtype='GWF6', grid_type=DiscretizationType.DIS)
{'modflow_grid': 'STRUCTURED', 'modflow_model': 'GWF01: MODFLOW 6 GWF6 model'}

Static package attribute dictionary:

from flopy.mf6.mfpackage import MFPackage
MFPackage.netcdf_attrs(mtype="GWF", ptype="NPF")
{'angle1': {'modflow_input': 'GWF/NPF/ANGLE1'},
 'angle2': {'modflow_input': 'GWF/NPF/ANGLE2'},
 'angle3': {'modflow_input': 'GWF/NPF/ANGLE3'},
 'icelltype': {'modflow_input': 'GWF/NPF/ICELLTYPE'},
 'k': {'modflow_input': 'GWF/NPF/K'},
 'k22': {'modflow_input': 'GWF/NPF/K22'},
 'k33': {'modflow_input': 'GWF/NPF/K33'},
 'wetdry': {'modflow_input': 'GWF/NPF/WETDRY'}}
from flopy.mf6.mfpackage import MFPackage
MFPackage.netcdf_attrs(mtype="GWF", ptype="WELG", auxiliary=["CONCENTRATION"])
{'aux/0': {'modflow_iaux': 1, 'modflow_input': 'GWF/WELG/AUX'},
 'q': {'modflow_input': 'GWF/WELG/Q'}}

Instance examples. NPF and WELG setup (structured grid with 2 layers):

# define laytyp and hk
npf = ModflowGwfnpf(
    gwf,
    icelltype=laytyp,
    k=hk,
    save_specific_discharge=True,
)

q = np.full((nlay, nrow, ncol), DNODATA, dtype=float)
welconc = np.full((nlay, nrow, ncol), DNODATA, dtype=float)
q[0,0,0] = 1.0
welconc[0,0,0] = 1.0
welg = flopy.mf6.ModflowGwfwelg(
    gwf,
    auxiliary=["CONCENTRATION"],
    q=q,
    aux=[welconc],
)

gwf.netcdf_info() would return:

{'attrs': {'modflow_grid': 'STRUCTURED',
           'modflow_model': 'GWF01: MODFLOW 6 GWF6 model'}}

Note: In the package netcdf variable dictionary, the varname attribute defined is only a suggestion as there is no name requirement.

gwf.npf.netcdf_info() would return:

{'icelltype': {'attrs': {'modflow_input': 'GWF01/NPF/ICELLTYPE'},
               'varname': 'npf_icelltype'},
 'k': {'attrs': {'modflow_input': 'GWF01/NPF/K'}, 'varname': 'npf_k'}}

gwf.welg.netcdf_info() would return:

{'aux/0': {'attrs': {'modflow_iaux': 1, 'modflow_input': 'GWF01/WELG_0/AUX'},
           'varname': 'welg_0_concentration'},
 'q': {'attrs': {'modflow_input': 'GWF01/WELG_0/Q'}, 'varname': 'welg_0_q'}}

@codecov
Copy link

codecov bot commented Jul 25, 2025

Codecov Report

❌ Patch coverage is 9.67742% with 112 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.9%. Comparing base (556c088) to head (8180c28).
⚠️ Report is 23 commits behind head on develop.

Files with missing lines Patch % Lines
flopy/mf6/mfpackage.py 4.8% 99 Missing ⚠️
flopy/mf6/mfmodel.py 18.7% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           develop    #2554     +/-   ##
==========================================
+ Coverage     55.5%    55.9%   +0.3%     
==========================================
  Files          644      642      -2     
  Lines       124135   124201     +66     
==========================================
+ Hits         68947    69463    +516     
+ Misses       55188    54738    -450     
Files with missing lines Coverage Δ
flopy/mf6/data/mfstructure.py 73.8% <100.0%> (+0.1%) ⬆️
flopy/mf6/mfmodel.py 79.7% <18.7%> (-1.2%) ⬇️
flopy/mf6/mfpackage.py 76.7% <4.8%> (-5.0%) ⬇️

... and 91 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
Copy link
Contributor Author

mjreno commented Aug 1, 2025

Replaced by #2564.

@mjreno mjreno closed this Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant