-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_mprw_obs.py
172 lines (145 loc) · 5.56 KB
/
test_mprw_obs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
'''
Tests for the ModpathRWObs class
'''
import pytest
import numpy as np
from flopyrw import modpathrw
from autotest.test_mprw_mt3dp09_cases import MT3DP09Cases
def test_mprw_obs_input_mf6(function_tmpdir):
'''
Verifies the input for the observations class
'''
# get the mf6 case
# brings WEL-1 and CHD-1 with aux CONCENTRATION
flowmf6 = MT3DP09Cases.mf6(function_tmpdir)
# modpath-rw
mp = modpathrw.ModpathRW(
modelname='mprwsim',
flowmodel=flowmf6,
model_ws =function_tmpdir,
)
# dsp
modpathrw.ModpathRWDsp(mp)
# rwopts
modpathrw.ModpathRWOpts(mp)
# simple checks #
#---------------#
# by default cellinputoption = 0 (list of cells)
# by default the input structured = None
# and is infered from the modelgrid type.
cells = [(0,3,6)]
with pytest.raises(ValueError):
# define without list of cells
modpathrw.ModpathRWObs(mp)
with pytest.raises(TypeError):
# define with invalid type of cells
modpathrw.ModpathRWObs(mp, cells='cells')
with pytest.raises(ValueError):
# define with invalid list of structured cells
modpathrw.ModpathRWObs(mp, cells=[0,1])
with pytest.raises(ValueError):
# define with invalid list of structured cells
modpathrw.ModpathRWObs(mp, cells=[(0,1)])
with pytest.raises(ValueError):
# define with unstructured and list of structured cells
modpathrw.ModpathRWObs(mp, cells=[(0,1,2),(0,1,3)], structured=False)
with pytest.raises(TypeError):
# define with unstructured and invalid type list of cells
modpathrw.ModpathRWObs(mp, cells=['asd',1,2], structured=False)
with pytest.raises(TypeError):
# define with invalid type for kind parameter
modpathrw.ModpathRWObs(mp, kind=None)
with pytest.raises(ValueError):
# define with invalid value for kind parameter
modpathrw.ModpathRWObs(mp, kind=10)
with pytest.raises(ValueError):
# define with invalid value for kind parameter
modpathrw.ModpathRWObs(mp, kind='theobs')
# obs: define a consistent observation
modpathrw.ModpathRWObs(mp, cells=cells)
# obs: it should be treated equally to cells
modpathrw.ModpathRWObs(mp, cells=cells[0])
# write distributed #
#-------------------#
mgrid = flowmf6.modelgrid
cells = np.zeros(shape=(mgrid.nlay,mgrid.nrow,mgrid.ncol), dtype=np.int32)
cells[0,3,6] = 1
badcells = np.zeros(shape=(mgrid.nlay,mgrid.nrow,mgrid.ncol), dtype=np.int32)
badcells[0,3,6] = 1
badcells[0,3,8] = 2
with pytest.raises(ValueError):
# define without the cells array
modpathrw.ModpathRWObs(mp, cellinputoption=1)
with pytest.raises(Exception):
# define with inconsistent shape for cells array
modpathrw.ModpathRWObs(mp, cellinputoption=1, cells=[[0,1],[1,0]])
with pytest.raises(ValueError):
# define with inconsistent values for cells array
modpathrw.ModpathRWObs(mp, cellinputoption=1, cells=badcells)
# define consistent for cells array
obs = modpathrw.ModpathRWObs(mp, cellinputoption=1, cells=cells)
# verify assignment to the main model
pkgs = mp.get_package_list()
assert obs._ftype() in pkgs, (
f"OBS package was not found in ModpathRW object"
)
# and write (without checking model consistency)
mp.write_input()
def test_mprw_obs_input_mf6disv(function_tmpdir):
'''
Verifies the input for the observations class
'''
# get the mf6 case
# brings WEL-1 and CHD-1 with aux CONCENTRATION
flowmf6 = MT3DP09Cases.mf6disv(function_tmpdir)
# modpath-rw
mp = modpathrw.ModpathRW(
modelname='mprwsim',
flowmodel=flowmf6,
model_ws =function_tmpdir,
)
# dsp
modpathrw.ModpathRWDsp(mp)
# rwopts
modpathrw.ModpathRWOpts(mp)
# simple checks #
#---------------#
# by default cellinputoption = 0 (list of cells)
# by default the input structured = None
# and is infered from the modelgrid type.
structcells = [(0,3,6)]
cells = [(147)]
with pytest.raises(ValueError):
# define without list of cells
modpathrw.ModpathRWObs(mp)
with pytest.raises(ValueError):
# define with a list of structured cells
modpathrw.ModpathRWObs(mp, cells=structcells)
# obs: define a consistent observation
modpathrw.ModpathRWObs(mp, cells=cells)
# write distributed #
#-------------------#
mgrid = flowmf6.modelgrid
cells = np.zeros(shape=(mgrid.nlay,mgrid.ncpl), dtype=np.int32)
cells[0,36] = 1
badcells = np.zeros(shape=(mgrid.nlay,mgrid.ncpl), dtype=np.int32)
badcells[0,36] = 1
badcells[0,38] = 2
with pytest.raises(ValueError):
# define without the cells array
modpathrw.ModpathRWObs(mp, cellinputoption=1)
with pytest.raises(Exception):
# define with inconsistent shape for cells array
modpathrw.ModpathRWObs(mp, cellinputoption=1, cells=[[0,1],[1,0]])
with pytest.raises(ValueError):
# define with inconsistent values for cells array
modpathrw.ModpathRWObs(mp, cellinputoption=1, cells=badcells)
# define consistent for cells array
obs = modpathrw.ModpathRWObs(mp, cellinputoption=1, cells=cells)
# verify assignment to the main model
pkgs = mp.get_package_list()
assert obs._ftype() in pkgs, (
f"OBS package was not found in ModpathRW object"
)
# and write (without checking model consistency)
mp.write_input()