Skip to content

Commit

Permalink
test roundtrip prt -> mp7 -> prt result conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Nov 21, 2023
1 parent facd87f commit 61b66d9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
26 changes: 24 additions & 2 deletions autotest/test_plotutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
import pandas as pd
import pytest

from flopy.plot.plotutil import to_mp7_endpoints, to_mp7_pathlines
from flopy.plot.plotutil import (
to_mp7_endpoints,
to_mp7_pathlines,
to_prt_pathlines,
)

# test PRT-MP7 pathline conversion functions
# todo: define fields in a single location and reference from here
# todo: support optional grid parameter to conversion functions
# todo: test to_prt_pathlines() conversion and round-trip


prt_pl_cols = []
Expand Down Expand Up @@ -289,3 +292,22 @@ def test_to_mp7_endpoints(dataframe):
assert set(
dict(mp7_eps.dtypes).keys() if dataframe else mp7_eps.dtype.names
) == set(mp7_ep_cols)


def test_to_prt_pathlines_roundtrip():
inp_pls = pls
mp7_pls = to_mp7_pathlines(inp_pls)
prt_pls = to_prt_pathlines(mp7_pls)
inp_pls.drop(
["imdl", "iprp", "name", "istatus", "ireason"], axis=1, inplace=True
)
prt_pls.drop(
["imdl", "iprp", "name", "istatus", "ireason"], axis=1, inplace=True
)
inp_pls[inp_pls.select_dtypes(np.float64).columns] = inp_pls.select_dtypes(
np.float64
).astype(np.float32)
inp_pls[inp_pls.select_dtypes(np.int64).columns] = inp_pls.select_dtypes(
np.int64
).astype(np.int32)
assert np.array_equal(inp_pls, prt_pls)
13 changes: 9 additions & 4 deletions flopy/plot/plotutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import os
import warnings
from itertools import repeat
from typing import Union

import matplotlib.pyplot as plt
Expand Down Expand Up @@ -2690,7 +2691,8 @@ def to_mp7_pathlines(
# build mp7 format recarray
ret = np.core.records.fromarrays(
[
data[seqn_key],
data["irpt"],
# data[seqn_key],
data["iprp"],
data[seqn_key],
data["irpt"],
Expand Down Expand Up @@ -2911,6 +2913,7 @@ def to_prt_pathlines(
("x", np.float32),
("y", np.float32),
("z", np.float32),
("name", str),
]
)

Expand All @@ -2920,17 +2923,19 @@ def to_prt_pathlines(
data["stressperiod"],
data["timestep"],
np.zeros(data.shape[0]),
np.zeros(data.shape[0]),
data["particlegroup"],
data["particleid"],
data["k"],
data["node"],
np.zeros(data.shape[0]), # todo k
np.zeros(data.shape[0]), # todo izone?
np.zeros(data.shape[0]), # todo istatus?
np.zeros(data.shape[0]), # todo ireason?
np.zeros(data.shape[0]), # todo trelease?
data["t"],
data["time"],
data["x"],
data["y"],
data["z"],
np.zeros(data.shape[0]),
],
dtype=prt_dtypes,
)
Expand Down

0 comments on commit 61b66d9

Please sign in to comment.