Skip to content
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
1 change: 0 additions & 1 deletion autotest/t043_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Test the observation process load and write
"""
import os
import shutil
import filecmp
import flopy
import pymake
Expand Down
42 changes: 17 additions & 25 deletions autotest/t044_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@
import pytest
import os
import flopy
import pymake
from ci_framework import base_test_dir, FlopyTestSetup

try:
import pymake
except ImportError:
print("could not import pymake")
pymake = False
base_dir = base_test_dir(__file__, rel_path="temp", verbose=True)

path = os.path.join("..", "examples", "data", "pcgn_test")
cpth = os.path.join("temp", "t044")
# make the directory if it does not exist
if not os.path.isdir(cpth):
os.makedirs(cpth, exist_ok=True)

mf_items = ["twri.nam", "MNW2.nam"]
pths = []
Expand All @@ -29,21 +23,19 @@ def load_and_write_pcgn(mfnam, pth):
"""
exe_name = "mf2005"
v = flopy.which(exe_name)
run = v is not None

if pymake:
run = v is not None
lpth = os.path.join(cpth, os.path.splitext(mfnam)[0])
apth = os.path.join(lpth, "flopy")
compth = lpth
pymake.setup(os.path.join(pth, mfnam), lpth)
else:
run = False
lpth = pth
apth = cpth
compth = cpth
model_ws = f"{base_dir}_{mfnam}"
compth = os.path.join(model_ws, "flopy")
test_setup = FlopyTestSetup(verbose=True, test_dirs=model_ws)

pymake.setup(os.path.join(pth, mfnam), model_ws)

m = flopy.modflow.Modflow.load(
mfnam, model_ws=lpth, verbose=True, exe_name=exe_name
mfnam,
model_ws=model_ws,
verbose=True,
exe_name=exe_name,
)
assert m.load_fail is False
if mfnam in ["twri.nam"]: # update this list for fixed models
Expand All @@ -57,21 +49,21 @@ def load_and_write_pcgn(mfnam, pth):
except:
success = False
assert success, "base model run did not terminate successfully"
fn0 = os.path.join(lpth, mfnam)
fn0 = os.path.join(model_ws, mfnam)

# rewrite files
m.change_model_ws(apth)
m.change_model_ws(compth)
m.write_input()
if run:
try:
success, buff = m.run_model(silent=False)
except:
success = False
assert success, "new model run did not terminate successfully"
fn1 = os.path.join(apth, mfnam)
fn1 = os.path.join(compth, mfnam)

if run:
fsum = os.path.join(compth, f"{os.path.splitext(mfnam)[0]}.head.out")
fsum = os.path.join(model_ws, f"{os.path.splitext(mfnam)[0]}.head.out")
success = False
try:
success = pymake.compare_heads(fn0, fn1, outfile=fsum, htol=0.005)
Expand Down
47 changes: 21 additions & 26 deletions autotest/t045_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@
import pytest
import os
import flopy
import pymake
from ci_framework import base_test_dir, FlopyTestSetup

base_dir = base_test_dir(__file__, rel_path="temp", verbose=True)

try:
import pymake
except ImportError:
print("could not import pymake")
pymake = False

path = os.path.join("..", "examples", "data", "secp")
cpth = os.path.join("temp", "t045")
# make the directory if is does not exist
if not os.path.isdir(cpth):
os.makedirs(cpth, exist_ok=True)

mf_items = ["secp.nam"]
pths = []
Expand All @@ -29,21 +24,19 @@ def load_and_write_gmg(mfnam, pth):
"""
exe_name = "mf2005"
v = flopy.which(exe_name)
run = v is not None

model_ws = f"{base_dir}_{mfnam}"
compth = os.path.join(model_ws, "flopy")
test_setup = FlopyTestSetup(verbose=True, test_dirs=model_ws)

if pymake:
run = v is not None
lpth = os.path.join(cpth, os.path.splitext(mfnam)[0])
apth = os.path.join(lpth, "flopy")
compth = lpth
pymake.setup(os.path.join(pth, mfnam), lpth)
else:
run = False
lpth = pth
apth = cpth
compth = cpth
pymake.setup(os.path.join(pth, mfnam), model_ws)

m = flopy.modflow.Modflow.load(
mfnam, model_ws=lpth, verbose=True, exe_name=exe_name
mfnam,
model_ws=model_ws,
verbose=True,
exe_name=exe_name,
)
assert m.load_fail is False

Expand All @@ -53,21 +46,21 @@ def load_and_write_gmg(mfnam, pth):
except:
success = False
assert success, "base model run did not terminate successfully"
fn0 = os.path.join(lpth, mfnam)
fn0 = os.path.join(model_ws, mfnam)

# rewrite files
m.change_model_ws(apth)
m.change_model_ws(compth)
m.write_input()
if run:
try:
success, buff = m.run_model(silent=False)
except:
success = False
assert success, "new model run did not terminate successfully"
fn1 = os.path.join(apth, mfnam)
fn1 = os.path.join(compth, mfnam)

if run:
fsum = os.path.join(compth, f"{os.path.splitext(mfnam)[0]}.head.out")
fsum = os.path.join(model_ws, f"{os.path.splitext(mfnam)[0]}.head.out")
success = False
try:
success = pymake.compare_heads(fn0, fn1, outfile=fsum)
Expand All @@ -77,7 +70,9 @@ def load_and_write_gmg(mfnam, pth):

assert success, "head comparison failure"

fsum = os.path.join(compth, f"{os.path.splitext(mfnam)[0]}.budget.out")
fsum = os.path.join(
model_ws, f"{os.path.splitext(mfnam)[0]}.budget.out"
)
success = False
try:
success = pymake.compare_budget(
Expand Down
48 changes: 21 additions & 27 deletions autotest/t046_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@
import pytest
import os
import flopy
import pymake
from ci_framework import base_test_dir, FlopyTestSetup

try:
import pymake
except ImportError:
print("could not import pymake")
pymake = False
base_dir = base_test_dir(__file__, rel_path="temp", verbose=True)

path = os.path.join("..", "examples", "data", "freyberg")
cpth = os.path.join("temp", "t046")
# make the directory if it does not exist
if not os.path.isdir(cpth):
os.makedirs(cpth, exist_ok=True)

mf_items = ["freyberg.nam"]
pths = []
Expand All @@ -29,21 +23,19 @@ def load_and_write(mfnam, pth):
"""
exe_name = "mf2005"
v = flopy.which(exe_name)
run = v is not None

if pymake:
run = v is not None
lpth = os.path.join(cpth, os.path.splitext(mfnam)[0])
apth = os.path.join(lpth, "flopy")
compth = lpth
pymake.setup(os.path.join(pth, mfnam), lpth)
else:
run = False
lpth = pth
apth = cpth
compth = cpth
model_ws = f"{base_dir}_{mfnam}"
compth = os.path.join(model_ws, "flopy")
test_setup = FlopyTestSetup(verbose=True, test_dirs=model_ws)

pymake.setup(os.path.join(pth, mfnam), model_ws)

m = flopy.modflow.Modflow.load(
mfnam, model_ws=lpth, verbose=True, exe_name=exe_name
mfnam,
model_ws=model_ws,
verbose=True,
exe_name=exe_name,
)
assert m.load_fail is False

Expand All @@ -53,10 +45,10 @@ def load_and_write(mfnam, pth):
except:
success = False
assert success, "base model run did not terminate successfully"
fn0 = os.path.join(lpth, mfnam)
fn0 = os.path.join(model_ws, mfnam)

# change model workspace
m.change_model_ws(apth)
m.change_model_ws(compth)

# recreate oc file
oc = m.oc
Expand All @@ -81,11 +73,11 @@ def load_and_write(mfnam, pth):
except:
success = False
assert success, "new model run did not terminate successfully"
fn1 = os.path.join(apth, mfnam)
fn1 = os.path.join(compth, mfnam)

if run:
# compare heads
fsum = os.path.join(compth, f"{os.path.splitext(mfnam)[0]}.head.out")
fsum = os.path.join(model_ws, f"{os.path.splitext(mfnam)[0]}.head.out")
success = False
try:
success = pymake.compare_heads(fn0, fn1, outfile=fsum)
Expand All @@ -96,7 +88,7 @@ def load_and_write(mfnam, pth):
assert success, "head comparison failure"

# compare heads
fsum = os.path.join(compth, f"{os.path.splitext(mfnam)[0]}.ddn.out")
fsum = os.path.join(model_ws, f"{os.path.splitext(mfnam)[0]}.ddn.out")
success = False
try:
success = pymake.compare_heads(
Expand All @@ -109,7 +101,9 @@ def load_and_write(mfnam, pth):
assert success, "head comparison failure"

# compare budgets
fsum = os.path.join(compth, f"{os.path.splitext(mfnam)[0]}.budget.out")
fsum = os.path.join(
model_ws, f"{os.path.splitext(mfnam)[0]}.budget.out"
)
success = False
try:
success = pymake.compare_budget(
Expand Down
30 changes: 18 additions & 12 deletions autotest/t047_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import os
import flopy
from flopy.utils.recarray_utils import recarray
from ci_framework import base_test_dir, FlopyTestSetup

cpth = os.path.join("temp", "t047")
# make the directory if it does not exist
if not os.path.isdir(cpth):
os.makedirs(cpth, exist_ok=True)
base_dir = base_test_dir(__file__, rel_path="temp", verbose=True)


def get_namefile_entries(fpth):
Expand Down Expand Up @@ -49,10 +47,12 @@ def get_namefile_entries(fpth):


def test_gage():
model_ws = f"{base_dir}_test_gage"
test_setup = FlopyTestSetup(verbose=True, test_dirs=model_ws)

mnam = "gage_test"

m = flopy.modflow.Modflow(modelname=mnam, model_ws=cpth)
m = flopy.modflow.Modflow(modelname=mnam, model_ws=model_ws)
dis = flopy.modflow.ModflowDis(m)
spd = {
(0, 0): ["print head"],
Expand All @@ -73,7 +73,7 @@ def test_gage():
m.write_input()

# check that the gage output units entries are in the name file
fpth = os.path.join(cpth, f"{mnam}.nam")
fpth = os.path.join(model_ws, f"{mnam}.nam")
entries = get_namefile_entries(fpth)
for idx, g in enumerate(gages):
if g[0] < 0:
Expand All @@ -93,10 +93,12 @@ def test_gage():


def test_gage_files():
model_ws = f"{base_dir}_test_gage_files"
test_setup = FlopyTestSetup(verbose=True, test_dirs=model_ws)

mnam = "gage_test_files"

m = flopy.modflow.Modflow(modelname=mnam, model_ws=cpth)
m = flopy.modflow.Modflow(modelname=mnam, model_ws=model_ws)
dis = flopy.modflow.ModflowDis(m)
spd = {
(0, 0): ["print head"],
Expand All @@ -120,7 +122,7 @@ def test_gage_files():
m.write_input()

# check that the gage output file entries are in the name file
fpth = os.path.join(cpth, f"{mnam}.nam")
fpth = os.path.join(model_ws, f"{mnam}.nam")
entries = get_namefile_entries(fpth)
for idx, f in enumerate(files):
found = False
Expand All @@ -142,10 +144,12 @@ def test_gage_files():


def test_gage_filenames0():
model_ws = f"{base_dir}_test_gage_filenames0"
test_setup = FlopyTestSetup(verbose=True, test_dirs=model_ws)

mnam = "gage_test_filenames0"

m = flopy.modflow.Modflow(modelname=mnam, model_ws=cpth)
m = flopy.modflow.Modflow(modelname=mnam, model_ws=model_ws)
dis = flopy.modflow.ModflowDis(m)
spd = {
(0, 0): ["print head"],
Expand All @@ -169,7 +173,7 @@ def test_gage_filenames0():
m.write_input()

# check that the gage output units entries are in the name file
fpth = os.path.join(cpth, f"{mnam}.nam")
fpth = os.path.join(model_ws, f"{mnam}.nam")
entries = get_namefile_entries(fpth)
for idx, g in enumerate(gages):
if g[0] < 0:
Expand All @@ -189,10 +193,12 @@ def test_gage_filenames0():


def test_gage_filenames():
model_ws = f"{base_dir}_test_gage_filenames"
test_setup = FlopyTestSetup(verbose=True, test_dirs=model_ws)

mnam = "gage_test_filenames"

m = flopy.modflow.Modflow(modelname=mnam, model_ws=cpth)
m = flopy.modflow.Modflow(modelname=mnam, model_ws=model_ws)
dis = flopy.modflow.ModflowDis(m)
spd = {
(0, 0): ["print head"],
Expand All @@ -216,7 +222,7 @@ def test_gage_filenames():
m.write_input()

# check that the gage output file entries are in the name file
fpth = os.path.join(cpth, f"{mnam}.nam")
fpth = os.path.join(model_ws, f"{mnam}.nam")
entries = get_namefile_entries(fpth)
for idx, f in enumerate(filenames[1:]):
found = False
Expand Down
Loading