Skip to content

Commit

Permalink
Merge pull request #2016 from modflowpy/v3.5.0
Browse files Browse the repository at this point in the history
Release 3.5.0
  • Loading branch information
wpbonelli committed Nov 25, 2023
2 parents 45cb0fa + e906f1b commit 879c153
Show file tree
Hide file tree
Showing 281 changed files with 15,050 additions and 10,621 deletions.
10 changes: 5 additions & 5 deletions .docs/Notebooks/array_output_tutorial.py
Expand Up @@ -53,9 +53,9 @@
os.makedirs(modelpth)

print(sys.version)
print("numpy version: {}".format(np.__version__))
print("matplotlib version: {}".format(mpl.__version__))
print("flopy version: {}".format(flopy.__version__))
print(f"numpy version: {np.__version__}")
print(f"matplotlib version: {mpl.__version__}")
print(f"flopy version: {flopy.__version__}")

# +
ml = flopy.modflow.Modflow.load(
Expand All @@ -73,10 +73,10 @@
files = ["freyberg.hds", "freyberg.cbc"]
for f in files:
if os.path.isfile(os.path.join(modelpth, f)):
msg = "Output file located: {}".format(f)
msg = f"Output file located: {f}"
print(msg)
else:
errmsg = "Error. Output file cannot be found: {}".format(f)
errmsg = f"Error. Output file cannot be found: {f}"
print(errmsg)

# + [markdown] pycharm={"name": "#%% md\n"}
Expand Down
10 changes: 5 additions & 5 deletions .docs/Notebooks/dis_triangle_example.py
Expand Up @@ -37,9 +37,9 @@
workspace = Path(temp_dir.name)

print(sys.version)
print("numpy version: {}".format(np.__version__))
print("matplotlib version: {}".format(mpl.__version__))
print("flopy version: {}".format(flopy.__version__))
print(f"numpy version: {np.__version__}")
print(f"matplotlib version: {mpl.__version__}")
print(f"flopy version: {flopy.__version__}")
# -

# ## Creating Meshes with the Triangle Class
Expand Down Expand Up @@ -247,8 +247,8 @@ def chdhead(x):
chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=chdlist)
oc = flopy.mf6.ModflowGwfoc(
gwf,
budget_filerecord="{}.cbc".format(name),
head_filerecord="{}.hds".format(name),
budget_filerecord=f"{name}.cbc",
head_filerecord=f"{name}.hds",
saverecord=[("HEAD", "LAST"), ("BUDGET", "LAST")],
printrecord=[("HEAD", "LAST"), ("BUDGET", "LAST")],
)
Expand Down
14 changes: 7 additions & 7 deletions .docs/Notebooks/dis_voronoi_example.py
Expand Up @@ -41,9 +41,9 @@
workspace = Path(temp_dir.name)

print(sys.version)
print("numpy version: {}".format(np.__version__))
print("matplotlib version: {}".format(mpl.__version__))
print("flopy version: {}".format(flopy.__version__))
print(f"numpy version: {np.__version__}")
print(f"matplotlib version: {mpl.__version__}")
print(f"flopy version: {flopy.__version__}")
# -

# ### Use Triangle to Generate Points for Voronoi Grid
Expand Down Expand Up @@ -164,8 +164,8 @@
chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=chdlist)
oc = flopy.mf6.ModflowGwfoc(
gwf,
budget_filerecord="{}.bud".format(name),
head_filerecord="{}.hds".format(name),
budget_filerecord=f"{name}.bud",
head_filerecord=f"{name}.hds",
saverecord=[("HEAD", "ALL"), ("BUDGET", "ALL")],
printrecord=[("HEAD", "LAST"), ("BUDGET", "LAST")],
)
Expand Down Expand Up @@ -229,8 +229,8 @@
fmi = flopy.mf6.ModflowGwtfmi(gwt, packagedata=pd)
oc = flopy.mf6.ModflowGwtoc(
gwt,
budget_filerecord="{}.cbc".format(name),
concentration_filerecord="{}.ucn".format(name),
budget_filerecord=f"{name}.cbc",
concentration_filerecord=f"{name}.ucn",
saverecord=[("CONCENTRATION", "ALL"), ("BUDGET", "ALL")],
)

Expand Down
10 changes: 5 additions & 5 deletions .docs/Notebooks/drain_return_example.py
Expand Up @@ -29,9 +29,9 @@
import flopy

print(sys.version)
print("numpy version: {}".format(np.__version__))
print("matplotlib version: {}".format(mpl.__version__))
print("flopy version: {}".format(flopy.__version__))
print(f"numpy version: {np.__version__}")
print(f"matplotlib version: {mpl.__version__}")
print(f"flopy version: {flopy.__version__}")

# +
# temporary directory
Expand Down Expand Up @@ -78,7 +78,7 @@
raise ValueError("Failed to run.")

# plot heads for the drt model
hds = flopy.utils.HeadFile(os.path.join(m.model_ws, m.name + ".hds"))
hds = flopy.utils.HeadFile(os.path.join(m.model_ws, f"{m.name}.hds"))
hds.plot(colorbar=True)

# remove the drt package and create a standard drain file
Expand All @@ -98,7 +98,7 @@
raise ValueError("Failed to run.")

# plot the heads for the model with the drain
hds = flopy.utils.HeadFile(os.path.join(m.model_ws, m.name + ".hds"))
hds = flopy.utils.HeadFile(os.path.join(m.model_ws, f"{m.name}.hds"))
hds.plot(colorbar=True)

try:
Expand Down
6 changes: 3 additions & 3 deletions .docs/Notebooks/export_tutorial.py
Expand Up @@ -27,7 +27,7 @@
import flopy

print(sys.version)
print("flopy version: {}".format(flopy.__version__))
print(f"flopy version: {flopy.__version__}")
# -

# Load our old friend...the Freyberg model
Expand Down Expand Up @@ -60,12 +60,12 @@
pth = temp_dir.name

# export the whole model (inputs and outputs)
fnc = ml.export(os.path.join(pth, ml.name + ".in.nc"))
fnc = ml.export(os.path.join(pth, f"{ml.name}.in.nc"))

# export outputs using spatial reference info
hds = flopy.utils.HeadFile(os.path.join(model_ws, "freyberg.hds"))
flopy.export.utils.output_helper(
os.path.join(pth, ml.name + ".out.nc"), ml, {"hds": hds}
os.path.join(pth, f"{ml.name}.out.nc"), ml, {"hds": hds}
)

# ### Export an array to netCDF or shapefile
Expand Down
6 changes: 3 additions & 3 deletions .docs/Notebooks/export_vtk_tutorial.py
Expand Up @@ -41,7 +41,7 @@
import notebook_utils

print(sys.version)
print("flopy version: {}".format(flopy.__version__))
print(f"flopy version: {flopy.__version__}")
# -

# load model for examples
Expand Down Expand Up @@ -384,10 +384,10 @@
files = ["mp7p2.hds", "mp7p2.cbb"]
for f in files:
if os.path.isfile(modelpth / f):
msg = "Output file located: {}".format(f)
msg = f"Output file located: {f}"
print(msg)
else:
errmsg = "Error. Output file cannot be found: {}".format(f)
errmsg = f"Error. Output file cannot be found: {f}"
print(errmsg)

# +
Expand Down
24 changes: 12 additions & 12 deletions .docs/Notebooks/external_file_handling_tutorial.py
Expand Up @@ -32,8 +32,8 @@
from flopy.utils import flopy_io

print(sys.version)
print("numpy version: {}".format(np.__version__))
print("flopy version: {}".format(flopy.__version__))
print(f"numpy version: {np.__version__}")
print(f"flopy version: {flopy.__version__}")

# +
# make a model
Expand All @@ -57,7 +57,7 @@
vka = np.zeros_like(hk)
fnames = []
for i, h in enumerate(hk):
fname = os.path.join(array_dir, "hk_{0}.ref".format(i + 1))
fname = os.path.join(array_dir, f"hk_{i + 1}.ref")
fnames.append(fname)
np.savetxt(fname, h)
vka[i] = i + 1
Expand All @@ -84,7 +84,7 @@

# We see that a copy of the ``hk`` files as well as the important recharge file were made in the ```model_ws```.Let's looks at the ```lpf``` file

open(os.path.join(ml.model_ws, ml.name + ".lpf"), "r").readlines()[:20]
open(os.path.join(ml.model_ws, f"{ml.name}.lpf")).readlines()[:20]

# We see that the ```open/close``` approach was used - this is because ``ml.array_free_format`` is ``True``. Notice that ```vka``` is written internally

Expand Down Expand Up @@ -137,7 +137,7 @@
vka = np.zeros_like(hk)
fnames = []
for i, h in enumerate(hk):
fname = os.path.join(array_dir, "hk_{0}.ref".format(i + 1))
fname = os.path.join(array_dir, f"hk_{i + 1}.ref")
fnames.append(fname)
np.savetxt(fname, h)
vka[i] = i + 1
Expand Down Expand Up @@ -189,7 +189,7 @@
vka = np.zeros_like(hk)
fnames = []
for i, h in enumerate(hk):
fname = os.path.join(array_dir, "hk_{0}.ref".format(i + 1))
fname = os.path.join(array_dir, f"hk_{i + 1}.ref")
fnames.append(fname)
np.savetxt(fname, h)
vka[i] = i + 1
Expand All @@ -206,16 +206,16 @@

# We see that now the external arrays are being handled through the name file. Let's look at the name file

open(os.path.join(ml.model_ws, ml.name + ".nam"), "r").readlines()
open(os.path.join(ml.model_ws, f"{ml.name}.nam")).readlines()

# ### Free and binary format

ml.dis.botm[0].format.binary = True
ml.write_input()

open(os.path.join(ml.model_ws, ml.name + ".nam"), "r").readlines()
open(os.path.join(ml.model_ws, f"{ml.name}.nam")).readlines()

open(os.path.join(ml.model_ws, ml.name + ".dis"), "r").readlines()
open(os.path.join(ml.model_ws, f"{ml.name}.dis")).readlines()

# ### The ```.how``` attribute
# ```Util2d``` includes a ```.how``` attribute that gives finer grained control of how arrays will written
Expand All @@ -240,11 +240,11 @@

ml.write_input()

open(os.path.join(ml.model_ws, ml.name + ".dis"), "r").readlines()
open(os.path.join(ml.model_ws, f"{ml.name}.dis")).readlines()

open(os.path.join(ml.model_ws, ml.name + ".lpf"), "r").readlines()
open(os.path.join(ml.model_ws, f"{ml.name}.lpf")).readlines()

open(os.path.join(ml.model_ws, ml.name + ".nam"), "r").readlines()
open(os.path.join(ml.model_ws, f"{ml.name}.nam")).readlines()

try:
# ignore PermissionError on Windows
Expand Down
8 changes: 4 additions & 4 deletions .docs/Notebooks/feat_working_stack_examples.py
Expand Up @@ -40,10 +40,10 @@
import flopy

print(sys.version)
print("numpy version: {}".format(np.__version__))
print("matplotlib version: {}".format(mpl.__version__))
print("pandas version: {}".format(pd.__version__))
print("flopy version: {}".format(flopy.__version__))
print(f"numpy version: {np.__version__}")
print(f"matplotlib version: {mpl.__version__}")
print(f"pandas version: {pd.__version__}")
print(f"flopy version: {flopy.__version__}")
# -

# ### Model Inputs
Expand Down
8 changes: 4 additions & 4 deletions .docs/Notebooks/get_transmissivities_example.py
Expand Up @@ -39,9 +39,9 @@
import flopy

print(sys.version)
print("numpy version: {}".format(np.__version__))
print("matplotlib version: {}".format(mpl.__version__))
print("flopy version: {}".format(flopy.__version__))
print(f"numpy version: {np.__version__}")
print(f"matplotlib version: {mpl.__version__}")
print(f"flopy version: {flopy.__version__}")
# -

# ### Make up some open interval tops and bottoms and some heads
Expand Down Expand Up @@ -104,7 +104,7 @@
fig, ax = plt.subplots()
plt.plot(m.dis.top.array[r, c], label="model top")
for i, l in enumerate(m.dis.botm.array[:, r, c]):
label = "layer {} bot".format(i + 1)
label = f"layer {i + 1} bot"
if i == m.nlay - 1:
label = "model bot"
plt.plot(l, label=label)
Expand Down
8 changes: 4 additions & 4 deletions .docs/Notebooks/grid_intersection_example.py
Expand Up @@ -60,10 +60,10 @@
from flopy.utils import GridIntersect

print(sys.version)
print("numpy version: {}".format(np.__version__))
print("matplotlib version: {}".format(mpl.__version__))
print("flopy version: {}".format(flopy.__version__))
print("shapely version: {}".format(shapely.__version__))
print(f"numpy version: {np.__version__}")
print(f"matplotlib version: {mpl.__version__}")
print(f"flopy version: {flopy.__version__}")
print(f"shapely version: {shapely.__version__}")
# -

# ## <a id="gridclass"></a>[GridIntersect Class](#top)
Expand Down
28 changes: 13 additions & 15 deletions .docs/Notebooks/gridgen_example.py
Expand Up @@ -45,9 +45,9 @@
from flopy.utils.gridgen import Gridgen

print(sys.version)
print("numpy version: {}".format(np.__version__))
print("matplotlib version: {}".format(mpl.__version__))
print("flopy version: {}".format(flopy.__version__))
print(f"numpy version: {np.__version__}")
print(f"matplotlib version: {mpl.__version__}")
print(f"flopy version: {flopy.__version__}")
# -

# The Flopy GRIDGEN module requires that the gridgen executable can be called using subprocess **(i.e., gridgen is in your path)**.
Expand All @@ -62,9 +62,7 @@
print(msg)
else:
print(
"gridgen executable was found at: {}".format(
flopy_io.relpath_safe(gridgen_exe)
)
f"gridgen executable was found at: {flopy_io.relpath_safe(gridgen_exe)}"
)

# +
Expand All @@ -75,8 +73,8 @@
gridgen_ws = os.path.join(model_ws, "gridgen")
if not os.path.exists(gridgen_ws):
os.makedirs(gridgen_ws, exist_ok=True)
print("Model workspace is : {}".format(flopy_io.scrub_login(model_ws)))
print("Gridgen workspace is : {}".format(flopy_io.scrub_login(gridgen_ws)))
print(f"Model workspace is : {flopy_io.scrub_login(model_ws)}")
print(f"Gridgen workspace is : {flopy_io.scrub_login(gridgen_ws)}")
# -

# ## Basic Gridgen Operations
Expand Down Expand Up @@ -276,8 +274,8 @@
gwf, xt3doptions=True, save_specific_discharge=True
)
chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=chdspd)
budget_file = name + ".bud"
head_file = name + ".hds"
budget_file = f"{name}.bud"
head_file = f"{name}.hds"
oc = flopy.mf6.ModflowGwfoc(
gwf,
budget_filerecord=budget_file,
Expand Down Expand Up @@ -378,8 +376,8 @@
gwf, xt3doptions=True, save_specific_discharge=True
)
chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=chdspd)
budget_file = name + ".bud"
head_file = name + ".hds"
budget_file = f"{name}.bud"
head_file = f"{name}.hds"
oc = flopy.mf6.ModflowGwfoc(
gwf,
budget_filerecord=budget_file,
Expand All @@ -406,7 +404,7 @@
pmv.contour_array(
head, levels=[0.2, 0.4, 0.6, 0.8], linewidths=3.0, vmin=vmin, vmax=vmax
)
ax.set_title("Layer {}".format(ilay + 1))
ax.set_title(f"Layer {ilay + 1}")
pmv.plot_vector(spdis["qx"], spdis["qy"], color="white")
# -

Expand Down Expand Up @@ -452,7 +450,7 @@
raise ValueError("Failed to run.")

# head is returned as a list of head arrays for each layer
head_file = os.path.join(ws, name + ".hds")
head_file = os.path.join(ws, f"{name}.hds")
head = flopy.utils.HeadUFile(head_file).get_data()

# MODFLOW-USG does not have vertices, so we need to create
Expand All @@ -472,7 +470,7 @@
pmv.plot_array(head[ilay], cmap="jet", vmin=vmin, vmax=vmax)
pmv.plot_grid(colors="k", alpha=0.1)
pmv.contour_array(head[ilay], levels=[0.2, 0.4, 0.6, 0.8], linewidths=3.0)
ax.set_title("Layer {}".format(ilay + 1))
ax.set_title(f"Layer {ilay + 1}")
# -

try:
Expand Down
6 changes: 3 additions & 3 deletions .docs/Notebooks/groundwater2023_watershed_example.py
Expand Up @@ -39,9 +39,9 @@
from flopy.utils.voronoi import VoronoiGrid

print(sys.version)
print("numpy version: {}".format(np.__version__))
print("matplotlib version: {}".format(mpl.__version__))
print("flopy version: {}".format(flopy.__version__))
print(f"numpy version: {np.__version__}")
print(f"matplotlib version: {mpl.__version__}")
print(f"flopy version: {flopy.__version__}")

# import all plot style information from defaults.py
sys.path.append("../common")
Expand Down

0 comments on commit 879c153

Please sign in to comment.