Skip to content

Commit

Permalink
fix(oc.parse_oc_period_input): some logic issues; fix(tests.test_pfl_…
Browse files Browse the repository at this point in the history
…mfnwt_inset): Flopy OC tuples are (kper, kstp), not (kstp, kper)
  • Loading branch information
aleaf committed May 14, 2021
1 parent 623091b commit 2de0f7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions mfsetup/oc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def parse_oc_period_input(period_input, nstp=None, output_fmt='mf6'):
"""
if nstp is not None:
nstp = list(nstp)
nper = len(nstp)

flopy_input = {}
mf6_flopy_input = {}
Expand Down Expand Up @@ -64,6 +65,7 @@ def parse_oc_period_input(period_input, nstp=None, output_fmt='mf6'):
raise ValueError("MODFLOW 2005-style OC input requires "
"timestep information.")
# parse MF6-style instructions
# into MF2005 style input
kstp = 0
nstep_idx = kper if kper < len(nstp) else -1
instruction, *values = instruction
Expand Down Expand Up @@ -93,9 +95,9 @@ def parse_oc_period_input(period_input, nstp=None, output_fmt='mf6'):
else:
raise ValueError("mfsetup.oc.parse_oc: instruction "
f"'{instruction}' not understood")
if len(mf6_record_input) > 0:
if len(mf6_record_input) > 0 and output_fmt == 'mf6':
mf6_flopy_input[rec] = dict(mf6_record_input)
if len(mf_record_input) > 0:
elif len(mf_record_input) > 0:
mf_record_input = fill_oc_stress_period_data(mf_record_input, nper=len(nstp))
flopy_input['stress_period_data'] = dict(mf_record_input)
if output_fmt == 'mf6':
Expand Down
6 changes: 3 additions & 3 deletions mfsetup/tests/test_pfl_mfnwt_inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,12 +529,12 @@ def test_nwt_setup(pfl_nwt, project_root_path):
({'period_options': {0: ['save head last', 'save budget last'],
1: []}},
{'stress_period_data': {(0, 0): ['save head', 'save budget'],
(0, 1): []}}),
(1, 0): []}}),
# MODFLOW 2005-style input
({'stress_period_data': {(0, 0): ['save head', 'save budget'],
(0, 1): []}},
(1, 0): []}},
{'stress_period_data': {(0, 0): ['save head', 'save budget'],
(0, 1): []}})
(1, 0): []}})
])
def test_oc_setup(pfl_nwt, input, expected):
m = pfl_nwt
Expand Down

0 comments on commit 2de0f7d

Please sign in to comment.