Skip to content

Commit c19ecbd

Browse files
mbakker7dbrakenhoffMattBrst
authored
Update Master branch to TTim version 0.7.1
Some bug fixes and minor improvements: * Add inhomogeneity name to crosssection plot (1D inhom) (#90) * Added 'names' in plotting of inhom * Bugfix for old method of selecting layers (#92) * Specify step for Jacobian (#95) --------- Co-authored-by: Davíd Brakenhoff <d.brakenhoff@artesia-water.nl> Co-authored-by: Mattijs Borst <41747007+MattBrst@users.noreply.github.com>
1 parent 9bd9c51 commit c19ecbd

8 files changed

+146
-134
lines changed

docs/03examples/watex_example.ipynb

+101-99
Large diffs are not rendered by default.

ttim/besselnumba.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def bessells_gauss(x, y, z1, z2, lab):
364364

365365
@numba.njit(nogil=True, cache=True)
366366
def bessellsuni(x, y, z1, z2, lab):
367-
"""bessellsuni.
367+
"""Bessellsuni.
368368
369369
# Uniform strength
370370
implicit none
@@ -402,7 +402,7 @@ def bessellsuni(x, y, z1, z2, lab):
402402

403403
@numba.njit(nogil=True, cache=True)
404404
def bessellsuniv(x, y, z1, z2, lab, rzero):
405-
"""bessellsuniv.
405+
"""Bessellsuniv.
406406
407407
# Uniform strength
408408
implicit none
@@ -513,7 +513,7 @@ def find_d1d2(z1, z2, zc, R):
513513

514514
@numba.njit(nogil=True, cache=True)
515515
def bessells(x, y, z1, z2, lab, order, d1in, d2in):
516-
"""bessells.
516+
"""Bessells.
517517
518518
implicit none
519519
integer, intent(in) :: order
@@ -783,7 +783,7 @@ def bessellsqxqyv2(x, y, z1, z2, lab, order, R):
783783

784784
@numba.njit(nogil=True, cache=True)
785785
def bessellsqxqy(x, y, z1, z2, lab, order, d1in, d2in):
786-
"""bessellsqxqy.
786+
"""Bessellsqxqy.
787787
788788
implicit none
789789
integer, intent(in) :: order
@@ -1240,7 +1240,7 @@ def besselldv2(x, y, z1, z2, lab, order, R):
12401240

12411241
@numba.njit(nogil=True, cache=True)
12421242
def besselld(x, y, z1, z2, lab, order, d1in, d2in):
1243-
"""besselld.
1243+
"""Besselld.
12441244
12451245
implicit none
12461246
integer, intent(in) :: order
@@ -1495,7 +1495,7 @@ def besselldqxqyv2(x, y, z1, z2, lab, order, R):
14951495

14961496
@numba.njit(nogil=True, cache=True)
14971497
def besselldqxqy(x, y, z1, z2, lab, order, d1in, d2in):
1498-
"""besselldqxqy.
1498+
"""Besselldqxqy.
14991499
15001500
implicit none
15011501
integer, intent(in) :: order
@@ -1816,7 +1816,7 @@ def besselld_gauss_ho_qxqy(x, y, z1, z2, lab, order):
18161816

18171817
@numba.njit(nogil=True, cache=True)
18181818
def besselldpart(x, y, z1, z2, lab, order, d1, d2):
1819-
"""besselldpart.
1819+
"""Besselldpart.
18201820
18211821
implicit none
18221822
integer, intent(in) :: order

ttim/besselnumba_total.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def lapls_int_ho(x, y, z1, z2, order):
533533

534534
@numba.njit(nogil=True, cache=True)
535535
def bessellsreal(x, y, x1, y1, x2, y2, lab):
536-
"""bessellsreal.
536+
"""Bessellsreal.
537537
538538
implicit none
539539
real(kind=8), intent(in) :: x,y,x1,y1,x2,y2,lab
@@ -596,7 +596,7 @@ def bessellsreal(x, y, x1, y1, x2, y2, lab):
596596

597597
@numba.njit(nogil=True, cache=True)
598598
def bessellsrealho(x, y, x1, y1, x2, y2, lab, order):
599-
"""bessellsrealho.
599+
"""Bessellsrealho.
600600
601601
implicit none
602602
real(kind=8), intent(in) :: x,y,x1,y1,x2,y2,lab
@@ -1183,7 +1183,7 @@ def bessells_gauss_ho_qxqy_d1d2(x, y, z1, z2, lab, order, d1, d2):
11831183

11841184
@numba.njit(nogil=True, cache=True)
11851185
def bessells(x, y, z1, z2, lab, order, d1in, d2in):
1186-
"""bessells.
1186+
"""Bessells.
11871187
11881188
implicit none
11891189
integer, intent(in) :: order
@@ -1229,7 +1229,7 @@ def bessells(x, y, z1, z2, lab, order, d1in, d2in):
12291229

12301230
@numba.njit(nogil=True, cache=True)
12311231
def bessellsv(x, y, z1, z2, lab, order, R, nlab):
1232-
"""bessellsv.
1232+
"""Bessellsv.
12331233
12341234
implicit none
12351235
integer, intent(in) :: order
@@ -1278,7 +1278,7 @@ def bessellsv2(x, y, z1, z2, lab, order, R, nlab):
12781278

12791279
@numba.njit(nogil=True, cache=True)
12801280
def bessellsqxqy(x, y, z1, z2, lab, order, d1in, d2in):
1281-
"""bessellsqxqy.
1281+
"""Bessellsqxqy.
12821282
12831283
implicit none
12841284
integer, intent(in) :: order
@@ -1328,7 +1328,7 @@ def bessellsqxqy(x, y, z1, z2, lab, order, d1in, d2in):
13281328

13291329
@numba.njit(nogil=True, cache=True)
13301330
def bessellsqxqyv(x, y, z1, z2, lab, order, R, nlab):
1331-
"""bessellsqxqyv.
1331+
"""Bessellsqxqyv.
13321332
13331333
implicit none
13341334
integer, intent(in) :: order
@@ -1382,7 +1382,7 @@ def bessellsqxqyv2(x, y, z1, z2, lab, order, R, nlab):
13821382

13831383
@numba.njit(nogil=True, cache=True)
13841384
def bessellsuni(x, y, z1, z2, lab):
1385-
"""bessellsuni.
1385+
"""Bessellsuni.
13861386
13871387
# Uniform strength
13881388
implicit none
@@ -1420,7 +1420,7 @@ def bessellsuni(x, y, z1, z2, lab):
14201420

14211421
@numba.njit(nogil=True, cache=True)
14221422
def bessellsuniv(x, y, z1, z2, lab, nlab):
1423-
"""bessellsuniv.
1423+
"""Bessellsuniv.
14241424
14251425
# Uniform strength
14261426
implicit none
@@ -1777,7 +1777,7 @@ def besselld_gauss_ho_d1d2(x, y, z1, z2, lab, order, d1, d2):
17771777

17781778
@numba.njit(nogil=True, cache=True)
17791779
def besselld(x, y, z1, z2, lab, order, d1in, d2in):
1780-
"""besselld.
1780+
"""Besselld.
17811781
17821782
implicit none
17831783
integer, intent(in) :: order
@@ -1824,7 +1824,7 @@ def besselld(x, y, z1, z2, lab, order, d1in, d2in):
18241824

18251825
@numba.njit(nogil=True, cache=True)
18261826
def besselldv(x, y, z1, z2, lab, order, R, nlab):
1827-
"""besselldv.
1827+
"""Besselldv.
18281828
18291829
implicit none
18301830
integer, intent(in) :: order
@@ -1875,7 +1875,7 @@ def besselldv2(x, y, z1, z2, lab, order, R, nlab):
18751875

18761876
# @numba.njit(nogil=True, cache=True)
18771877
def besselldpart(x, y, z1, z2, lab, order, d1, d2):
1878-
"""besselldpart.
1878+
"""Besselldpart.
18791879
18801880
implicit none
18811881
integer, intent(in) :: order
@@ -2256,7 +2256,7 @@ def besselld_gauss_ho_qxqy_d1d2(x, y, z1, z2, lab, order, d1, d2):
22562256

22572257
# @numba.njit(nogil=True, cache=True)
22582258
def besselldqxqy(x, y, z1, z2, lab, order, d1in, d2in):
2259-
"""besselldqxqy.
2259+
"""Besselldqxqy.
22602260
22612261
implicit none
22622262
integer, intent(in) :: order
@@ -2308,7 +2308,7 @@ def besselldqxqy(x, y, z1, z2, lab, order, d1in, d2in):
23082308

23092309
# @numba.njit(nogil=True, cache=True)
23102310
def besselldqxqyv(x, y, z1, z2, lab, order, R, nlab):
2311-
"""besselldqxqyv.
2311+
"""Besselldqxqyv.
23122312
23132313
implicit none
23142314
integer, intent(in) :: order

ttim/circinhom.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ def initialize(self):
198198
self.aqin = self.model.aq.findAquiferData(
199199
self.x0 + (1 - 1e-8) * self.R, self.y0
200200
)
201-
assert (
202-
self.aqin.R == self.R
203-
), "Radius of CircInhom and CircInhomData must be equal"
201+
assert self.aqin.R == self.R, (
202+
"Radius of CircInhom and CircInhomData must be equal"
203+
)
204204
self.aqout = self.model.aq.find_aquifer_data(
205205
self.x0 + (1 + 1e-8) * self.R, self.y0
206206
)

ttim/fit.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import pandas as pd
88
from scipy.optimize import least_squares, leastsq
99

10-
# import lmfit
11-
1210

1311
class Calibrate:
1412
def __init__(self, model):
@@ -96,7 +94,7 @@ def set_parameter(
9694
from_lay = int(layers_from_name[0])
9795
to_lay = from_lay + 1
9896
elif len(layers_from_name) == 2:
99-
from_lay, to_lay = layers_from_name
97+
from_lay, to_lay = map(int, layers_from_name)
10098

10199
# get aquifer information and create list if necessary
102100
if inhoms is None:
@@ -168,9 +166,9 @@ def set_parameter_by_reference(
168166
"""
169167
assert isinstance(name, str), "Error: name must be string"
170168
if parameter is not None:
171-
assert isinstance(
172-
parameter, np.ndarray
173-
), "Error: parameter needs to be numpy array"
169+
assert isinstance(parameter, np.ndarray), (
170+
"Error: parameter needs to be numpy array"
171+
)
174172
p = parameter
175173
self.parameters.loc[name] = {
176174
"optimal": initial,
@@ -311,13 +309,13 @@ def fit_lmfit(self, report=False, printdot=True, **kwargs):
311309
for name in self.parameters.index:
312310
p = self.parameters.loc[name]
313311
self.lmfitparams.add(name, value=p["initial"], min=p["pmin"], max=p["pmax"])
314-
# fit_kws = {"epsfcn": 1e-4}
312+
fit_kws = {"epsfcn": 1e-4} # this is essential to specify step for the Jacobian
315313
self.fitresult = lmfit.minimize(
316314
self.residuals_lmfit,
317315
self.lmfitparams,
318316
method="leastsq",
319317
kws={"printdot": printdot},
320-
# **fit_kws,
318+
**fit_kws,
321319
**kwargs,
322320
)
323321
print("", flush=True)

ttim/inhom1d.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def create_elements(self):
196196
)
197197
HstarXsection(self.model, self.x1, self.x2, tsandhstar=self.tsandhstar)
198198

199-
def plot(self, ax=None, labels=False, params=False, **kwargs):
199+
def plot(self, ax=None, labels=False, params=False, names=False, **kwargs):
200200
"""Plot the cross-section.
201201
202202
Parameters
@@ -207,6 +207,8 @@ def plot(self, ax=None, labels=False, params=False, **kwargs):
207207
If True, add layer-name labels.
208208
params : bool, optional
209209
If True, add parameter labels.
210+
names : bool, optional
211+
If True, add inhomogeneity names.
210212
"""
211213
if ax is None:
212214
_, ax = plt.subplots(1, 1, figsize=(8, 4))
@@ -230,6 +232,17 @@ def plot(self, ax=None, labels=False, params=False, **kwargs):
230232
lli = None
231233
aqi = None
232234

235+
if names:
236+
ax.text(
237+
r0 + 0.5 * r,
238+
0.95,
239+
self.name,
240+
ha="center",
241+
va="center",
242+
fontsize=10,
243+
transform=ax.get_xaxis_transform(),
244+
)
245+
233246
for i in range(self.nlayers):
234247
if self.ltype[i] == "l":
235248
ax.fill_between(

ttim/plots.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ def xsection(
153153
if params and self._ml.aq.ltype[i] == "a":
154154
if aqi == 0 and self._ml.aq.phreatictop:
155155
paramtxt = (
156-
f"$k_h$ = {self._ml.aq.kaq[aqi]}, "
157-
f"$S$ = {self._ml.aq.Saq[aqi]}"
156+
f"$k_h$ = {self._ml.aq.kaq[aqi]}, $S$ = {self._ml.aq.Saq[aqi]}"
158157
)
159158
else:
160159
paramtxt = (

ttim/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from importlib import import_module, metadata
22
from platform import python_version
33

4-
__version__ = "0.7.0"
4+
__version__ = "0.7.1"
55

66

77
def show_versions(optional=True) -> None:

0 commit comments

Comments
 (0)