Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@
"metadata": {},
"outputs": [],
"source": [
"spd = cobj.get_data(text='DATA-SPDIS')[0]"
"spd = cobj.get_data(text='DATA-SPDIS')[0]\n",
"qx, qy, qz = flopy.utils.postprocessing.get_specific_discharge(spd, gwf)"
]
},
{
Expand All @@ -391,7 +392,7 @@
"source": [
"mm = flopy.plot.PlotMapView(model=gwf, layer=0)\n",
"mm.plot_array(hds)\n",
"mm.plot_specific_discharge(spd)\n",
"mm.plot_vector(qx, qy)\n",
"mm.plot_bc('RIV')\n",
"mm.plot_bc('WEL')"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,15 @@
"fpth = os.path.join(ws, cname)\n",
"cobj = flopy.utils.CellBudgetFile(fpth, precision=hobj.precision)\n",
"spd = cobj.get_data(text='DATA-SPDIS')[0]\n",
"qx, qy, qz = flopy.utils.postprocessing.get_specific_discharge(spd, gwf)\n",
"\n",
"# make the plot\n",
"fig = plt.figure(figsize=(10, 10))\n",
"ax = fig.add_subplot(1, 1, 1, aspect='equal')\n",
"pmv = flopy.plot.PlotMapView(model=gwf, layer=0, ax=ax)\n",
"pmv.plot_array(hds, cmap='jet')\n",
"pmv.plot_specific_discharge(spd)"
"pmv.plot_vector(qx, qy)\n",
"plt.show()"
]
},
{
Expand Down Expand Up @@ -179,9 +181,10 @@
"sim = flopy.mf6.MFSimulation(sim_name=name, exe_name=exe_name, sim_ws=ws)\n",
"\n",
"# CHANGES FOR TRANSIENT SIMULATION\n",
"time_units=\"days\"\n",
"perioddata = [(1., 1, 1.)] + [(365., 12, 1.2) for kper in range(10)]\n",
"nper = len(perioddata)\n",
"tdis = flopy.mf6.ModflowTdis(sim, nper=nper, perioddata=perioddata)\n",
"tdis = flopy.mf6.ModflowTdis(sim, nper=nper, perioddata=perioddata, time_units=time_units)\n",
"\n",
"ims = flopy.mf6.ModflowIms(sim)\n",
"gwf = flopy.mf6.ModflowGwf(sim, modelname=name, save_flows=True)\n",
Expand Down Expand Up @@ -276,12 +279,15 @@
"source": [
"fpth = os.path.join(ws, obsname)\n",
"import pandas as pd\n",
"pd.read_csv(fpth, index_col='time').plot(figsize=(15, 5), marker='o')\n",
"plt.gca().set_ylabel('head')\n",
"ax2 = plt.gca().twinx()\n",
"fig, ax = plt.subplots(figsize=(6, 6))\n",
"pd.read_csv(fpth, index_col='time').plot(figsize=(15, 5), marker='o', ax=ax)\n",
"ax.set_ylabel('head')\n",
"ax2 = ax.twinx()\n",
"ax2.bar(times[:-1], qlist, width=pertimes, align='edge', alpha=0.2, color='red')\n",
"ax2.set_ylim(-500000, 0)\n",
"ax2.set_ylabel('rate')"
"ax2.set_ylabel('rate')\n",
"ax.set_xlabel(f\"time ({time_units})\")\n",
"plt.show()"
]
},
{
Expand Down Expand Up @@ -322,7 +328,8 @@
" ax.set_title(\"totim:{0:.0f}\".format(t))\n",
" pmv.plot_array(hds[i], cmap='jet', vmin=vmin, vmax=vmax)\n",
" pmv.contour_array(a=hds[0] - hds[i], levels=[.1, .5, 1, 5], colors='white')\n",
" pmv.plot_specific_discharge(spd[i])\n",
" qx, qy, qz = flopy.utils.postprocessing.get_specific_discharge(spd[i], gwf)\n",
" pmv.plot_vector(qx, qy)\n",
" time.sleep(0.1)\n",
" clear_output(wait=True)\n",
" display(fig)\n",
Expand Down
22 changes: 12 additions & 10 deletions Notebooks-completed/04-Developing-MODFLOW6-AdvancedPackages.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
"source": [
"cpth = os.path.join(wsa, name+'.cbc')\n",
"cobja = flopy.utils.CellBudgetFile(cpth, precision=hobja.precision)\n",
"spda = cobja.get_data(text='DATA-SPDIS')[0]"
"spda = cobja.get_data(text='DATA-SPDIS')[0]\n",
"qx, qy, qz = flopy.utils.postprocessing.get_specific_discharge(spda, gwf)"
]
},
{
Expand All @@ -118,7 +119,7 @@
"source": [
"mm = flopy.plot.PlotMapView(model=gwf)\n",
"v = mm.plot_array(heada)\n",
"mm.plot_specific_discharge(spda)\n",
"mm.plot_vector(qx, qy)\n",
"mm.plot_bc('CHD')\n",
"mm.plot_bc('RIV')\n",
"mm.plot_bc('WEL', plotAll=True)\n",
Expand Down Expand Up @@ -180,7 +181,7 @@
"metadata": {},
"outputs": [],
"source": [
"riv_data = gwf.riv_0.stress_period_data.array[0]"
"riv_data = gwf.riv.stress_period_data.array[0]"
]
},
{
Expand Down Expand Up @@ -254,7 +255,7 @@
" icon = 2\n",
" # update pakdata\n",
" rk = r['cond'] * rt / (rl * rw)\n",
" s['rno'] = idx\n",
" s['ifno'] = idx\n",
" s['cellid'] = r['cellid']\n",
" s['rlen'] = rl\n",
" s['rwid'] = rw\n",
Expand Down Expand Up @@ -354,7 +355,7 @@
"metadata": {},
"outputs": [],
"source": [
"gwf.remove_package('RIV_0')"
"gwf.remove_package('riv-1')"
]
},
{
Expand Down Expand Up @@ -464,11 +465,11 @@
"ncon_maw = 0\n",
"for iwel, pd in enumerate(pak_data):\n",
" cellid = wel_data[0]['cellid'][iwel]\n",
" pd['wellno'] = iwel\n",
" pd['ifno'] = iwel\n",
" pd['radius'] = 0.25\n",
" pd['bottom'] = botm[cellid]\n",
" pd['strt'] = 0\n",
" pd['condeqn'] = 'THEIM'\n",
" pd['condeqn'] = 'THIEM'\n",
" pd['ngwfnodes'] = 1\n",
" ncon_maw += 1 "
]
Expand Down Expand Up @@ -536,7 +537,7 @@
"source": [
"for iwel, mc in enumerate(mawcon_data):\n",
" cellid = wel_data[0]['cellid'][iwel]\n",
" mc['wellno'] = iwel\n",
" mc['ifno'] = iwel\n",
" mc['icon'] = 0\n",
" mc['cellid'] = cellid\n",
" top = botm[cellid[0]-1, cellid[1], cellid[2]]\n",
Expand Down Expand Up @@ -689,7 +690,8 @@
"source": [
"cpth = os.path.join(wsb, name+'.cbc')\n",
"cobjb = flopy.utils.CellBudgetFile(cpth, precision=hobjb.precision)\n",
"spdb = cobja.get_data(text='DATA-SPDIS')[0]"
"spdb = cobja.get_data(text='DATA-SPDIS')[0]\n",
"qx, qy, qz = flopy.utils.postprocessing.get_specific_discharge(spdb, gwf)"
]
},
{
Expand Down Expand Up @@ -720,7 +722,7 @@
"source": [
"mm = flopy.plot.PlotMapView(model=gwf, layer=0)\n",
"v = mm.plot_array(headb)\n",
"mm.plot_specific_discharge(spdb)\n",
"mm.plot_vector(qx, qy)\n",
"mm.plot_bc('CHD')\n",
"c = mm.contour_array(headb, linewidths=0.75, colors='white', levels=np.arange(0, 20, 1))\n",
"plt.clabel(c, fmt='%3d')\n",
Expand Down
13 changes: 8 additions & 5 deletions Notebooks-completed/05-Advanced-analysis-pandas-flopy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -497,15 +497,18 @@
"metadata": {},
"outputs": [],
"source": [
"ax = ggo_last.flow_cfs.plot()\n",
"df[4].plot()"
"fig, ax = plt.subplots()\n",
"ggo_last.flow_cfs.plot(ax=ax, label=\"Modeled\")\n",
"df[4].plot(ax=ax, label=\"Actual\")\n",
"ax.legend()\n",
"ax.set_xlabel(\"Time\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### convert gage results to monthly averages for flows less than q threshold\n",
"### convert gage results to monthly averages for flows less than q threshold percentile\n",
"\n",
"align timestamps with gage results"
]
Expand All @@ -516,8 +519,8 @@
"metadata": {},
"outputs": [],
"source": [
"qthresh = 0.5\n",
"quant = df[4].quantile(qthresh)\n",
"qthresh = 0.5 #threshold percentile for flow values\n",
"quant = df[4].quantile(qthresh) #The value below which qthresh (0<=qthresh<=1) of the data\n",
"quant"
]
},
Expand Down