Skip to content

Commit 162dfb5

Browse files
authored
Read output dask (#121)
* Try to use imod for reading Error during import * Use imod to lazy read with dask And plot with XUGrid and XArray directly. --------- Co-authored-by: deltamarnix <[email protected]>
1 parent 98ba19a commit 162dfb5

File tree

5 files changed

+605
-65
lines changed

5 files changed

+605
-65
lines changed

.vscode/launch.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,19 @@
1010
"request": "launch",
1111
"program": "${file}",
1212
"console": "integratedTerminal",
13-
"purpose": ["debug-test"],
13+
"purpose": [
14+
"debug-test"
15+
],
1416
"justMyCode": false
17+
},
18+
{
19+
"name": "quickstart",
20+
"type": "debugpy",
21+
"request": "launch",
22+
"program": "${workspaceFolder}/docs/examples/quickstart.py",
23+
"console": "integratedTerminal",
24+
"justMyCode": false,
25+
"cwd": "${workspaceFolder}/docs/examples"
1526
}
1627
]
17-
}
28+
}

docs/examples/image/quickstart.png

-4.98 KB
Loading

docs/examples/quickstart.py

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

3-
import flopy
3+
import imod.mf6
44
import matplotlib.pyplot as plt
55
import numpy as np
66

@@ -45,39 +45,26 @@
4545
# PLOT
4646
# create budget reader
4747
bpth = Path("./quickstart_data/mymodel.bud")
48-
bobj = flopy.utils.CellBudgetFile(bpth, precision="double")
48+
grbpth = Path("./quickstart_data/mymodel.dis.grb")
4949

5050
# set specific discharge
51-
spdis = bobj.get_data(text="DATA-SPDIS")[0]
51+
spdis = imod.mf6.open_cbc(bpth, grbpth, merge_to_dataset=True)
5252

5353
# create head reader
5454
hpth = Path("./quickstart_data/mymodel.hds")
55-
hobj = flopy.utils.HeadFile(hpth, precision="double")
56-
57-
# set heads
58-
heads = hobj.get_alldata()
59-
60-
# create grid
61-
grbpth = Path("./quickstart_data/mymodel.dis.grb")
62-
grid = flopy.discretization.StructuredGrid.from_binary_grid_file(grbpth)
63-
64-
# TODO: get_specific_discharge is dependent on flopy3 model
65-
# qx, qy, qz = flopy.utils.postprocessing.get_specific_discharge(spdis, gwf)
66-
67-
# set discharge component arrays
68-
u = []
69-
v = []
70-
for r in spdis:
71-
u.append(r[3])
72-
v.append(r[4])
73-
qx = np.array(u).reshape(grid.nrow, grid.ncol)
74-
qy = np.array(v).reshape(grid.nrow, grid.ncol)
75-
55+
heads = imod.mf6.open_hds(hpth, grbpth)
56+
sq = heads.squeeze()
7657
fig, ax = plt.subplots()
77-
pmv = flopy.plot.PlotMapView(modelgrid=grid, ax=ax)
78-
pmv.plot_array(heads[0][0])
79-
pmv.plot_grid(colors="white")
80-
pmv.contour_array(heads[0][0], levels=[0.2, 0.4, 0.6, 0.8], linewidths=3.0)
81-
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+
)
8269
qs_pth = Path("./image/quickstart.png")
8370
fig.savefig(qs_pth)

0 commit comments

Comments
 (0)