-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(utils): move utils from modflow-devtools (#1621)
* add head and budget file writing util fns * add disu creation helper fn * add uniform flow field fn * add head/budget/concentration comparison utility fns * add namefile-reading utility fn * add minimal tests for relocated utils
- Loading branch information
Showing
8 changed files
with
2,537 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from flopy.mf6.utils import MfGrdFile | ||
from flopy.utils.compare import _diffmax, _difftol | ||
|
||
|
||
def test_diffmax(): | ||
a1 = np.array([1, 2, 3]) | ||
a2 = np.array([4, 5, 7]) | ||
d, indices = _diffmax(a1, a2) | ||
indices = indices[ | ||
0 | ||
] # return value is a tuple of arrays (1 for each dimension) | ||
assert d == 4 | ||
assert list(indices) == [2] | ||
|
||
|
||
def test_difftol(): | ||
a1 = np.array([1, 2, 3]) | ||
a2 = np.array([3, 5, 7]) | ||
d, indices = _difftol(a1, a2, 2.5) | ||
indices = indices[ | ||
0 | ||
] # return value is a tuple of arrays (1 for each dimension) | ||
assert d == 4 | ||
print(d, indices) | ||
assert list(indices) == [1, 2] | ||
|
||
|
||
@pytest.mark.skip(reason="todo") | ||
def test_eval_bud_diff(example_data_path): | ||
# get ia from grdfile | ||
mfgrd_test_path = example_data_path / "mfgrd_test" | ||
grb_path = mfgrd_test_path / "nwtp3.dis.grb" | ||
grb = MfGrdFile(str(grb_path), verbose=True) | ||
ia = grb._datadict["IA"] - 1 | ||
|
||
# TODO: create/run minimal model, then compare budget files | ||
|
||
|
||
@pytest.mark.skip(reason="todo") | ||
def test_compare_budget(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip(reason="todo") | ||
def test_compare_swrbudget(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip(reason="todo") | ||
def test_compare_heads(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip(reason="todo") | ||
def test_compare_concs(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip(reason="todo") | ||
def test_compare_stages(): | ||
pass | ||
|
||
|
||
@pytest.mark.skip(reason="todo") | ||
def test_compare(): | ||
pass |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import pytest | ||
from autotest.conftest import get_example_data_path | ||
|
||
from flopy.utils.mfreadnam import get_entries_from_namefile | ||
|
||
_example_data_path = get_example_data_path() | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"path", | ||
[ | ||
_example_data_path / "mf6" / "test001a_Tharmonic" / "mfsim.nam", | ||
_example_data_path / "mf6" / "test001e_UZF_3lay" / "mfsim.nam", | ||
_example_data_path / "mf6-freyberg" / "mfsim.nam", | ||
], | ||
) | ||
def test_get_entries_from_namefile_mf6(path): | ||
package = "IMS6" | ||
entries = get_entries_from_namefile(path, ftype=package) | ||
assert len(entries) == 1 | ||
|
||
entry = entries[0] | ||
assert path.parent.name in entry[0] | ||
assert entry[1] == package | ||
|
||
|
||
@pytest.mark.skip(reason="only supports mf6 namefiles") | ||
@pytest.mark.parametrize( | ||
"path", | ||
[ | ||
_example_data_path / "mf6-freyberg" / "freyberg.nam", | ||
], | ||
) | ||
def test_get_entries_from_namefile_mf2005(path): | ||
package = "IC6" | ||
entries = get_entries_from_namefile(path, ftype=package) | ||
assert len(entries) == 1 | ||
|
||
entry = entries[0] | ||
assert path.parent.name in entry[0] | ||
assert entry[1] == package |
Oops, something went wrong.