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

TTim plots #76

Merged
merged 17 commits into from
Nov 7, 2024
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
98 changes: 44 additions & 54 deletions docs/03examples/circareasink_example.ipynb

Large diffs are not rendered by default.

89 changes: 58 additions & 31 deletions docs/03examples/compare_wells_linesink.ipynb

Large diffs are not rendered by default.

79 changes: 54 additions & 25 deletions docs/03examples/line_sink_well_sol.ipynb

Large diffs are not rendered by default.

24 changes: 10 additions & 14 deletions docs/03examples/meandering_river.ipynb

Large diffs are not rendered by default.

67 changes: 46 additions & 21 deletions docs/03examples/ttim_exercise1_sol.ipynb

Large diffs are not rendered by default.

150 changes: 67 additions & 83 deletions docs/03examples/well_example.ipynb

Large diffs are not rendered by default.

67 changes: 22 additions & 45 deletions docs/03examples/well_near_wall.ipynb

Large diffs are not rendered by default.

45 changes: 22 additions & 23 deletions docs/03examples/wells_in_different_systems.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Quick Example
ml.solve()

# Plot head contours at t=2 days
ml.contour(win=[-30, 55, -30, 30], ngr=40, t=2, labels=True, decimals=1)
ml.plots.contour(win=[-30, 55, -30, 30], ngr=40, t=2, labels=True, decimals=1)


.. tab-item:: Result
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ classifiers = [
"Operating System :: MacOS",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Scientific/Engineering :: Hydrology",
]
Expand Down
6 changes: 4 additions & 2 deletions ttim/circareasink.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ def disvecinf(self, x, y, aq=None):
qy[:] = qr * (y - self.yc) / r
return qx, qy

def plot(self):
plt.plot(
def plot(self, ax=None):
if ax is None:
_, ax = plt.subplots()
ax.plot(
self.xc + self.R * np.cos(np.linspace(0, 2 * np.pi, 100)),
self.yc + self.R * np.sin(np.linspace(0, 2 * np.pi, 100)),
"k",
Expand Down
2 changes: 1 addition & 1 deletion ttim/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,5 @@ def run_after_solve(self):
"""
pass

def plot(self):
def plot(self, ax=None):
pass
12 changes: 8 additions & 4 deletions ttim/linedoublet.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ def disvecinf(self, x, y, aq=None):
rvy.shape = (self.nparam, aq.naq, self.model.npval)
return rvx, rvy

def plot(self):
plt.plot([self.x1, self.x2], [self.y1, self.y2], "k")
def plot(self, ax=None):
if ax is None:
_, ax = plt.subplots()
ax.plot([self.x1, self.x2], [self.y1, self.y2], "k")


class LeakyLineDoublet(LineDoubletHoBase, LeakyWallEquation):
Expand Down Expand Up @@ -376,5 +378,7 @@ def disvecinf(self, x, y, aq=None):
rvy[i * ld.nparam : (i + 1) * ld.nparam, :] = qy
return rvx, rvy

def plot(self):
plt.plot(self.xldlayout, self.yldlayout, "k")
def plot(self, ax=None):
if ax is None:
_, ax = plt.subplots()
ax.plot(self.xldlayout, self.yldlayout, "k")
16 changes: 10 additions & 6 deletions ttim/linesink.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ def headinside(self, t):
:, np.newaxis
] * self.discharge(t)

def plot(self):
plt.plot([self.x1, self.x2], [self.y1, self.y2], "k")
def plot(self, ax=None):
if ax is None:
_, ax = plt.subplots()
ax.plot([self.x1, self.x2], [self.y1, self.y2], "k")


class LineSink(LineSinkBase):
Expand Down Expand Up @@ -442,8 +444,8 @@ def headinside(self, t, derivative=0):
)
return rv

def plot(self):
plt.plot(self.xlslayout, self.ylslayout, "k")
def plot(self, ax):
ax.plot(self.xlslayout, self.ylslayout, "k")

def run_after_solve(self):
for i in range(self.nls):
Expand Down Expand Up @@ -998,8 +1000,10 @@ def headinside(self, t):
:, np.newaxis
] * self.discharge(t)

def plot(self):
plt.plot([self.x1, self.x2], [self.y1, self.y2], "k")
def plot(self, ax=None):
if ax is None:
_, ax = plt.subplots()
ax.plot([self.x1, self.x2], [self.y1, self.y2], "k")


class HeadLineSinkHo(LineSinkHoBase, HeadEquationNores):
Expand Down
28 changes: 24 additions & 4 deletions ttim/model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# from .invlap import *
import inspect # Used for storing the input
from warnings import warn

import numpy as np

Expand All @@ -8,10 +9,10 @@

# from .bessel import *
from .invlapnumba import compute_laplace_parameters_numba, invlap, invlapcomp
from .util import PlotTtim
from .plots import PlotTtim


class TimModel(PlotTtim):
class TimModel:
def __init__(
self,
kaq=[1, 1],
Expand Down Expand Up @@ -68,6 +69,25 @@ def __init__(
if self.timmlmodel is not None:
self.timmlmodel.solve()

self.plots = PlotTtim(self)
self.plot = self.plots.topview

# NOTE: reinstate later, after deprecation below is removed?
# self.xsection = self.plots.xsection

def xsection(*args, **kwargs):
raise DeprecationWarning(
"This method is deprecated. Use `ml.plots.head_along_line()` instead."
)

def contour(self, *args, **kwargs):
warn(
category=DeprecationWarning,
message="This method is deprecated. Use `ml.plots.contour()` instead.",
stacklevel=1,
)
self.plots.contour(*args, **kwargs)

def __repr__(self):
return "Model"

Expand Down Expand Up @@ -349,7 +369,7 @@ def velocomp(self, x, y, z, t, aq=None, layer_ltype=None):
)
qz = (h[1, 0] - h[0, 0]) / aq.c[
layer
] # TO DO include storage in leaky layer
] # TODO: include storage in leaky layer
vz = qz / aq.porll[layer]
else: # in aquifer layer
h = self.head(x, y, t, layers=layer, aq=aq, neglect_steady=True)
Expand Down Expand Up @@ -387,7 +407,7 @@ def velocomp(self, x, y, z, t, aq=None, layer_ltype=None):
)[:, 0]
# this works because c[0] = 1e100 for impermeable top
qztop = (h[1] - h[0]) / self.aq.c[layer]
# TO DO modify for infiltration in top aquifer
# TODO: modify for infiltration in top aquifer
# if layer == 0:
# qztop += self.qztop(x, y)
if layer < aq.naq - 1:
Expand Down
Loading