Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate nlmod facet plot method #189

Merged
merged 2 commits into from
Jun 7, 2023
Merged
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
28 changes: 18 additions & 10 deletions docs/examples/00_model_from_scratch.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@
" ds=ds,\n",
" cmap=\"RdYlBu\",\n",
" ax=ax,\n",
" edgecolor=\"k\",\n",
")\n",
"nlmod.plot.modelgrid(ds, ax=ax, alpha=0.5, lw=0.5)\n",
"ax.axis(extent)\n",
"cbar = ax.figure.colorbar(pc, shrink=1.0)\n",
"cbar.set_label(\"head [m NAP]\")\n",
Expand All @@ -300,17 +300,25 @@
"metadata": {},
"outputs": [],
"source": [
"fig, axes = nlmod.plot.facet_plot(\n",
" gwf,\n",
" head,\n",
" lbl=\"head [m NAP]\",\n",
" plot_dim=\"layer\",\n",
" period=0,\n",
"fg = head.plot(\n",
" x=\"x\",\n",
" y=\"y\",\n",
" col=\"layer\",\n",
" col_wrap=3,\n",
" cmap=\"RdYlBu\",\n",
" plot_bc={\"WEL\": {}},\n",
" plot_grid=True,\n",
")"
" subplot_kws={\"aspect\": \"equal\"},\n",
")\n",
"\n",
"for iax in fg.axs.flat:\n",
" nlmod.plot.modelgrid(ds, ax=iax, alpha=0.5, lw=0.5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
3 changes: 3 additions & 0 deletions docs/examples/run_all_notebooks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %%
from glob import glob
import nbformat
from nbconvert.preprocessors import ExecutePreprocessor
Expand Down Expand Up @@ -44,3 +45,5 @@
os.system(
f"jupyter nbconvert --clear-output --inplace --ClearMetadataPreprocessor.enabled=True {notebook}"
)

# %%
8 changes: 0 additions & 8 deletions nlmod/plot/flopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ def facet_plot(
xlim=None,
ylim=None,
grid=False,
figdir=None,
figsize=(10, 8),
plot_bc=None,
plot_grid=False,
Expand Down Expand Up @@ -317,11 +316,4 @@ def facet_plot(
cb = fig.colorbar(qm, ax=axes, shrink=1.0)
cb.set_label(lbl)

if figdir:
fig.savefig(
os.path.join(figdir, f"{lbl}_per_{plot_dim}.png"),
dpi=150,
bbox_inches="tight",
)

return fig, axes
44 changes: 23 additions & 21 deletions nlmod/plot/plot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
import warnings
from functools import partial

import flopy as fp
Expand Down Expand Up @@ -46,10 +46,9 @@ def modelgrid(ds, ax=None, **kwargs):
def facet_plot(
gwf,
ds,
figdir,
plot_var="bot",
plot_var,
plot_time=None,
plot_bc=("CHD",),
plot_bc=None,
color="k",
grid=False,
xlim=None,
Expand All @@ -65,8 +64,8 @@ def facet_plot(
model dataset.
figdir : str
file path figures.
plot_var : str, optional
variable in ds. The default is 'bot'.
plot_var : str
variable in ds
plot_time : int, optional
time step if plot_var is time variant. The default is None.
plot_bc : list of str, optional
Expand All @@ -88,12 +87,19 @@ def facet_plot(
axes : TYPE
DESCRIPTION.
"""
for key in plot_bc:
if key not in gwf.get_package_list():
raise ValueError(
f"cannot plot boundary condition {key} "
"because it is not in the package list"
)

warnings.warn(
"this function is out of date and will probably be removed in a future version",
DeprecationWarning,
)

if plot_bc is not None:
for key in plot_bc:
if key not in gwf.get_package_list():
raise ValueError(
f"cannot plot boundary condition {key} "
"because it is not in the package list"
)

nlay = len(ds.layer)

Expand All @@ -116,15 +122,16 @@ def facet_plot(
vmin = plot_arr.min()
vmax = plot_arr.max()
for ilay in range(nlay):
iax = axes.ravel()[ilay]
iax = axes.flat[ilay]
mp = fp.plot.PlotMapView(model=gwf, layer=ilay, ax=iax)
# mp.plot_grid()
qm = mp.plot_array(plot_arr[ilay].values, cmap="viridis", vmin=vmin, vmax=vmax)
# qm = mp.plot_array(hf[-1], cmap="viridis", vmin=-0.1, vmax=0.1)
# mp.plot_ibound()
# plt.colorbar(qm)
for bc_var in plot_bc:
mp.plot_bc(bc_var, kper=0, color=color)
if plot_bc is not None:
for bc_var in plot_bc:
mp.plot_bc(bc_var, color=color, kper=0)

iax.set_aspect("equal", adjustable="box")
iax.set_title(f"Layer {ilay}")
Expand All @@ -135,18 +142,13 @@ def facet_plot(
if ylim is not None:
iax.set_ylim(ylim)

for iax in axes.ravel()[nlay:]:
for iax in axes.flat[nlay:]:
iax.set_visible(False)

cb = fig.colorbar(qm, ax=axes, shrink=1.0)
cb.set_label(f"{plot_var}", rotation=270)
fig.suptitle(f"{plot_var} Time = {(ds.nper*ds.perlen)/365} year")
fig.tight_layout()
fig.savefig(
os.path.join(figdir, f"{plot_var}_per_layer.png"),
dpi=150,
bbox_inches="tight",
)

return fig, axes

Expand Down