-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(PRT): add utilities to configure/plot PRT models
* to_coords() and to_prt() methods on particle data classes * to_mp7_[pathlines/endpoints]() dtype conversion functions * support plotting PRT pathlines in map/cross-section plots
- Loading branch information
Showing
23 changed files
with
2,547 additions
and
893 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import os | ||
from typing import List | ||
|
||
import numpy as np | ||
import pytest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import numpy as np | ||
import pytest | ||
from modflow_devtools.markers import requires_pkg | ||
|
||
import flopy | ||
|
||
|
||
def structured_square_grid(side: int = 10, thick: int = 10): | ||
""" | ||
Creates a basic 1-layer structured grid with the given thickness and number of cells per side | ||
Parameters | ||
---------- | ||
side : The number of cells per side | ||
thick : The thickness of the grid's single layer | ||
Returns | ||
------- | ||
A single-layer StructuredGrid of the given size and thickness | ||
""" | ||
|
||
from flopy.discretization.structuredgrid import StructuredGrid | ||
|
||
delr = np.ones(side) | ||
delc = np.ones(side) | ||
top = np.ones((side, side)) * thick | ||
botm = np.ones((side, side)) * (top - thick).reshape(1, side, side) | ||
return StructuredGrid(delr=delr, delc=delc, top=top, botm=botm) | ||
|
||
|
||
@requires_pkg("shapely") | ||
@pytest.mark.parametrize( | ||
"line", | ||
[(), [], (()), [[]], (0, 0), [0, 0], [[0, 0]]], | ||
) | ||
def test_cross_section_invalid_lines_raise_error(line): | ||
grid = structured_square_grid(side=10) | ||
with pytest.raises(ValueError): | ||
flopy.plot.PlotCrossSection(modelgrid=grid, line={"line": line}) | ||
|
||
|
||
@requires_pkg("shapely") | ||
@pytest.mark.parametrize( | ||
"line", | ||
[ | ||
# diagonal | ||
[(0, 0), (10, 10)], | ||
([0, 0], [10, 10]), | ||
# horizontal | ||
([0, 5.5], [10, 5.5]), | ||
[(0, 5.5), (10, 5.5)], | ||
# vertical | ||
[(5.5, 0), (5.5, 10)], | ||
([5.5, 0], [5.5, 10]), | ||
# multiple segments | ||
[(0, 0), (4, 6), (10, 10)], | ||
([0, 0], [4, 6], [10, 10]), | ||
], | ||
) | ||
def test_cross_section_valid_line_representations(line): | ||
from shapely.geometry import LineString as SLS | ||
|
||
from flopy.utils.geometry import LineString as FLS | ||
|
||
grid = structured_square_grid(side=10) | ||
|
||
fls = FLS(line) | ||
sls = SLS(line) | ||
|
||
# use raw, flopy.utils.geometry and shapely.geometry representations | ||
lxc = flopy.plot.PlotCrossSection(modelgrid=grid, line={"line": line}) | ||
fxc = flopy.plot.PlotCrossSection(modelgrid=grid, line={"line": fls}) | ||
sxc = flopy.plot.PlotCrossSection(modelgrid=grid, line={"line": sls}) | ||
|
||
# make sure parsed points are identical for all line representations | ||
assert np.allclose(lxc.pts, fxc.pts) and np.allclose(lxc.pts, sxc.pts) | ||
assert ( | ||
set(lxc.xypts.keys()) == set(fxc.xypts.keys()) == set(sxc.xypts.keys()) | ||
) | ||
for k in lxc.xypts.keys(): | ||
assert np.allclose(lxc.xypts[k], fxc.xypts[k]) and np.allclose( | ||
lxc.xypts[k], sxc.xypts[k] | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"line", | ||
[ | ||
0, | ||
[0], | ||
[0, 0], | ||
(0, 0), | ||
[(0, 0)], | ||
([0, 0]), | ||
], | ||
) | ||
@requires_pkg("shapely", "geojson") | ||
def test_cross_section_invalid_line_representations_fail(line): | ||
grid = structured_square_grid(side=10) | ||
with pytest.raises(ValueError): | ||
flopy.plot.PlotCrossSection(modelgrid=grid, line={"line": line}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.