@@ -98,12 +98,45 @@ def get_disu_kwargs(
98
98
def get_nn (k , i , j ):
99
99
return k * nrow * ncol + i * ncol + j
100
100
101
- if not isinstance (delr , np .ndarray ):
102
- delr = np .array (delr )
103
- if not isinstance (delc , np .ndarray ):
104
- delc = np .array (delc )
105
- assert delr .shape == (ncol ,)
106
- assert delc .shape == (nrow ,)
101
+ # delr check
102
+ if np .isscalar (delr ):
103
+ delr = delr * np .ones (ncol , dtype = float )
104
+ else :
105
+ assert np .asanyarray (delr ).shape == (ncol ,), (
106
+ "delr must be array with shape (ncol,), got {}" .format (delr .shape )
107
+ )
108
+
109
+ # delc check
110
+ if np .isscalar (delc ):
111
+ delc = delc * np .ones (nrow , dtype = float )
112
+ else :
113
+ assert np .asanyarray (delc ).shape == (nrow ,), (
114
+ "delc must be array with shape (nrow,), got {}" .format (delc .shape )
115
+ )
116
+
117
+ # tp check
118
+ if np .isscalar (tp ):
119
+ tp = tp * np .ones ((nrow , ncol ), dtype = float )
120
+ else :
121
+ assert np .asanyarray (tp ).shape == (
122
+ nrow ,
123
+ ncol ,
124
+ ), "tp must be scalar or array with shape (nrow, ncol), got {}" .format (tp .shape )
125
+
126
+ # botm check
127
+ if np .isscalar (botm ):
128
+ botm = botm * np .ones ((nlay , nrow , ncol ), dtype = float )
129
+ elif np .asanyarray (botm ).shape == (nlay ,):
130
+ b = np .empty ((nlay , nrow , ncol ), dtype = float )
131
+ for k in range (nlay ):
132
+ b [k ] = botm [k ]
133
+ botm = b
134
+ else :
135
+ assert np .asanyarray (botm ).shape == (
136
+ nlay ,
137
+ nrow ,
138
+ ncol ,
139
+ ), "botm must be array with shape (nlay, nrow, ncol), got {}" .format (botm .shape )
107
140
108
141
nodes = nlay * nrow * ncol
109
142
iac = np .zeros ((nodes ), dtype = int )
@@ -126,16 +159,16 @@ def get_nn(k, i, j):
126
159
cl12 .append (n + 1 )
127
160
hwva .append (n + 1 )
128
161
if k == 0 :
129
- top [n ] = tp . item () if isinstance ( tp , np . ndarray ) else tp
162
+ top [n ] = tp [ i , j ]
130
163
else :
131
- top [n ] = botm [k - 1 ]
132
- bot [n ] = botm [k ]
164
+ top [n ] = botm [k - 1 , i , j ]
165
+ bot [n ] = botm [k , i , j ]
133
166
# up
134
167
if k > 0 :
135
168
ja .append (get_nn (k - 1 , i , j ))
136
169
iac [n ] += 1
137
170
ihc .append (0 )
138
- dz = botm [k - 1 ] - botm [k ]
171
+ dz = botm [k - 1 , i , j ] - botm [k , i , j ]
139
172
cl12 .append (0.5 * dz )
140
173
hwva .append (delr [j ] * delc [i ])
141
174
# back
@@ -172,9 +205,9 @@ def get_nn(k, i, j):
172
205
iac [n ] += 1
173
206
ihc .append (0 )
174
207
if k == 0 :
175
- dz = tp - botm [k ]
208
+ dz = tp [ i , j ] - botm [k , i , j ]
176
209
else :
177
- dz = botm [k - 1 ] - botm [k ]
210
+ dz = botm [k - 1 , i , j ] - botm [k , i , j ]
178
211
cl12 .append (0.5 * dz )
179
212
hwva .append (delr [j ] * delc [i ])
180
213
ja = np .array (ja , dtype = int )
@@ -272,28 +305,31 @@ def get_disv_kwargs(
272
305
if np .isscalar (delr ):
273
306
delr = delr * np .ones (ncol , dtype = float )
274
307
else :
275
- assert delr .shape == (ncol ,), "delr must be array with shape (ncol,)"
308
+ assert np .asanyarray (delr ).shape == (ncol ,), (
309
+ "delr must be array with shape (ncol,), got {}" .format (delr .shape )
310
+ )
276
311
277
312
# delc check
278
313
if np .isscalar (delc ):
279
314
delc = delc * np .ones (nrow , dtype = float )
280
315
else :
281
- assert delc .shape == (nrow ,), "delc must be array with shape (nrow,)"
316
+ assert np .asanyarray (delc ).shape == (nrow ,), (
317
+ "delc must be array with shape (nrow,), got {}" .format (delc .shape )
318
+ )
282
319
283
320
# tp check
284
321
if np .isscalar (tp ):
285
322
tp = tp * np .ones ((nrow , ncol ), dtype = float )
286
323
else :
287
- assert tp .shape == (
324
+ assert np . asanyarray ( tp ) .shape == (
288
325
nrow ,
289
326
ncol ,
290
- ), "tp must be scalar or array with shape (nrow, ncol)"
327
+ ), "tp must be scalar or array with shape (nrow, ncol), got {}" . format ( tp . shape )
291
328
292
329
# botm check
293
330
if np .isscalar (botm ):
294
331
botm = botm * np .ones ((nlay , nrow , ncol ), dtype = float )
295
- elif isinstance (botm , list ):
296
- assert len (botm ) == nlay , "if botm provided as a list it must have length nlay"
332
+ elif np .asanyarray (botm ).shape == (nlay ,):
297
333
b = np .empty ((nlay , nrow , ncol ), dtype = float )
298
334
for k in range (nlay ):
299
335
b [k ] = botm [k ]
@@ -303,7 +339,7 @@ def get_disv_kwargs(
303
339
nlay ,
304
340
nrow ,
305
341
ncol ,
306
- ), "botm must be array with shape (nlay, nrow, ncol)"
342
+ ), "botm must be array with shape (nlay, nrow, ncol), got {}" . format ( botm . shape )
307
343
308
344
# build vertices
309
345
xv = np .cumsum (delr )
0 commit comments