From a630d76962f610798a4d766f8f783cdf00cf072e Mon Sep 17 00:00:00 2001 From: "Langevin, Christian D" Date: Wed, 13 Mar 2024 15:30:30 -0500 Subject: [PATCH] Add a test and update docstring --- autotest/test_binaryfile.py | 19 +++++++++++++++++++ flopy/utils/binaryfile.py | 6 +++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/autotest/test_binaryfile.py b/autotest/test_binaryfile.py index 1089e22ad0..b320a5c20e 100644 --- a/autotest/test_binaryfile.py +++ b/autotest/test_binaryfile.py @@ -559,3 +559,22 @@ def test_read_mf2005_freyberg(example_data_path, function_tmpdir, compact): assert len(cbb_data) == len(cbb_data_kstpkper) for i in range(len(cbb_data)): assert np.array_equal(cbb_data[i], cbb_data_kstpkper[i]) + + +def test_read_mf6_budgetfile(example_data_path): + cbb_file = ( + example_data_path + / "mf6" + / "test005_advgw_tidal" + / "expected_output" + / "AdvGW_tidal.cbc" + ) + cbb = CellBudgetFile(cbb_file) + rch_zone_1 = cbb.get_data(paknam2="rch-zone_1".upper()) + rch_zone_2 = cbb.get_data(paknam2="rch-zone_2".upper()) + rch_zone_3 = cbb.get_data(paknam2="rch-zone_3".upper()) + + # ensure there is a record for each time step + assert len(rch_zone_1) == 120 * 3 + 1 + assert len(rch_zone_2) == 120 * 3 + 1 + assert len(rch_zone_3) == 120 * 3 + 1 diff --git a/flopy/utils/binaryfile.py b/flopy/utils/binaryfile.py index 03bd74af3e..899d6ffc44 100644 --- a/flopy/utils/binaryfile.py +++ b/flopy/utils/binaryfile.py @@ -1603,7 +1603,11 @@ def get_data( paknam : str The `from` package name for the record. paknam2 : str - The `to` package name for the record. + The `to` package name for the record. This argument can be + useful for MODFLOW 6 budget files if multiple packages of + the same type are specified. The paknam2 argument can be + specified as the package name (not the package type) in + order to retrieve budget data for a specific named package. full3D : boolean If true, then return the record as a three dimensional numpy array, even for those list-style records written as part of a