def plot_grid(sim, silent=True): verbose = not silent fs = USGSFigure(figure_type="map", verbose=verbose) name = sim.name gwf = sim.get_model(name) fig, ax = plt.subplots(figsize=(6.8, 2.0)) mc = flopy.plot.PlotCrossSection(model=gwf, line={"Row": 0}, ax=ax) ax.fill_between([0, 1], y1=0, y2=botm, color="cyan", alpha=0.5) fs.add_text( ax=ax, text="Constant head", x=0.5, y=-500.0, bold=False, italic=False, transform=False, va="center", ha="center", fontsize=9, ) ax.fill_between([2, 3], y1=0, y2=botm, color="cyan", alpha=0.5) fs.add_text( ax=ax, text="Constant head", x=2.5, y=-500.0, bold=False, italic=False, transform=False, va="center", ha="center", fontsize=9, ) ax.fill_between([1, 2], y1=-499.5, y2=-500.5, color="brown", alpha=0.5) fs.add_annotation( ax=ax, text="Delay interbed", xy=(1.5, -510.0), xytext=(1.6, -300), bold=False, italic=False, fontsize=9, ha="center", va="center", zorder=100, arrowprops=arrow_props, ) mc.plot_grid(color="0.5", lw=0.5, zorder=100) ax.set_xlim(0, 3) ax.set_ylabel("Elevation, in meters") ax.set_xlabel("x-coordinate, in meters") fs.remove_edge_ticks(ax) plt.tight_layout() # save figure if config.plotSave: fpth = os.path.join("..", "figures", "{}-grid{}".format(sim_name, config.figure_ext)) if not silent: print("saving...'{}'".format(fpth)) fig.savefig(fpth)
def plot_conc_results(sims, idx): print("Plotting conc model results...") sim_mf6gwf, sim_mf6gwt, sim_mf2005, sim_mt3dms = sims gwf = sim_mf6gwf.flow gwt = sim_mf6gwt.trans botm = gwf.dis.botm.array fs = USGSFigure(figure_type="map", verbose=False) sim_ws = sim_mf6gwf.simulation_data.mfpath.get_sim_path() fname = os.path.join(sim_ws, "flow.hds") hobj = flopy.utils.HeadFile(fname) head = hobj.get_data() head = np.where(head > botm, head, np.nan) sim_ws = sim_mf6gwt.simulation_data.mfpath.get_sim_path() fname = os.path.join(sim_ws, "trans.ucn") cobj = flopy.utils.HeadFile(fname, text="concentration") conc_times = cobj.get_times() fig, axes = plt.subplots(3, 1, figsize=(7.5, 4.5), dpi=300, tight_layout=True) xgrid, _, zgrid = gwt.modelgrid.xyzcellcenters for iplot, time_index in enumerate([0, 1, 2]): totim = conc_times[time_index] ax = axes[iplot] pxs = flopy.plot.PlotCrossSection(model=gwf, ax=ax, line={"row": 0}) conc = cobj.get_data(totim=totim) conc = np.where(head > botm, conc, np.nan) pa = pxs.plot_array(conc, head=head, cmap="jet", vmin=0, vmax=1.0) pxs.plot_bc(ftype="RCH", color="red") pxs.plot_bc(ftype="CHD") confining_rect = matplotlib.patches.Rectangle((3000, 1000), 3000, 100, color="gray", alpha=0.5) ax.add_patch(confining_rect) if iplot == 2: ax.set_xlabel("x position (m)") ax.set_ylabel("elevation (m)") title = "Time = {}".format(totim) letter = chr(ord("@") + iplot + 1) fs.heading(letter=letter, heading=title, ax=ax) ax.set_aspect(plotaspect) for k, i, j in [obs1, obs2]: x = xgrid[i, j] z = zgrid[k, i, j] ax.plot( x, z, markerfacecolor="yellow", markeredgecolor="black", marker="o", markersize="4", ) # save figure if config.plotSave: sim_folder = os.path.split(sim_ws)[0] sim_folder = os.path.basename(sim_folder) fname = "{}-conc{}".format(sim_folder, config.figure_ext) fpth = os.path.join(ws, "..", "figures", fname) fig.savefig(fpth)
def plot_cvt_results(sims, idx): print("Plotting cvt model results...") sim_mf6gwf, sim_mf6gwt, sim_mf2005, sim_mt3dms = sims gwf = sim_mf6gwf.flow gwt = sim_mf6gwt.trans botm = gwf.dis.botm.array fs = USGSFigure(figure_type="map", verbose=False) sim_ws = sim_mf6gwt.simulation_data.mfpath.get_sim_path() fname = os.path.join(sim_ws, "trans.obs.csv") mf6gwt_ra = np.genfromtxt(fname, names=True, delimiter=",", deletechars="") dt = [("time", "f8"), ("obs", "f8")] fname = os.path.join(config.data_ws, "ex-gwt-keating", "keating_obs1.csv") obs1ra = np.genfromtxt(fname, delimiter=",", deletechars="", dtype=dt) fname = os.path.join(config.data_ws, "ex-gwt-keating", "keating_obs2.csv") obs2ra = np.genfromtxt(fname, delimiter=",", deletechars="", dtype=dt) fig, axes = plt.subplots(2, 1, figsize=(6, 4), dpi=300, tight_layout=True) ax = axes[0] ax.plot( mf6gwt_ra["time"], mf6gwt_ra["OBS1"], "b-", alpha=1.0, label="MODFLOW 6", ) ax.plot( obs1ra["time"], obs1ra["obs"], markerfacecolor="None", markeredgecolor="k", marker="o", markersize="4", linestyle="None", label="Keating and Zyvolosky (2009)", ) ax.set_xlim(0, 8000) ax.set_ylim(0, 0.80) ax.set_xlabel('time, in days') ax.set_ylabel('normalized concentration, unitless') fs.graph_legend(ax) ax = axes[1] ax.plot( mf6gwt_ra["time"], mf6gwt_ra["OBS2"], "b-", alpha=1.0, label="MODFLOW 6", ) ax.plot( obs2ra["time"], obs2ra["obs"], markerfacecolor="None", markeredgecolor="k", marker="o", markersize="4", linestyle="None", label="Keating and Zyvolosky (2009)", ) ax.set_xlim(0, 30000) ax.set_ylim(0, 0.20) ax.set_xlabel('time, in days') ax.set_ylabel('normalized concentration, unitless') fs.graph_legend(ax) # save figure if config.plotSave: sim_folder = os.path.split(sim_ws)[0] sim_folder = os.path.basename(sim_folder) fname = "{}-cvt{}".format(sim_folder, config.figure_ext) fpth = os.path.join(ws, "..", "figures", fname) fig.savefig(fpth)
def plot_results(idx, sim, silent=True): verbose = not silent if config.plotModel: fs = USGSFigure(figure_type="map", verbose=verbose) name = list(parameters.keys())[idx] sim_ws = os.path.join(ws, name) gwf = sim.get_model(sim_name) bot = gwf.dis.botm.array if idx == 0: plot_grid(gwf, silent=silent) # create MODFLOW 6 head object file_name = gwf.oc.head_filerecord.get_data()[0][0] fpth = os.path.join(sim_ws, file_name) hobj = flopy.utils.HeadFile(fpth) # create MODFLOW 6 cell-by-cell budget object file_name = gwf.oc.budget_filerecord.get_data()[0][0] fpth = os.path.join(sim_ws, file_name) cobj = flopy.utils.CellBudgetFile(fpth, precision="double") # extract heads and specific discharge head = hobj.get_data(totim=1.0) imask = (head > -1e30) & (head <= bot) head[imask] = -1e30 # botm[imask] spdis = cobj.get_data(text="DATA-SPDIS", totim=1.0) # Create figure for simulation fig, axes = create_figure() ax = axes[0] mm = flopy.plot.PlotMapView(gwf, ax=ax, extent=extents) if bot.max() < 20: cv = mm.contour_array( bot, levels=blevels, linewidths=0.5, linestyles=":", colors=bcolor, zorder=9, ) plt.clabel(cv, fmt="%1.0f", zorder=9) h_coll = mm.plot_array(head, vmin=vmin, vmax=vmax, masked_values=masked_values, zorder=10) cv = mm.contour_array( head, masked_values=masked_values, levels=vlevels, linewidths=0.5, linestyles="-", colors=vcolor, zorder=10, ) plt.clabel(cv, fmt="%1.0f", zorder=10) mm.plot_bc("CHD", color="cyan", zorder=11) mm.plot_specific_discharge(spdis, normalize=True, color="0.75", zorder=11) ax.set_xlabel("x-coordinate, in meters") ax.set_ylabel("y-coordinate, in meters") fs.remove_edge_ticks(ax) # create legend ax = axes[-1] ax.plot( -10000, -10000, lw=0, marker="s", ms=10, mfc="cyan", mec="cyan", label="Constant Head", ) ax.plot( -10000, -10000, lw=0, marker=u"$\u2192$", ms=10, mfc="0.75", mec="0.75", label="Normalized specific discharge", ) if bot.max() < 20: ax.plot( -10000, -10000, lw=0.5, ls=":", color=bcolor, label="Bottom elevation contour, m", ) ax.plot( -10000, -10000, lw=0.5, ls="-", color=vcolor, label="Head contour, m", ) fs.graph_legend(ax, loc="center", ncol=2) cax = plt.axes([0.275, 0.125, 0.45, 0.025]) cbar = plt.colorbar(h_coll, shrink=0.8, orientation="horizontal", cax=cax) cbar.ax.tick_params(size=0) cbar.ax.set_xlabel(r"Head, $m$", fontsize=9) # save figure if config.plotSave: fpth = os.path.join( "..", "figures", "{}-{:02d}{}".format(sim_name, idx + 1, config.figure_ext), ) fig.savefig(fpth)
def plot_gwseep_results(silent=True): fs = USGSFigure(figure_type="graph", verbose=False) # load the observations name = list(parameters.keys())[0] fpth = os.path.join(ws, name, "{}.surfrate.obs.csv".format(sim_name)) drn = np.genfromtxt(fpth, delimiter=",", names=True) name = list(parameters.keys())[1] fpth = os.path.join(ws, name, "{}.surfrate.obs.csv".format(sim_name)) uzf = np.genfromtxt(fpth, delimiter=",", names=True) time = drn["time"] / 86400.0 q0 = drn["SURFRATE"] q1 = uzf["SURFRATE"] mean_error = np.mean(q0 - q1) # create the figure fig, axes = plt.subplots( ncols=2, nrows=1, sharex=True, figsize=(6.3, 3.15), constrained_layout=True, ) ax = axes[0] ax.set_xlim(0, 365) ax.set_ylim(0, 175) xp, yp = [0.0], [uzf["NETINFIL"][0]] for idx in range(time.shape[0]): if idx == 0: x0, x1 = 0.0, time[idx] else: x0, x1 = time[idx - 1], time[idx] y2 = uzf["NETINFIL"][idx] xp.append(x0) xp.append(x1) yp.append(y2) yp.append(y2) ax.fill_between( [x0, x1], 0, y2=y2, lw=0, color="blue", step="post", ec="none", zorder=100, ) ax.plot(xp, yp, lw=0.5, color="black", zorder=101) plot_stress_periods(ax) fs.heading(ax, idx=0) ax.set_xlabel("Simulation time, in days") ax.set_ylabel( "Infiltration to the unsaturated zone,\nin cubic feet per second") ax = axes[-1] ax.set_xlim(0, 365) ax.set_ylim(50.8, 51.8) ax.plot( time, -drn["SURFRATE"], lw=0.75, ls="-", color="blue", label="Drainage package", ) ax.plot( time, -uzf["SURFRATE"], marker="o", ms=3, mfc="none", mec="black", markeredgewidth=0.5, lw=0.0, ls="-", color="red", label="UZF groundwater seepage", ) plot_stress_periods(ax) fs.graph_legend(ax, loc="upper center", ncol=1, frameon=True, edgecolor="none") fs.heading(ax, idx=1) fs.add_text( ax, "Mean Error {:.2e} cubic feet per second".format(mean_error), bold=False, italic=False, x=1.0, y=1.01, va="bottom", ha="right", fontsize=7, ) ax.set_xlabel("Simulation time, in days") ax.set_ylabel( "Groundwater seepage to the land surface,\nin cubic feet per second") # save figure if config.plotSave: fpth = os.path.join( "..", "figures", "{}-01{}".format(sim_name, config.figure_ext), ) fig.savefig(fpth) return
def plot_grid(gwf, silent=True): verbose = not silent fs = USGSFigure(figure_type="map", verbose=verbose) bot = gwf.dis.botm.array fig, axes = create_figure() ax = axes[0] mm = flopy.plot.PlotMapView(gwf, ax=ax, extent=extents) bot_coll = mm.plot_array(bot, vmin=bmin, vmax=bmax) mm.plot_bc("CHD", color="cyan") cv = mm.contour_array( bot, levels=blevels, linewidths=0.5, linestyles=":", colors=bcolor, ) plt.clabel(cv, fmt="%1.0f") ax.set_xlabel("x-coordinate, in meters") ax.set_ylabel("y-coordinate, in meters") fs.remove_edge_ticks(ax) # legend ax = axes[1] ax.plot( -10000, -10000, lw=0, marker="s", ms=10, mfc="cyan", mec="cyan", label="Constant Head", ) ax.plot( -10000, -10000, lw=0.5, ls=":", color=bcolor, label="Bottom elevation contour, m", ) fs.graph_legend(ax, loc="center", ncol=2) cax = plt.axes([0.275, 0.125, 0.45, 0.025]) cbar = plt.colorbar( bot_coll, shrink=0.8, orientation="horizontal", cax=cax, ) cbar.ax.tick_params(size=0) cbar.ax.set_xlabel(r"Bottom Elevation, $m$") # save figure if config.plotSave: fpth = os.path.join( "..", "figures", "{}-grid{}".format(sim_name, config.figure_ext), ) fig.savefig(fpth) return
def plot_grid(sim, silent=True): gwf = sim.get_model(sim_name) fs = USGSFigure(figure_type="map", verbose=False) fig = plt.figure( figsize=(4, 4.3), tight_layout=True, ) plt.axis("off") nrows, ncols = 10, 1 axes = [fig.add_subplot(nrows, ncols, (1, 8))] for idx, ax in enumerate(axes): ax.set_xlim(extents[:2]) ax.set_ylim(extents[2:]) ax.set_aspect("equal") # legend axis axes.append(fig.add_subplot(nrows, ncols, (9, 10))) # set limits for legend area ax = axes[-1] ax.set_xlim(0, 1) ax.set_ylim(0, 1) # get rid of ticks and spines for legend area ax.axis("off") ax.set_xticks([]) ax.set_yticks([]) ax.spines["top"].set_color("none") ax.spines["bottom"].set_color("none") ax.spines["left"].set_color("none") ax.spines["right"].set_color("none") ax.patch.set_alpha(0.0) ax = axes[0] mm = flopy.plot.PlotMapView(gwf, ax=ax, extent=extents) mm.plot_bc("MAW", color="red") mm.plot_inactive(color_noflow="black") ax.set_xticks([0, extents[1] / 2, extents[1]]) ax.set_yticks([0, extents[1] / 2, extents[1]]) ax = axes[-1] ax.plot( -10000, -10000, lw=0, marker="s", ms=10, mfc="black", mec="black", markeredgewidth=0.5, label="Inactive cells", ) ax.plot( -10000, -10000, lw=0, marker="s", ms=10, mfc="red", mec="red", markeredgewidth=0.5, label="Multi-aquifer well", ) fs.graph_legend(ax, loc="lower center", ncol=2) # save figure if config.plotSave: fpth = os.path.join( "..", "figures", "{}-grid{}".format(sim_name, config.figure_ext), ) fig.savefig(fpth)
def plot_maw_results(silent=True): fs = USGSFigure(figure_type="graph", verbose=False) # load the observations fpth = os.path.join(ws, sim_name, "{}.maw.obs.csv".format(sim_name)) maw = np.genfromtxt(fpth, delimiter=",", names=True) time = maw["time"] * 86400.0 tmin = time[0] tmax = time[-1] # create the figure fig, axes = plt.subplots( ncols=1, nrows=2, sharex=True, figsize=figure_size, constrained_layout=True, ) ax = axes[0] ax.set_xlim(tmin, tmax) ax.set_ylim(0, 4500) ax.semilogx( time, maw["Q1"], lw=0.75, ls="-", color="blue", label="Upper aquifer", ) ax.semilogx( time, maw["Q2"], lw=0.75, ls="-", color="red", label="Lower aquifer", ) ax.axhline(0, lw=0.5, color="0.5") ax.set_ylabel(" ") fs.heading(ax, idx=0) # fs.graph_legend(ax, loc="upper right", ncol=2) ax = axes[1] ax.set_xlim(tmin, tmax) ax.set_ylim(-4500, 0) ax.axhline( 10.0, lw=0.75, ls="-", color="blue", label="Upper aquifer", ) ax.axhline( 10.0, lw=0.75, ls="-", color="red", label="Lower aquifer", ) ax.semilogx( time, maw["FW"], lw=0.75, ls="-", color="black", label="Flowing well discharge", ) ax.set_xlabel(" ") ax.set_ylabel(" ") for axis in (ax.xaxis, ): axis.set_major_formatter(mpl.ticker.ScalarFormatter()) fs.heading(ax, idx=1) fs.graph_legend(ax, loc="upper left", ncol=1) # add y-axis label that spans both subplots ax = fig.add_subplot(1, 1, 1) ax.set_xlim(0, 1) ax.set_ylim(0, 1) # get rid of ticks and spines for legend area # ax.axis("off") ax.set_xticks([]) ax.set_yticks([]) ax.spines["top"].set_color("none") ax.spines["bottom"].set_color("none") ax.spines["left"].set_color("none") ax.spines["right"].set_color("none") ax.patch.set_alpha(0.0) ax.set_xlabel("Simulation time, in seconds") ax.set_ylabel("Discharge rate, in cubic meters per day") # save figure if config.plotSave: fpth = os.path.join( "..", "figures", "{}-01{}".format(sim_name, config.figure_ext), ) fig.savefig(fpth) return
def plot_results(mf2k5, mt3d, mf6, idx, ax=None): if config.plotModel: print("Plotting model results...") mt3d_out_path = mt3d.model_ws mf6_out_path = mf6.simulation_data.mfpath.get_sim_path() mf6.simulation_data.mfpath.get_sim_path() # Get the MT3DMS concentration output fname_mt3d = os.path.join(mt3d_out_path, "MT3D001.UCN") ucnobj_mt3d = flopy.utils.UcnFile(fname_mt3d) conc_mt3d = ucnobj_mt3d.get_alldata() # Get the MF6 concentration output gwt = mf6.get_model(list(mf6.model_names)[1]) ucnobj_mf6 = gwt.output.concentration() conc_mf6 = ucnobj_mf6.get_alldata() # Create figure for scenario fs = USGSFigure(figure_type="graph", verbose=False) sim_name = mf6.name plt.rcParams["lines.dashed_pattern"] = [5.0, 5.0] xc, yc = mf2k5.modelgrid.xycenters levels = np.arange(0.2, 10, 0.4) stp_idx = 0 # 0-based (out of 2 possible stress periods) cinit = mt3d.btn.sconc[0].array[2] # Plots of concentration axWasNone = False if ax is None: fig = plt.figure(figsize=figure_size, dpi=300, tight_layout=True) ax = fig.add_subplot(2, 2, 1, aspect="equal") axWasNone = True mm = flopy.plot.PlotMapView(model=mf2k5) mm.plot_grid(color=".5", alpha=0.2) cs = mm.contour_array(cinit, levels=np.arange(20, 200, 20)) plt.xlim(5100, 5100 + 28 * 50) plt.ylim(9100, 9100 + 45 * 50) plt.xlabel("Distance Along X-Axis, in meters") plt.ylabel("Distance Along Y-Axis, in meters") plt.clabel(cs, fmt=r"%3d") for k, i, j, q in mf2k5.wel.stress_period_data[0]: plt.plot(xc[j], yc[i], "ks") title = "Layer 3 Initial Concentration" letter = chr(ord("@") + idx + 1) fs.heading(letter=letter, heading=title) # 2nd figure if axWasNone: ax = fig.add_subplot(2, 2, 2, aspect="equal") c = conc_mt3d[1, 2] # Layer 3 @ 500 days (2nd specified output time) mm = flopy.plot.PlotMapView(model=mf2k5) mm.plot_grid(color=".5", alpha=0.2) cs1 = mm.contour_array(c, levels=np.arange(10, 200, 10), colors="black") plt.clabel(cs1, fmt=r"%3d") c_mf6 = conc_mf6[1, 2] # Layer 3 @ 500 days cs2 = mm.contour_array(c_mf6, levels=np.arange(10, 200, 10), colors="red", linestyles="--") labels = ["MT3DMS", "MODFLOW 6"] lines = [cs1.collections[0], cs2.collections[0]] ax.legend(lines, labels, loc="upper left") plt.xlim(5100, 5100 + 28 * 50) plt.ylim(9100, 9100 + 45 * 50) plt.xlabel("Distance Along X-Axis, in meters") plt.ylabel("Distance Along Y-Axis, in meters") for k, i, j, q in mf2k5.wel.stress_period_data[0]: plt.plot(xc[j], yc[i], "ks") title = "MT3D Layer 3 Time = 500 days" letter = chr(ord("@") + idx + 2) fs.heading(letter=letter, heading=title) # 3rd figure if axWasNone: ax = fig.add_subplot(2, 2, 3, aspect="equal") c = conc_mt3d[2, 2] mm = flopy.plot.PlotMapView(model=mf2k5) mm.plot_grid(color=".5", alpha=0.2) cs1 = mm.contour_array(c, levels=np.arange(10, 200, 10), colors="black") plt.clabel(cs1, fmt=r"%3d") c_mf6 = conc_mf6[2, 2] cs2 = mm.contour_array(c_mf6, levels=np.arange(10, 200, 10), colors="red", linestyles="--") plt.xlim(5100, 5100 + 28 * 50) plt.ylim(9100, 9100 + 45 * 50) plt.xlabel("Distance Along X-Axis, in meters") plt.ylabel("Distance Along Y-Axis, in meters") for k, i, j, q in mf2k5.wel.stress_period_data[0]: plt.plot(xc[j], yc[i], "ks") title = "MT3D Layer 3 Time = 750 days" letter = chr(ord("@") + idx + 3) fs.heading(letter=letter, heading=title) # 4th figure if axWasNone: ax = fig.add_subplot(2, 2, 4, aspect="equal") c = conc_mt3d[3, 2] mm = flopy.plot.PlotMapView(model=mf2k5) mm.plot_grid(color=".5", alpha=0.2) cs1 = mm.contour_array(c, levels=np.arange(10, 200, 10), colors="black") plt.clabel(cs1, fmt=r"%3d") c_mf6 = conc_mf6[3, 2] cs2 = mm.contour_array(c_mf6, levels=np.arange(10, 200, 10), colors="red", linestyles="--") plt.xlim(5100, 5100 + 28 * 50) plt.ylim(9100, 9100 + 45 * 50) plt.xlabel("Distance Along X-Axis, in meters") plt.ylabel("Distance Along Y-Axis, in meters") for k, i, j, q in mf2k5.wel.stress_period_data[0]: plt.plot(xc[j], yc[i], "ks") title = "MT3D Layer 3 Time = 1,000 days" letter = chr(ord("@") + idx + 4) fs.heading(letter=letter, heading=title) plt.tight_layout() # save figure if config.plotSave: fpth = os.path.join( "..", "figures", "{}{}".format( sim_name, config.figure_ext, ), ) fig.savefig(fpth)
def plot_results(mf6, idx): if config.plotModel: print("Plotting model results...") sim_name = mf6.name fs = USGSFigure(figure_type="graph", verbose=False) # Generate a plot of FINF distribution finf_plt = finf_grad.copy() finf_plt[idomain1 == 0] = np.nan fig = plt.figure(figsize=figure_size, dpi=300, tight_layout=True) ax = fig.add_subplot(1, 1, 1) plt.imshow(finf_plt, cmap="jet") title = "Precipitation distribution" cbar = plt.colorbar(shrink=0.5) cbar.ax.set_title("Infiltration\nrate\nfactor", pad=20) plt.xlabel("Column Number") plt.ylabel("Row Number") fs.heading(heading=title) # save figure if config.plotSave: fpth = os.path.join( "..", "figures", "{}{}".format(sim_name + "-finfFact", config.figure_ext), ) fig.savefig(fpth) # Start by retrieving some output gwf = mf6.get_model(list(mf6.model_names)[0]) hdsobj = gwf.output.head() modobj = gwf.output.budget() sfrobj = gwf.sfr.output.budget() uzfobj = gwf.uzf.output.budget() ckstpkper = modobj.get_kstpkper() hds = [] depths = [] hd_tmp = hdsobj.get_data(kstpkper=ckstpkper[0]) hd_tmp = np.where(hd_tmp == 1e30, 0, hd_tmp) hds.append(hd_tmp) depths.append(top - hd_tmp[0, :, :]) depths = np.array(depths) depths = depths[0, :, :] # Generate a plot of the gw table depths for the steady state stress per depths[idomain1 == 0] = np.nan fig = plt.figure(figsize=figure_size, dpi=300, tight_layout=True) ax = fig.add_subplot(1, 1, 1) plt.imshow(depths, vmin=0, vmax=25, cmap="jet") cbar = plt.colorbar(shrink=0.5, ticks=[0, 5, 10, 15, 20, 25]) cbar.ax.set_yticklabels(["0", "5", "10", "15", "20", "> 25"]) cbar.ax.set_title("Depth to\nwater\ntable,\nin m", pad=20) plt.xlabel("Column Number") plt.ylabel("Row Number") title = "Depth To Groundwater" fs.heading(heading=title) # save figure if config.plotSave: fpth = os.path.join( "..", "figures", "{}{}".format(sim_name + "-gwDepth", config.figure_ext), ) fig.savefig(fpth) drn_disQ = [] uzrech = [] finf_tot = [] sfr_gwsw = [] sfr_flow = [] rejinf = [] uzet = [] gwet = [] outflow = [] for kstpkper in ckstpkper: # 1. Compile groundwater discharge to land surface drn_tmp = modobj.get_data( kstpkper=kstpkper, text=" DRN-TO-MVR" ) drn_arr = np.zeros_like(top) for itm in drn_tmp[0]: i, j = drn_dict_rev[itm[1] - 1] drn_arr[i, j] = itm[2] drn_disQ.append(drn_arr) # 2. Compile groundwater discharge to stream cells sfr_tmp = sfrobj.get_data( kstpkper=kstpkper, text=" GWF" ) sfr_arr = np.zeros_like(top) for x, itm in enumerate(sfr_tmp[0]): i = sfrcells[x][1] j = sfrcells[x][2] sfr_arr[i, j] = itm[2] sfr_gwsw.append(sfr_arr) # 3. Compile Infiltrated amount uzf_tmp = uzfobj.get_data( kstpkper=kstpkper, text=" INFILTRATION" ) finf_arr = np.zeros_like(top) for itm in uzf_tmp[0]: i, j = iuzno_dict_rev[itm[0] - 1] finf_arr[i, j] = itm[2] finf_tot.append(finf_arr) # 4. Compile recharge from UZF uzrch_tmp = uzfobj.get_data( kstpkper=kstpkper, text=" GWF" ) uzrch_arr = np.zeros_like(top) for itm in uzrch_tmp[0]: i, j = iuzno_dict_rev[itm[0] - 1] uzrch_arr[i, j] = itm[2] uzrech.append(uzrch_arr) # 5. Compile rejected infiltration rejinf_tmp = uzfobj.get_data( kstpkper=kstpkper, text=" REJ-INF-TO-MVR" ) rejinf_arr = np.zeros_like(top) for itm in rejinf_tmp[0]: i, j = iuzno_dict_rev[itm[0] - 1] rejinf_arr[i, j] = itm[2] rejinf.append(rejinf_arr) # 6. Compile unsat ET uzet_tmp = uzfobj.get_data( kstpkper=kstpkper, text=" UZET" ) uzet_arr = np.zeros_like(top) for itm in uzet_tmp[0]: i, j = iuzno_dict_rev[itm[0] - 1] uzet_arr[i, j] = itm[2] uzet.append(uzet_arr) # 7. Compile groundwater ET gwet_tmp = modobj.get_data( kstpkper=kstpkper, text=" UZF-GWET" ) gwet_arr = np.zeros_like(top) for itm in gwet_tmp[0]: i, j = iuzno_dict_rev[itm[1] - 1] gwet_arr[i, j] = itm[2] gwet.append(gwet_arr) # 8. Get flows at outlet outletQ = sfrobj.get_data( kstpkper=kstpkper, text=" FLOW-JA-FACE" ) outflow.append(outletQ[0][-1][2]) drn_disQ = np.array(drn_disQ) sfr_gwsw = np.array(sfr_gwsw) finf_tot = np.array(finf_tot) uzrech = np.array(uzrech) rejinf = np.array(rejinf) uzet = np.array(uzet) gwet = np.array(gwet) outflow = np.array(outflow) drn_disQ_ts = drn_disQ.sum(axis=-1).sum(axis=-1) sfr_gwsw_ts = sfr_gwsw.sum(axis=-1).sum(axis=-1) finf_tot_ts = finf_tot.sum(axis=-1).sum(axis=-1) uzrech_ts = uzrech.sum(axis=-1).sum(axis=-1) rejinf_ts = rejinf.sum(axis=-1).sum(axis=-1) uzet_ts = uzet.sum(axis=-1).sum(axis=-1) gwet_ts = gwet.sum(axis=-1).sum(axis=-1) rng = pd.date_range(start="11/1/1999", end="10/31/2000", freq="D") data = { "Recharge": abs(uzrech_ts[0:366]), "Infiltration": abs(finf_tot_ts[0:366]), "GroundwaterET": abs(gwet_ts[0:366]), "UnsaturatedZoneET": abs(uzet_ts[0:366]), } vals1 = pd.DataFrame(data, index=rng) fig = plt.figure(figsize=figure_size_ts, dpi=300, tight_layout=True) ax = fig.add_subplot(1, 1, 1) vals1.Infiltration.plot(style="k-", linewidth=0.3) vals1.Recharge.plot(style="b-", linewidth=0.7) vals1.GroundwaterET.plot( style="-", color="darkgreen", linewidth=0.7, label="Groundwater ET" ) vals1.UnsaturatedZoneET.plot( style="-", color="orange", linewidth=1, label="Unsaturated Zone ET" ) ax.set_ylim(0, 700000) plt.tick_params( axis="x", # changes apply to the x-axis which="both", # both major and minor ticks are affected bottom=False, # ticks along the bottom edge are off top=False, # ticks along the top edge are off labelbottom=True, ) # labels along the bottom edge are off ax.set_xlabel("Month") ax.set_ylabel("Volumetric Rate, $m^3$ per day") fs.graph_legend(ax) title = "Unsaturated Zone Flow Budget" fs.heading(heading=title) # save figure if config.plotSave: fpth = os.path.join( "..", "figures", "{}{}".format(sim_name + "-uzFlow", config.figure_ext), ) fig.savefig(fpth) data_sfr = { "GroundwaterDischarge": abs(drn_disQ_ts[0:366]), "RejectedInfiltration": abs(rejinf_ts[0:366]), "gwswExchange": abs(sfr_gwsw_ts[0:366]), "outflow": outflow[0:366], } vals2 = pd.DataFrame(data_sfr, index=rng) fig = plt.figure(figsize=figure_size_ts, dpi=300, tight_layout=True) ax = fig.add_subplot(1, 1, 1) vals2.outflow.plot( style="-", linewidth=0.5, color="royalblue", label="Streamflow at Outlet", ) vals2.GroundwaterDischarge.plot( style="k-", linewidth=0.7, label="Groundwater Discharge" ) vals2.RejectedInfiltration.plot( style="-", linewidth=0.7, color="brown", label="Rejected Infiltration", ) vals2.gwswExchange.plot( style="-", color="darkgreen", linewidth=0.7, label="GW Discharge to Streams", ) ax.set_ylim(0, 350000) plt.tick_params( axis="x", # changes apply to the x-axis which="both", # both major and minor ticks are affected bottom=False, # ticks along the bottom edge are off top=False, # ticks along the top edge are off labelbottom=True, ) # labels along the bottom edge are off ax.set_xlabel("Month") ax.set_ylabel("Volumetric Rate, $m^3$ per day") fs.graph_legend(ax) title = "Surface Water Flow" fs.heading(heading=title) # save figure if config.plotSave: fpth = os.path.join( "..", "figures", "{}{}".format(sim_name + "-swFlow", config.figure_ext), ) fig.savefig(fpth)