Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix(#675): hfb load parameters when Factor is excluded #685

Merged
merged 6 commits into from
Oct 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions autotest/t008_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
pth = os.path.join('..', 'examples', 'data', 'mf2005_test')
namfiles = [namfile for namfile in os.listdir(pth) if namfile.endswith('.nam')]

ppth = os.path.join('..', 'examples', 'data', 'parameters')
pnamfiles = ["Oahu_02.nam",]

test_nwt_pth = os.path.join("..", "examples", "data", "nwt_test")
nwt_files = [os.path.join(test_nwt_pth, f) for f in os.listdir(test_nwt_pth)
if f.endswith('.nwt')]
Expand All @@ -30,6 +33,13 @@ def load_model(namfile):
assert m.load_fail is False


def load_parameter_model(namfile):
m = flopy.modflow.Modflow.load(namfile, model_ws=ppth,
version='mf2005', verbose=True)
assert m, 'Could not load namefile {}'.format(namfile)
assert m.load_fail is False


def load_only_bas6_model(namfile):
m = flopy.modflow.Modflow.load(namfile, model_ws=pth,
version='mf2005', verbose=True,
Expand All @@ -43,6 +53,11 @@ def test_modflow_load():
yield load_model, namfile
return

def test_parameter_load():
for namfile in pnamfiles:
yield load_parameter_model, namfile
return


def test_modflow_loadonly():
for namfile in namfiles:
Expand Down
7 changes: 7 additions & 0 deletions autotest/t034_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,32 +228,39 @@ def test_read_write_nwt_options():
from flopy.utils.optionblock import OptionBlock

welstr = "OPTIONS\nSPECIFY 0.5 10\nTABFILES 2 28\nEND\n"
welstr2 = "OPTIONS\nSPECIFY 0.3\nTABFILES 2 28\nEND\n"
uzfstr = "OPTIONS\nSPECIFYTHTR\nSPECIFYTHTI\nNOSURFLEAK\n" \
"SPECIFYSURFK\nSEEPSURFK\nETSQUARE 0.7\nNETFLUX 10 20\n" \
"SAVEFINF\nEND\n"
sfrstr = "OPTIONS\nREACHINPUT\nTRANSROUTE\nTABFILES 10 21\n" \
"LOSSFACTOR 0.5\nSTRHC1KH 0.1\nSTRHC1KV 0.2\nEND\n"

welopt = OptionBlock.load_options(StringIO(welstr), ModflowWel)
welopt2 = OptionBlock.load_options(StringIO(welstr2), ModflowWel)
uzfopt = OptionBlock.load_options(StringIO(uzfstr), ModflowUzf1)
sfropt = OptionBlock.load_options(StringIO(sfrstr), ModflowSfr2)

assert repr(welopt) == welstr
assert repr(welopt2) == welstr2
assert repr(uzfopt) == uzfstr
assert repr(sfropt) == sfrstr

welopt.write_options(os.path.join(cpth, "welopt.txt"))
welopt2.write_options(os.path.join(cpth, "welopt2.txt"))
uzfopt.write_options(os.path.join(cpth, 'uzfopt.txt'))
sfropt.write_options(os.path.join(cpth, 'sfropt.txt'))

welopt = OptionBlock.load_options(os.path.join(cpth, "welopt.txt"),
ModflowWel)
welopt2 = OptionBlock.load_options(os.path.join(cpth, "welopt2.txt"),
ModflowWel)
uzfopt = OptionBlock.load_options(os.path.join(cpth, 'uzfopt.txt'),
ModflowUzf1)
sfropt = OptionBlock.load_options(os.path.join(cpth, "sfropt.txt"),
ModflowSfr2)

assert repr(welopt) == welstr
assert repr(welopt2) == welstr2
assert repr(uzfopt) == uzfstr
assert repr(sfropt) == sfrstr

Expand Down
30 changes: 30 additions & 0 deletions autotest/t041_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Test the observation process load and write
"""
import os
import sys
import shutil
import numpy as np
import flopy
Expand Down Expand Up @@ -274,6 +275,34 @@ def test_multilayerhob_prfail():
return


def test_multilayerhob_pr_multiline():
if sys.version_info[0] > 2:
from io import StringIO
else:
from cStringIO import StringIO

problem_hob = ["2 4 7",
"1 1",
"A19E1_1 -2 140 91 1 1 -0.28321 -0.05389"
" 69 1 1 1 # A19E1 8/13/1975",
"3 0.954",
"4 0.046",
"A19E1_2 -2 140 91 1 1 -0.28321 -0.05389"
" 72 1 1 1 # A19E1 10/9/1975",
"3 0.954",
"4 0.046"]

problem_hob = "\n".join(problem_hob)
ml = flopy.modflow.Modflow('hobtest')
dis = flopy.modflow.ModflowDis(ml, nlay=4, nrow=200, ncol=200,
nper=100, perlen=10, nstp=4, tsmult=1.,
steady=False)
hob = flopy.modflow.ModflowHob.load(StringIO(problem_hob), ml)

if len(hob.obs_data) != 2:
raise AssertionError("pr, mlay... load error")


def test_flwob_load():
"""
test041 create, write, and load ModflowFlwob package.
Expand Down Expand Up @@ -366,3 +395,4 @@ def test_flwob_load():
test_obs_load_and_write()
test_filenames()
test_flwob_load()
test_multilayerhob_pr_multiline()
41 changes: 41 additions & 0 deletions examples/data/parameters/Oahu_02.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Basic package file for MODFLOW, generated by Flopy.
FREE
INTERNAL 1 (20I10) -1 #ibound Layer 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
-999.99
INTERNAL 1 (20G15.6) -1 #strt Layer 1
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.500000E+01 1.500000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 1.500000E+01 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 1.500000E+01 1.500000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00
8 changes: 8 additions & 0 deletions examples/data/parameters/Oahu_02.dis
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Discretization file for MODFLOW, generated by Flopy.
1 18 20 1 4 2
0
CONSTANT 1.600000E+04 #delr
CONSTANT 1.600000E+04 #delc
CONSTANT 3.000000E+01 #model_top
CONSTANT -1.000000E+03 #botm Layer 1
1000.000000 1000 1.000000 SS
Loading