Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
73d1c71
feat(ModflowFlwob): Add various flow-obs types to model.mfnam_package…
jbellino-usgs Jun 19, 2019
bec13eb
feat(ModflowFlwob): Add method to load package from file.
jbellino-usgs Jun 19, 2019
9644078
feat(ModflowFlwob): Use supplied unit number when loading package to …
jbellino-usgs Jun 19, 2019
1056340
feat(ModflowFlwob): Add additional width and precision for toffset to…
jbellino-usgs Jun 19, 2019
d2bd924
feat(ModflowFlwob): Account for case where nqclfb is negative.
jbellino-usgs Jun 19, 2019
6f52006
feat(ModflowFlwob): Append filename using relative path with respect …
jbellino-usgs Jun 20, 2019
84a724d
feat(ModflowFlwob): Add new autotest to check loading functionality.
jbellino-usgs Jun 20, 2019
bf8f0be
revert: "feat(ModflowFlwob): Append filename using relative path with…
jbellino-usgs Jun 20, 2019
4adf51f
feat(ModflowFlwob): Add 1 to zero-based "irefsp" when writing file.
jbellino-usgs Jun 20, 2019
eca305a
feat(ModflowFlwob): Try to make Codacy happy.
jbellino-usgs Jun 20, 2019
d11fbca
feat(ModflowFlwob): Add "ftype" attribute and retrieval method.
jbellino-usgs Jun 24, 2019
d336b41
feat(ModflowFlwob): Use ext_unit_dict to get proper flowtype and ftyp…
jbellino-usgs Jun 24, 2019
0934c12
feat(ModflowFlwob): Remove unused variable and extra whitespace.
jbellino-usgs Jun 24, 2019
47514fa
feat(ModflowFlwob): Catch dict items explicitly even if they are unused.
jbellino-usgs Jun 24, 2019
df3f5e2
Revert "feat(ModflowFlwob): Try to make Codacy happy."
jbellino-usgs Jun 24, 2019
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
132 changes: 89 additions & 43 deletions autotest/t041_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def test_filenames():
pkglst = ['dis', 'bas6', 'pcg', 'lpf']
m = flopy.modflow.Modflow.load(modelname + '.nam', model_ws=pth,
check=False, load_only=pkglst,
verbose=False, exe_name=exe_name)
verbose=False, exe_name=exe_name,
forgive=False)

obs = flopy.modflow.HeadObservation(m, layer=0, row=5, column=5,
time_series_data=[[1., 54.4],
Expand All @@ -229,48 +230,6 @@ def test_filenames():
obs_data=[obs], options=['NOPRINT'],
filenames=filenames)


# add DRN package
spd = {0: [[0, 5, 5, .5, 8e6],
[0, 8, 8, .7, 8e6]]}
drn = flopy.modflow.ModflowDrn(m, 53, stress_period_data=spd)

# flow observation

# Lists of length nqfb
nqobfb = [1, 1]
nqclfb = [1, 1]

# Lists of length nqtfb
obsnam = ['drob_1', 'drob_2']
irefsp = [0, 0]
toffset = [0, 0]
flwobs = [0., 0.]

# Lists of length (nqfb, nqclfb)
layer = [[0], [0]]
row = [[5], [8]]
column = [[5], [8]]
factor = [[1.], [1.]]

drob = flopy.modflow.ModflowFlwob(m,
nqfb=len(nqclfb),
nqcfb=np.sum(nqclfb),
nqtfb=np.sum(nqobfb),
nqobfb=nqobfb,
nqclfb=nqclfb,
obsnam=obsnam,
irefsp=irefsp,
toffset=toffset,
flwobs=flwobs,
layer=layer,
row=row,
column=column,
factor=factor,
flowtype='drn',
options=['NOPRINT'],
filenames=['flwobs_simple.drob',
'flwobs_simple.obd'])
# Write the model input files
m.write_input()

Expand Down Expand Up @@ -315,8 +274,95 @@ def test_multilayerhob_prfail():
return


def test_flwob_load():
"""
test041 create, write, and load ModflowFlwob package.
"""
# load the modflow model
opth = os.path.join(cpth, 'tc1-true', 'orig')
m = flopy.modflow.Modflow.load('tc1-true.nam', verbose=True,
model_ws=opth, exe_name=exe_name)

npth = os.path.join(cpth, 'tc1-true', 'flwob')
m.change_model_ws(new_pth=npth, reset_external=True)

# write the lgr model in to the new path
m.write_input()

# add DRN package
spd = {0: [[0, 5, 5, .5, 8e6],
[0, 8, 8, .7, 8e6]]}
drn = flopy.modflow.ModflowDrn(m, 53, stress_period_data=spd)

# flow observation

# Lists of length nqfb
nqobfb = [1, 1]
nqclfb = [1, 1]

# Lists of length nqtfb
obsnam = ['drob_1', 'drob_2']
irefsp = [0, 0]
toffset = [0, 0]
flwobs = [-5.678, -6.874]

# Lists of length (nqfb, nqclfb)
layer = [[0], [0]]
row = [[5], [8]]
column = [[5], [8]]
factor = [[1.], [1.]]

drob = flopy.modflow.ModflowFlwob(m,
nqfb=len(nqclfb),
nqcfb=np.sum(nqclfb),
nqtfb=np.sum(nqobfb),
nqobfb=nqobfb,
nqclfb=nqclfb,
obsnam=obsnam,
irefsp=irefsp,
toffset=toffset,
flwobs=flwobs,
layer=layer,
row=row,
column=column,
factor=factor,
flowtype='drn',
options=['NOPRINT'])
# Write the model input files
m.write_input(check=False)

# Load the DROB package and compare it to the original
pkglst = ['drob']
m = flopy.modflow.Modflow.load('tc1-true.nam', model_ws=npth,
check=False, load_only=pkglst,
verbose=False, exe_name=exe_name,
forgive=False)

# check variables were read properly
s = 'nqfb loaded from {} read incorrectly'.format(m.drob.fn_path)
assert(drob.nqfb == m.drob.nqfb), s
s = 'nqcfb loaded from {} read incorrectly'.format(m.drob.fn_path)
assert (drob.nqcfb == m.drob.nqcfb), s
s = 'nqtfb loaded from {} read incorrectly'.format(m.drob.fn_path)
assert (drob.nqtfb == m.drob.nqtfb), s
s = 'obsnam loaded from {} read incorrectly'.format(m.drob.fn_path)
assert (list([n for n in drob.obsnam]) ==
list([n for n in m.drob.obsnam])), s
s = 'flwobs loaded from {} read incorrectly'.format(m.drob.fn_path)
assert np.array_equal(drob.flwobs, m.drob.flwobs), s
s = 'layer loaded from {} read incorrectly'.format(m.drob.fn_path)
assert np.array_equal(drob.layer, m.drob.layer), s
s = 'row loaded from {} read incorrectly'.format(m.drob.fn_path)
assert np.array_equal(drob.row, m.drob.row), s
s = 'column loaded from {} read incorrectly'.format(m.drob.fn_path)
assert np.array_equal(drob.column, m.drob.column), s

return


if __name__ == '__main__':
test_hob_simple()
test_obs_create_and_write()
test_obs_load_and_write()
test_filenames()
test_flwob_load()
4 changes: 4 additions & 0 deletions flopy/modflow/mf.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ def __init__(self, modelname='modflowtest', namefile_ext='nam',
"swt": flopy.modflow.ModflowSwt,
"hyd": flopy.modflow.ModflowHyd,
"hob": flopy.modflow.ModflowHob,
"chob": flopy.modflow.ModflowFlwob,
"gbob": flopy.modflow.ModflowFlwob,
"drob": flopy.modflow.ModflowFlwob,
"rvob": flopy.modflow.ModflowFlwob,
"vdf": flopy.seawat.SeawatVdf,
"vsc": flopy.seawat.SeawatVsc
}
Expand Down
Loading