Skip to content

Commit c8272b4

Browse files
committed
Use imod to lazy read with dask
And plot with XUGrid and XArray directly.
1 parent 74d7dc4 commit c8272b4

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

docs/examples/image/quickstart.png

-4.98 KB
Loading

docs/examples/quickstart.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
22

3-
import flopy
43
import imod.mf6
54
import matplotlib.pyplot as plt
65
import numpy as np
@@ -49,29 +48,23 @@
4948
grbpth = Path("./quickstart_data/mymodel.dis.grb")
5049

5150
# set specific discharge
52-
spdis = imod.mf6.open_cbc(bpth, grbpth, merge_to_dataset=False)
51+
spdis = imod.mf6.open_cbc(bpth, grbpth, merge_to_dataset=True)
5352

5453
# create head reader
5554
hpth = Path("./quickstart_data/mymodel.hds")
5655
heads = imod.mf6.open_hds(hpth, grbpth)
57-
58-
# create grid
59-
grid = flopy.discretization.StructuredGrid.from_binary_grid_file(grbpth)
60-
61-
# set discharge component arrays
62-
u = []
63-
v = []
64-
for r in spdis:
65-
u.append(r[3])
66-
v.append(r[4])
67-
qx = np.array(u).reshape(grid.nrow, grid.ncol)
68-
qy = np.array(v).reshape(grid.nrow, grid.ncol)
69-
56+
sq = heads.squeeze()
7057
fig, ax = plt.subplots()
71-
pmv = flopy.plot.PlotMapView(modelgrid=grid, ax=ax)
72-
pmv.plot_array(heads[0][0])
73-
pmv.plot_grid(colors="white")
74-
pmv.contour_array(heads[0][0], levels=[0.2, 0.4, 0.6, 0.8], linewidths=3.0)
75-
pmv.plot_vector(qx, qy, normalize=True, color="white")
58+
ax.tick_params()
59+
ax.set_xticks(np.arange(0, 11, 2), minor=False)
60+
ax.set_xticks(np.arange(1, 10, 2), minor=True)
61+
ax.set_yticks(np.arange(0, 11, 2), minor=False)
62+
ax.set_yticks(np.arange(1, 10, 2), minor=True)
63+
ax.grid(which="both", color="white")
64+
sq.plot.imshow(ax=ax)
65+
sq.plot.contour(ax=ax, levels=[0.2, 0.4, 0.6, 0.8], linewidths=3.0)
66+
spdis.squeeze().plot.quiver(
67+
x="x", y="y", u="npf-qx", v="npf-qy", ax=ax, color="white"
68+
)
7669
qs_pth = Path("./image/quickstart.png")
7770
fig.savefig(qs_pth)

0 commit comments

Comments
 (0)