Skip to content

Commit 3c539dc

Browse files
mjrenomjreno
authored andcommitted
add notebook example for specific parameters
1 parent 319d7b4 commit 3c539dc

File tree

9 files changed

+223
-58
lines changed

9 files changed

+223
-58
lines changed

.docs/Notebooks/mf6_netcdf01_tutorial.py

Lines changed: 195 additions & 35 deletions
Large diffs are not rendered by default.

autotest/test_mf6.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,7 +2131,7 @@ def test_grid_array(function_tmpdir):
21312131

21322132
assert not wel.has_stress_period_data
21332133
q_nan = np.where(wel.q.array == DNODATA, np.nan, wel.q.array)
2134-
val_q = np.nansum(q_nan, axis=(1, 2, 3, 4))
2134+
val_q = np.nansum(q_nan, axis=(1, 2, 3))
21352135
assert val_q[0] == 0.0
21362136
assert val_q[1] == 0.25
21372137
assert val_q[2] == 0.1
@@ -2189,7 +2189,6 @@ def test_grid_array(function_tmpdir):
21892189
assert len(wel.aux.get_data()) == 4
21902190
assert wel.q.get_data()[0] is None
21912191
assert wel.q.get_data(0) is None
2192-
wel_q_array = wel.q.array
21932192
assert np.allclose(wel.q.get_data()[1], wel.q.get_data(1))
21942193
assert np.allclose(wel.q.get_data()[2], wel.q.get_data(2))
21952194
assert np.allclose(wel.q.array[1], wel.q.get_data(1))
@@ -2199,12 +2198,15 @@ def test_grid_array(function_tmpdir):
21992198
assert np.allclose(wel.aux.array[1][0], wel.aux.get_data(1)[0])
22002199
assert np.allclose(wel.aux.array[2][0], wel.aux.get_data(2)[0])
22012200
assert not wel.has_stress_period_data
2201+
wel_q_array = wel.q.array
2202+
print(wel_q_array)
22022203
q_nan = np.where(wel_q_array == DNODATA, np.nan, wel_q_array)
2203-
val_q = np.nansum(q_nan, axis=(1, 2, 3, 4))
2204+
val_q = np.nansum(q_nan, axis=(1, 2, 3))
2205+
print(val_q)
22042206
assert val_q[0] == 0.0
22052207
assert val_q[1] == 0.25
22062208
assert val_q[2] == 0.1
2207-
assert val_q[3] == 0.1
2209+
assert val_q[3] == 0.0
22082210
val_q_2 = wel.q.get_data()
22092211
assert val_q_2[0] is None
22102212
assert val_q_2[1][0, 0, 0] == 0.25
@@ -2416,9 +2418,9 @@ def test_grid_array(function_tmpdir):
24162418

24172419
wel_q_array = wel.q.array
24182420
assert np.all(wel_q_array[0][0] == 0.0)
2419-
assert wel_q_array[1][0][0, 0, 0] == 0.25
2420-
assert wel_q_array[2][0][0, 0, 0] == 0.1
2421-
assert wel_q_array[3][0][0, 0, 0] == 0.1
2421+
assert wel_q_array[1][0, 0, 0] == 0.25
2422+
assert wel_q_array[2][0, 0, 0] == 0.1
2423+
assert wel_q_array[3][0, 0, 0] == 0.1
24222424
welg_q_per = wel.q.get_data()
24232425
assert welg_q_per[0] is None
24242426
assert welg_q_per[1][0, 0, 0] == 0.25
@@ -2437,20 +2439,20 @@ def test_grid_array(function_tmpdir):
24372439

24382440
# first axis is nper, second is naux, then grid
24392441
drn_elev_array = drn.elev.array
2440-
assert drn_elev_array[0][0][0, 0, 0] == 60.0
2441-
assert drn_elev_array[1][0][0, 0, 0] == 60.0
2442-
assert drn_elev_array[2][0][0, 0, 0] == DNODATA
2443-
assert drn_elev_array[3][0][0, 0, 0] == 55.0
2442+
assert drn_elev_array[0][0, 0, 0] == 60.0
2443+
assert drn_elev_array[1][0, 0, 0] == 60.0
2444+
assert drn_elev_array[2][0, 0, 0] == DNODATA
2445+
assert drn_elev_array[3][0, 0, 0] == 55.0
24442446
assert np.allclose(drn_elev_array[0], drn.elev.get_data(0))
24452447
assert drn.elev.get_data(1) is None
24462448
assert np.allclose(drn_elev_array[2], drn.elev.get_data(2))
24472449
assert np.allclose(drn_elev_array[3], drn.elev.get_data(3))
24482450

24492451
ghb_bhead_array = ghb.bhead.array
2450-
assert ghb_bhead_array[0][0][0, 1, 1] == 60.0
2451-
assert ghb_bhead_array[1][0][0, 1, 1] == 60.0
2452-
assert ghb_bhead_array[2][0][0, 1, 1] == 60.0
2453-
assert ghb_bhead_array[3][0][0, 1, 1] == 60.0
2452+
assert ghb_bhead_array[0][0, 1, 1] == 60.0
2453+
assert ghb_bhead_array[1][0, 1, 1] == 60.0
2454+
assert ghb_bhead_array[2][0, 1, 1] == 60.0
2455+
assert ghb_bhead_array[3][0, 1, 1] == 60.0
24542456
assert np.allclose(ghb_bhead_array[0], ghb.bhead.get_data(0))
24552457
assert ghb.bhead.get_data(1) is None
24562458
assert ghb.bhead.get_data(2) is None

flopy/discretization/grid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ def read_usgs_model_reference_file(self, reffile="usgs.model.reference"):
12101210
elif info[0] == "proj4":
12111211
self.crs = data
12121212
else:
1213-
print(" ->warn: update not applied.")
1213+
print(" -> warn: update not applied.")
12141214

12151215
# model must be rotated first, before setting xoff and yoff
12161216
# when xul and yul are provided.

flopy/discretization/modeltime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ def read_usgs_model_reference_file(self, reffile="usgs.model.reference"):
831831
else:
832832
start_date_time = data
833833
else:
834-
print(" ->warn: update not applied.")
834+
print(" -> warn: update not applied.")
835835

836836
if len(start_date_time) > 0:
837837
self.start_datetime = start_date_time

flopy/discretization/structuredgrid.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,7 @@ def dataset(self, modeltime=None, mesh=None, configuration=None):
18351835
def _layered_mesh_dataset(self, ds, modeltime=None, configuration=None):
18361836
FILLNA_INT32 = np.int32(-2147483647)
18371837
FILLNA_DBL = 9.96920996838687e36
1838-
lenunits = {0: "m", 1: "ft", 2: "m", 3: "m"}
1838+
lenunits = {0: "u", 1: "ft", 2: "m", 3: "cm"}
18391839

18401840
# create dataset coordinate vars
18411841
var_d = {
@@ -1958,7 +1958,7 @@ def _layered_mesh_dataset(self, ds, modeltime=None, configuration=None):
19581958
return ds
19591959

19601960
def _structured_dataset(self, ds, modeltime=None, configuration=None):
1961-
lenunits = {0: "m", 1: "ft", 2: "m", 3: "m"}
1961+
lenunits = {0: "u", 1: "ft", 2: "m", 3: "cm"}
19621962

19631963
xc = self.xoffset + self.xycenters[0]
19641964
yc = self.yoffset + self.xycenters[1]
@@ -2024,6 +2024,8 @@ def _structured_dataset(self, ds, modeltime=None, configuration=None):
20242024
and configuration["longitude"] is not None
20252025
)
20262026

2027+
lats = None
2028+
lons = None
20272029
if latlon_cfg:
20282030
lats = configuration["latitude"]
20292031
lons = configuration["longitude"]

flopy/discretization/vertexgrid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ def dataset(self, modeltime=None, mesh=None, configuration=None):
614614

615615
FILLNA_INT32 = np.int32(-2147483647)
616616
FILLNA_DBL = 9.96920996838687e36
617-
lenunits = {0: "m", 1: "ft", 2: "m", 3: "m"}
617+
lenunits = {0: "u", 1: "ft", 2: "m", 3: "cm"}
618618

619619
if mesh is None or mesh.upper() != "LAYERED":
620620
raise ValueError("Vextex grid only supports layered mesh datasets")

flopy/mf6/data/mfdataarray.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ def _get_data(self, layer=None, apply_mult=False, **kwargs):
735735
and isinstance(self, MFTransientArray)
736736
and data is not [] # noqa: F632
737737
and not self._is_grid_aux()
738+
and not "nodes" in self.structure.shape
738739
):
739740
data = np.expand_dims(data, 0)
740741
return data

flopy/mf6/data/mfdatastorage.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,6 @@ def _build_full_data(self, apply_multiplier=False):
24112411
layers_to_process = [0]
24122412
else:
24132413
layers_to_process = self.layer_storage.indexes()
2414-
layers_to_process = self.layer_storage.indexes()
24152414
for layer in layers_to_process:
24162415
if (
24172416
self.layer_storage[layer].factor is not None

flopy/mf6/mfmodel.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,8 +1402,9 @@ def write(
14021402
pp._set_netcdf_storage(reset=True)
14031403

14041404
# write netcdf file
1405-
if write_netcdf and netcdf != "":
1406-
self._write_netcdf(mesh=netcdf)
1405+
if write_netcdf:
1406+
if netcdf != "":
1407+
self._write_netcdf(mesh=netcdf)
14071408
if nc_fname is not None:
14081409
self.name_file.nc_filerecord = None
14091410

0 commit comments

Comments
 (0)