Skip to content

Commit a8c680b

Browse files
committed
add comparison of tpl-gaussian and matern models
1 parent 0e9beb7 commit a8c680b

9 files changed

+155
-2
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ The workflow is organized by the following structure:
3131
- `03_literature_transmissivities.py` - comparision of drawdowns for different
3232
transimissivites from literature
3333
- `04_trans_plot.py` - plot a realization of a TPL transmissivity field
34+
- `05_KTPL_plot.py` - plot K_TPL for different dimensions
35+
- `06_tplgaussian_vs_matern.py` - comparison of TPL-Gaussian and Matern models
3436
- `comparison/` - scripts for the comparison of ensemble mean to effective TPL heads
3537
- `00_run_sim_mpi.sh` - bash file running `01_run_sim.py` in parallel
3638
- `01_run_sim.py` - run all ensemble simulations for pumping tests on TPL aquifers
@@ -43,7 +45,7 @@ The workflow is organized by the following structure:
4345
Main Python dependencies are stored in `requirements.txt`:
4446

4547
```
46-
gstools==1.2.1
48+
gstools==1.3.0
4749
anaflow==1.0.1
4850
ogs5py==1.1.1
4951
matplotlib

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
gstools==1.2.1
1+
gstools==1.3.0
22
anaflow==1.0.1
33
ogs5py==1.1.1
44
matplotlib

results/06_matern_tpl_1-5.pdf

92.6 KB
Binary file not shown.

results/07_matern_tpl_0-5.pdf

92.6 KB
Binary file not shown.

results/08_matern_family.pdf

94.2 KB
Binary file not shown.

results/09_tpl_family.pdf

94.2 KB
Binary file not shown.

results/10_field_matern_1-5.pdf

510 KB
Binary file not shown.

results/11_field_matern_0-5.pdf

593 KB
Binary file not shown.

src/06_tplgaussian_vs_matern.py

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
"""TPL-Gaussian model vs. Matern model family."""
2+
import os
3+
import numpy as np
4+
import matplotlib as mpl
5+
from matplotlib import pyplot as plt
6+
import gstools as gs
7+
8+
plt.style.use("default")
9+
mpl.rc("text", usetex=True)
10+
mpl.rc("lines", linewidth=3.5)
11+
plt.close("all")
12+
13+
14+
def dashes(i=1, max_d=12, space=1):
15+
"""Dashes for matplotlib."""
16+
return i * [space, space] + [max_d - 2 * i * space, space]
17+
18+
19+
def format_ax(axis):
20+
"""Format axis."""
21+
axis.set_xlim([-0.06, 3.06])
22+
axis.set_xticks(range(4))
23+
axis.set_xticklabels(["$0$", r"$\ell$", r"$2\ell$", r"$3\ell$"])
24+
axis.set_xlabel("distance")
25+
axis.set_ylabel("semivariance")
26+
axis.set_ylim([0, 1])
27+
axis.grid(linestyle=":")
28+
axis.legend()
29+
30+
31+
save = True
32+
x = np.geomspace(0.01, 3, 10)
33+
grid = np.linspace(0, 10, 100)
34+
35+
# Matern(nu=1.5) vs TPL-Gaussian
36+
37+
fig, ax = plt.subplots(figsize=[5, 3])
38+
39+
m1 = gs.Matern(dim=2, integral_scale=1, nu=1.5)
40+
fit_m1 = gs.TPLGaussian(dim=2)
41+
fit_m1.fit_variogram(x, m1.variogram(x), len_low=0, nugget=0)
42+
m1.plot(ax=ax, x_max=3, label="Matern(nu=1.5)", color="k", linewidth=2)
43+
fit_m1.plot(
44+
ax=ax, x_max=3, label="TPL-Gaussian(hurst=1.0)", linestyle=":", color="C0"
45+
)
46+
47+
print(m1)
48+
print(fit_m1)
49+
50+
format_ax(ax)
51+
fig.tight_layout()
52+
if save:
53+
fig.savefig(
54+
os.path.join("..", "results", "06_matern_tpl_1-5.pdf"), dpi=300
55+
)
56+
fig.show()
57+
58+
# Matern(nu=0.5) vs TPL-Gaussian
59+
60+
fig, ax = plt.subplots(figsize=[5, 3])
61+
62+
m2 = gs.Matern(dim=2, integral_scale=1, nu=0.5)
63+
fit_m2 = gs.TPLGaussian(dim=2)
64+
fit_m2.fit_variogram(x, m2.variogram(x), len_low=0, nugget=0)
65+
m2.plot(ax=ax, x_max=3, label="Matern(nu=0.5)", color="k", linewidth=2)
66+
fit_m2.plot(
67+
ax=ax, x_max=3, label="TPL-Gaussian(hurst=0.45)", linestyle=":", color="C0"
68+
)
69+
70+
print(m2)
71+
print(fit_m2)
72+
73+
format_ax(ax)
74+
fig.tight_layout()
75+
if save:
76+
fig.savefig(
77+
os.path.join("..", "results", "07_matern_tpl_0-5.pdf"), dpi=300
78+
)
79+
fig.show()
80+
81+
# model families
82+
83+
fig, ax = plt.subplots(figsize=[5, 3])
84+
85+
gau = gs.Gaussian(integral_scale=1)
86+
exp = gs.Exponential(integral_scale=1)
87+
nus = [0.5, 0.75, 1.0, 1.5, 2.0]
88+
# ax = exp.plot(ax=ax, x_max=3, linestyle="-.", color="k")
89+
ax = gau.plot(ax=ax, x_max=3, linestyle="-", color="k")
90+
for i, nu in enumerate(nus):
91+
m = gs.Matern(integral_scale=1, nu=nu)
92+
ax = m.plot(
93+
ax=ax,
94+
x_max=3,
95+
label=f"Matern(nu={nu:.2})",
96+
linewidth=2,
97+
dashes=dashes(i),
98+
color="C0",
99+
)
100+
format_ax(ax)
101+
fig.tight_layout()
102+
if save:
103+
fig.savefig(os.path.join("..", "results", "08_matern_family.pdf"), dpi=300)
104+
fig.show()
105+
106+
fig, ax = plt.subplots(figsize=[5, 3])
107+
108+
hursts = [0.45, 0.5, 0.6, 0.8, 0.999]
109+
# ax = exp.plot(ax=ax, x_max=3, linestyle="-.", color="k")
110+
ax = gau.plot(ax=ax, x_max=3, linestyle="-", color="k")
111+
for i, hurst in enumerate(hursts):
112+
m = gs.TPLGaussian(integral_scale=1, hurst=hurst)
113+
ax = m.plot(
114+
ax=ax,
115+
x_max=3,
116+
label=f"TPL-Gaussian(hurst={hurst:.2})",
117+
linewidth=2,
118+
dashes=dashes(i),
119+
color="C0",
120+
)
121+
format_ax(ax)
122+
fig.tight_layout()
123+
if save:
124+
fig.savefig(os.path.join("..", "results", "09_tpl_family.pdf"), dpi=300)
125+
fig.show()
126+
127+
# Fields
128+
129+
fig, ax = plt.subplots(figsize=[5, 4])
130+
srf = gs.SRF(m1, seed=1234)
131+
field1a = srf.structured((grid, grid))
132+
srf.plot(ax=ax, contour_plot=False)
133+
ax.set_title("Matern(nu=1.5)")
134+
fig.tight_layout()
135+
if save:
136+
fig.savefig(
137+
os.path.join("..", "results", "10_field_matern_1-5.pdf"), dpi=300
138+
)
139+
fig.show()
140+
141+
fig, ax = plt.subplots(figsize=[5, 4])
142+
srf = gs.SRF(m2, seed=1234)
143+
srf.structured((grid, grid))
144+
srf.plot(ax=ax, contour_plot=False)
145+
ax.set_title("Matern(nu=0.5)")
146+
fig.tight_layout()
147+
if save:
148+
fig.savefig(
149+
os.path.join("..", "results", "11_field_matern_0-5.pdf"), dpi=300
150+
)
151+
fig.show()

0 commit comments

Comments
 (0)