Skip to content

Commit

Permalink
prt files mostly working, minimal tests with example data (can remove…
Browse files Browse the repository at this point in the history
… and programmatically generate once prt pkg classes are in flopy)
  • Loading branch information
wpbonelli committed Apr 11, 2024
1 parent a58e731 commit 471b83f
Show file tree
Hide file tree
Showing 5 changed files with 258 additions and 34 deletions.
45 changes: 45 additions & 0 deletions autotest/test_prtfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from pathlib import Path

import pytest

from autotest.conftest import get_project_root_path
from flopy.utils.prtfile import PathlineFile

pytestmark = pytest.mark.mf6
prt_data_path = (
get_project_root_path() / "examples" / "data" / "mf6" / "prt_data" / "001"
)


@pytest.mark.parametrize(
"path, header_path",
[
(Path(prt_data_path) / "prt001.trk", None),
(
Path(prt_data_path) / "prt001.trk",
Path(prt_data_path) / "prt001.trk.hdr",
),
(Path(prt_data_path) / "prt001.trk.csv", None),
],
)
def test_init(path, header_path):
file = PathlineFile(path, header_filename=header_path)
assert file.fname == path
assert file.dtype == PathlineFile.dtypes["full"]
if path.suffix == ".csv":
assert len(file._data) == len(open(path).readlines()) - 1


@pytest.mark.parametrize(
"path",
[
Path(prt_data_path) / "prt001.trk",
Path(prt_data_path) / "prt001.trk.csv",
],
)
def test_intersect(path):
file = PathlineFile(path)
nodes = [1, 11, 21]
intersection = file.intersect(nodes)
assert any(intersection)
assert all(d.icell in nodes for d in intersection.itertuples())
Binary file added examples/data/mf6/prt_data/001/prt001.trk
Binary file not shown.
Loading

0 comments on commit 471b83f

Please sign in to comment.