Skip to content

Commit

Permalink
Merge f5f5da9 into feea04e
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhughes-usgs authored Aug 17, 2021
2 parents feea04e + f5f5da9 commit 561191e
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 1,158 deletions.
129 changes: 0 additions & 129 deletions autotest/t007_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,135 +1172,6 @@ def test_rotation():
assert np.abs(mg4.yvertices[0, 0] - yul) < 1e-4


def test_sr_with_Map():
# Note that most of this is either deprecated, or has pending deprecation
import matplotlib.pyplot as plt

m = flopy.modflow.Modflow(rotation=20.0)
dis = flopy.modflow.ModflowDis(
m, nlay=1, nrow=40, ncol=20, delr=250.0, delc=250.0, top=10, botm=0
)
# transformation assigned by arguments
xul, yul, rotation = 500000.0, 2934000.0, 45.0
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")

modelmap = flopy.plot.ModelMap(
model=m, xul=xul, yul=yul, rotation=rotation
)
assert len(w) == 2, len(w)
assert w[0].category == DeprecationWarning, w[0]
assert "ModelMap is deprecated" in str(w[0].message)
assert w[1].category == DeprecationWarning, w[1]
assert "xul/yul have been deprecated" in str(w[1].message)

pc = modelmap.plot_grid()
xll, yll = modelmap.mg.xoffset, modelmap.mg.yoffset
plt.close()

def check_vertices():
xllp, yllp = pc._paths[0].vertices[0]
xulp, yulp = pc._paths[0].vertices[1]
assert np.abs(xllp - xll) < 1e-6
assert np.abs(yllp - yll) < 1e-6
assert np.abs(xulp - xul) < 1e-6
assert np.abs(yulp - yul) < 1e-6

check_vertices()

with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")

modelmap = flopy.plot.ModelMap(
model=m, xll=xll, yll=yll, rotation=rotation
)
assert len(w) == 1, len(w)
assert w[0].category == DeprecationWarning, w[0]
assert "ModelMap is deprecated" in str(w[0].message)

pc = modelmap.plot_grid()
check_vertices()
plt.close()

# transformation in m.sr
sr = flopy.utils.reference.SpatialReference(
delr=m.dis.delr.array,
delc=m.dis.delc.array,
xll=xll,
yll=yll,
rotation=rotation,
)
m.sr = copy.deepcopy(sr)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")

modelmap = flopy.plot.ModelMap(model=m)

assert len(w) == 1, len(w)
assert w[0].category == DeprecationWarning, w[0]
assert "ModelMap is deprecated" in str(w[0].message)

pc = modelmap.plot_grid()
check_vertices()
plt.close()

# transformation assign from sr instance
m.sr._reset()
m.sr.set_spatialreference()
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")

modelmap = flopy.plot.ModelMap(model=m, sr=sr)

assert len(w) == 1, len(w)
assert w[0].category == DeprecationWarning, w[0]
assert "ModelMap is deprecated" in str(w[0].message)

pc = modelmap.plot_grid()
check_vertices()
plt.close()

# test plotting of line with specification of xul, yul in Dis/Model Map
mf = flopy.modflow.Modflow()

# Model domain and grid definition
dis = flopy.modflow.ModflowDis(
mf, nlay=1, nrow=10, ncol=20, delr=1.0, delc=1.0, xul=100, yul=210
)
# fig, ax = plt.subplots()
verts = [[101.0, 201.0], [119.0, 209.0]]

with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")

modelxsect = flopy.plot.ModelCrossSection(
model=mf,
line={"line": verts},
xul=mf.dis.sr.xul,
yul=mf.dis.sr.yul,
)

for wn in w:
print(str(wn))
if len(w) > 5:
w = w[0:5]
assert len(w) in (3, 5), len(w)
if len(w) == 5:
assert w[0].category == DeprecationWarning, w[0]
assert "SpatialReference has been deprecated" in str(w[0].message)
assert w[1].category == DeprecationWarning, w[1]
assert "SpatialReference has been deprecated" in str(w[1].message)
assert w[-3].category == DeprecationWarning, w[-3]
# assert "ModelCrossSection is Deprecated" in str(w[-3].message)
assert w[-2].category == DeprecationWarning, w[-2]
# assert "xul/yul have been deprecated" in str(w[-2].message)
assert w[-1].category == DeprecationWarning, w[-1]
# assert "xul/yul have been deprecated" in str(w[-1].message)

patchcollection = modelxsect.plot_grid()
plt.close()


def test_modelgrid_with_PlotMapView():
import matplotlib.pyplot as plt

Expand Down
1 change: 1 addition & 0 deletions autotest/t016_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def test_usg_rch_evt_models02a():
success, buff = m.run_model()
assert success


def test_usg_ss_to_tr():
# Test switching steady model to transient
# https://github.com/modflowpy/flopy/issues/1187
Expand Down
17 changes: 6 additions & 11 deletions autotest/t506_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,9 @@ def test_mf6disv():

if mf6_exe is not None:
sim.run_simulation(silent=True)
head = flopy.utils.HeadFile(os.path.join(ws, head_file)).get_data()
bud = flopy.utils.CellBudgetFile(
os.path.join(ws, budget_file), precision="double"
)
head = gwf.output.head().get_data()
bud = gwf.output.budget()
spdis = bud.get_data(text="DATA-SPDIS")[0]

if matplotlib is not None:
f = plt.figure(figsize=(10, 10))
vmin = head.min()
Expand All @@ -178,7 +175,7 @@ def test_mf6disv():
vmax=vmax,
)
ax.set_title("Layer {}".format(ilay + 1))
pmv.plot_specific_discharge(spdis, color="white")
pmv.plot_vector(spdis["qx"], spdis["qy"], color="white")
fname = "results.png"
fname = os.path.join(ws, fname)
plt.savefig(fname)
Expand Down Expand Up @@ -273,10 +270,8 @@ def test_mf6disu():

if mf6_exe is not None:
sim.run_simulation(silent=True)
head = flopy.utils.HeadFile(os.path.join(ws, head_file)).get_data()
bud = flopy.utils.CellBudgetFile(
os.path.join(ws, budget_file), precision="double"
)
head = gwf.output.head().get_data()
bud = gwf.output.budget()
spdis = bud.get_data(text="DATA-SPDIS")[0]

if matplotlib is not None:
Expand All @@ -299,7 +294,7 @@ def test_mf6disu():
vmax=vmax,
)
ax.set_title("Layer {}".format(ilay + 1))
pmv.plot_specific_discharge(spdis, color="white")
pmv.plot_vector(spdis["qx"], spdis["qy"], color="white")
fname = "results.png"
fname = os.path.join(ws, fname)
plt.savefig(fname)
Expand Down
Loading

0 comments on commit 561191e

Please sign in to comment.