Skip to content

Commit

Permalink
test(array3d_export): add tests for structured and unstructured grids
Browse files Browse the repository at this point in the history
  • Loading branch information
martclanor committed Sep 15, 2024
1 parent c2f966d commit c93977b
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions autotest/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,65 @@ def test_export_array2(function_tmpdir):
assert os.path.isfile(filename), "did not create array shapefile"


@pytest.mark.mf6
@requires_pkg("pyshp", name_map={"pyshp": "shapefile"})
def test_array3d_export_structured(function_tmpdir):
from shapefile import Reader

xll, yll = 468970, 3478635
xur, yur = 681010, 3716462
spacing = 20000
ncol = int((xur - xll) / spacing)
nrow = int((yur - yll) / spacing)
sim = flopy.mf6.MFSimulation("sim", sim_ws=function_tmpdir)
gwf = flopy.mf6.ModflowGwf(
sim,
modelname="array3d_export_unstructured",
)
flopy.mf6.ModflowGwfdis(
gwf,
nlay=3,
top=5,
botm=[4, 3, 2],
delr=spacing,
delc=spacing,
nrow=nrow,
ncol=ncol,
)

shp_file = os.path.join(function_tmpdir, "dis_botm.shp")
gwf.dis.botm.export(shp_file)

with Reader(shp_file) as shp:
assert list(shp.shapeRecord(-1).record) == [
110, # node
11, # row
10, # column
4.0, # botm_1
3.0, # botm_2
2.0, # botm_3
]


@requires_pkg("pyshp", name_map={"pyshp": "shapefile"})
def test_array3d_export_unstructured(function_tmpdir):
from shapefile import Reader

name = "array3d_export_unstructured"
sim = disu_sim(name, function_tmpdir)
gwf = sim.get_model(name)

shp_file = function_tmpdir / "disu_bot.shp"
gwf.disu.bot.export(shp_file)

with Reader(shp_file) as shp:
assert list(shp.shapeRecord(-1).record) == [
1770, # node
3, # layer
0.0, # bot
]


@requires_pkg("pyshp", "shapely", name_map={"pyshp": "shapefile"})
def test_export_array_contours_structured(function_tmpdir):
nrow = 7
Expand Down

0 comments on commit c93977b

Please sign in to comment.