|
| 1 | +from pathlib import Path |
| 2 | + |
| 3 | +import flopy |
| 4 | +import matplotlib.pyplot as plt |
1 | 5 | import numpy as np |
| 6 | +import xarray as xr |
2 | 7 |
|
3 | 8 | from flopy4.mf6.gwf import Chd, Dis, Gwf, Ic, Npf, Oc |
4 | 9 | from flopy4.mf6.ims import Ims |
|
38 | 43 | # check OC |
39 | 44 | assert oc.data["save_head"][0].item() == "all" |
40 | 45 | assert oc.data["save_budget"][0].item() == "all" |
| 46 | + |
| 47 | +# PLOT |
| 48 | +# create budget reader |
| 49 | +bpth = Path("./quickstart_data/mymodel.bud") |
| 50 | +bobj = flopy.utils.CellBudgetFile(bpth, precision="double") |
| 51 | + |
| 52 | +# set specific discharge |
| 53 | +spdis = bobj.get_data(text="DATA-SPDIS")[0] |
| 54 | + |
| 55 | +# create head reader |
| 56 | +hpth = Path("./quickstart_data/mymodel.hds") |
| 57 | +hobj = flopy.utils.HeadFile(hpth, precision="double") |
| 58 | + |
| 59 | +# set heads |
| 60 | +heads = hobj.get_alldata() |
| 61 | + |
| 62 | +# create grid |
| 63 | +grbpth = Path("./quickstart_data/mymodel.dis.grb") |
| 64 | +grid = flopy.discretization.StructuredGrid.from_binary_grid_file(grbpth) |
| 65 | + |
| 66 | +# TODO: get_specific_discharge is dependent on flopy3 model |
| 67 | +# qx, qy, qz = flopy.utils.postprocessing.get_specific_discharge(spdis, gwf) |
| 68 | + |
| 69 | +# set discharge component arrays |
| 70 | +u = [] |
| 71 | +v = [] |
| 72 | +for r in spdis: |
| 73 | + u.append(r[3]) |
| 74 | + v.append(r[4]) |
| 75 | +uflow = np.array(u).reshape(grid.nrow, grid.ncol) |
| 76 | +vflow = np.array(v).reshape(grid.nrow, grid.ncol) |
| 77 | + |
| 78 | +# set data coordinate arrays |
| 79 | +xcrs = grid.xycenters[0] |
| 80 | +ycrs = grid.xycenters[1] |
| 81 | + |
| 82 | +# create qx, qy dataarrys |
| 83 | +qx = xr.DataArray(uflow, dims=("y", "x"), coords={"x": xcrs, "y": ycrs}) |
| 84 | +qy = xr.DataArray(vflow, dims=("y", "x"), coords={"x": xcrs, "y": ycrs}) |
| 85 | + |
| 86 | +fig, ax = plt.subplots() |
| 87 | +pmv = flopy.plot.PlotMapView(modelgrid=grid, ax=ax) |
| 88 | +pmv.plot_array(heads[0][0]) |
| 89 | +pmv.plot_grid(colors="white") |
| 90 | +pmv.contour_array(heads[0][0], levels=[0.2, 0.4, 0.6, 0.8], linewidths=3.0) |
| 91 | +pmv.plot_vector(qx, qy, normalize=True, color="white") |
| 92 | +qs_pth = Path("./image/quickstart.png") |
| 93 | +fig.savefig(qs_pth) |
0 commit comments