-
Notifications
You must be signed in to change notification settings - Fork 5
/
ths.py
325 lines (233 loc) · 10.3 KB
/
ths.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 5 15:55:54 2017
@author: pianarol
"""
import scipy as sp
import math
import numpy as np
import hypy as hp
import matplotlib.pyplot as plt
###Contains all the functions of the module ths####
####function dim ###
def dim(p,t):
'''THS_DIM - Compute drawdown with the Theis (1935) solution
Syntax: s = hp.ths.dim( p, t)
p(1) = a = slope of Jacob Straight Line in meters
p(2) = t0 = intercept with the horizontal axis for s = 0
t = measured time
s = measured drawdown
Description:
The Theis (1935) solution assumes that the aquifer is confined,
homogeneous, isotropic, and infinite. The well as radius that is
negligible. It is pumped at a constant rate Q and is 100 percent
efficient.
Under these assumptions, Theis solution can be expressed as:
s(r,t) = Q/(4 pi T) E1( r2S / 4Tt)
where Q is the pumping rate, T the transmissivity, r the radial
distance between the pumping well and the observation well,
S the storativity coefficient and t the time.
To interpret field data with the Theis solution, it is expressed as a
function of two fitting parameters a and to which are defined as:
a = 0.183 Q /T
t0 = r2 S / 2.25 T
Example:
s = ths_dim( p,t )
See also: ths_dmo, ths_gss, ths_rpt'''
td = []
for i in range(0, len(t)):
td.append(0.5628*p[1]/t[i])
s = p[0]/math.log(10)*sp.special.expn(1,td)
tdn = [ -x for x in td]
d = p[0]/math.log(10)*np.exp(tdn)
return s
####function dls ###
def dls(td):
'''THS_DLS - Dimensionless drawdown of the Theis model
Syntax: sd,dd = hp.ths.dls(td)
Description:
Calculates the dimensionless drawdown sd and the dimensionless
derivative dd for a given dimensionless reduced time td/rd^2
See also: ths_lap'''
td2 = []
dd = []
for i in range(0, len(td)):
td2.append((0.25/td[i]))
dd.append(0.5*np.exp(-1.0*td2[i]))
sd = 0.5*sp.special.expn(1,td2)
return sd, dd
####function drw ###
##Not sure if useful and coded right
#def drw():
# '''THS_DRW - Type curves of the Theis model.
#
# Syntax: hp.ths.drw()
#
# Description:
# Draw a series of type curves of Theis (1935)
#
# See also: ths_dim, ths_dls
#'''
#
# td = np.logspace(-1, 4)
# sd, dd = dls(td)
# fig = plt.figure()
#
# ax1 = fig.add_subplot(111)
#
#
# ax1.set_xlabel(r'$t_{D}/r²_{D} = T t / S r²$')
# ax1.set_ylabel(r'$s_{D} = 2*\pi*s/Q$')
#
# ax1.loglog(td,sd, c='b', label='Theis')
# ax1.plot(td,dd, c='r', linestyle = '--', label='Derivative')
# ax1.legend()
#
# plt.show()
#
# fig2 = plt.figure()
# sj = hp.jcb.dls(td)
# ax2 = fig2.add_subplot(111)
#
#
# ax2.set_xlabel(r'$t_{D}/r²_{D}$')
# ax2.set_ylabel(r'$s_{D}$')
#
# ax2.semilogx(td,sd, c='b', linestyle = '--', label='Theis')
# ax2.plot(td,sj, c='r', label='Jacob')
# ax2.legend()
#
# plt.show()
### function gss ###
def gss(t,s):
'''THS_GSS - First guess for the parameters of the Theis model.
Syntax: p = hp.ths.gss(t,s)
p(1) = a = slope of Jacob straight line for late time
p(2) = t0 = intercept with the horizontal axis for s = 0
t = time
s = drawdown
Description:
First guess for the parameters of theis solution
See also: ths_dim, ths_dmo, ths_rpt, ezwt'''
if np.shape(t) == 1:
t = np.transpose(t)
s = np.transpose(s) #contrôler si c'est ce qui est souhaité
n = round(len(t)/3)
t = t[n:len(t)]
s = s[n:len(s)]
p = hp.jcb.gss(t,s)
return p
### function jac ###
def jac(p,t):
'''THS_JAC - Jacobian matrix of the Theis function
Syntax: j = hp.ths.jac( p, t)
j(1,:) = ds / dp(1)
j(2,:) = ds / dp(2)
'''
td = []
for i in range(0, len(t)):
td.append(0.5625*p[1]/t[i])
j1 = []
for i in range(0, len(td)):
j1.append(sp.special.expn(1,td[i])/math.log(10))
tdn = [-x for x in td]
j2 = []
for i in range(0, len(td)):
j2.append(p[0]*np.exp(tdn[i])/math.log(10)/p[1])
j = [j1,j2]
return j
###unfction rpt ###
def rpt(p,t,s,d, name, ttle = 'Interference test', Author = 'My name', Rapport = 'My Rapport', filetype = 'img'):
'''THS_RPT - Reports graphically the results of a pumping test interpreted with the Theis (1935) model.
Syntax: hp.ths.rpt( p, t, s, d, name, ttle, Author, Rapport, filetype )
p = parameters of the model
p(1) = a = slope of the straight line
p(2) = t0 = intercept with the horizontal axis for s = 0
t = measured time % s = measured drawdown
d(1) = q = Pumping rate
d(2) = r = distance from the pumping well
ttle = Title of the figure
Description:
Produces the final figure and results for Theis model (1935).
See also: ths_dmo, ths_dim, ths_gss'''
#rename the parameters for a more intuitive check of the formulas
a = p[0]
t0 = p[1]
q = d[0]
r = d[1]
#Compute the transmissivity, storativity and radius of influence
T = 0.1832339*q/a
S = 2.458394*T*t0/r**2
Ri = 2*math.sqrt(T*t[len(t)-1]/S)
#Calls an internalscript that computes drawdown, derivative and residuals
#script rpt.cmp
tc,sc,mr,sr,rms = hp.script.cmp(p,t,s,'ths')
#script rpt_plt
#calculate the derivative of the data
td, sd = hp.ldiffs(t,s, npoints=30)
#keep only positive derivatives
td, sd = hp.hyclean(td,sd)
#compute the derivative of the model
tdc,sdc = hp.ldiff(tc,sc)
#keep only positive derivatives
tdc,sdc = hp.hyclean(tdc,sdc)
#plots the data and model in bi-logarithmic scale
if filetype == 'pdf':
fig = plt.figure()
fig.set_size_inches(8, 6)
fig.text(0.125, 1, Author, fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.125, 0.95, Rapport, fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.125, -0.05, 'Test Data : ', fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.1, 'Discharge rate : {:3.2e} m³/s'.format(q), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.15, 'Radial distance : {:0.2g} m '.format(r), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.125, -0.25, 'Hydraulic parameters :', fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.3, 'Transmissivity T : {:3.2e} m²/s'.format(T), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.35, 'Storativity S : {:3.2e} '.format(S), fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.40, 'Radius of Investigation Ri : {:0.2g} m'.format(Ri) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.125, -0.5, 'Fitting parameters :' , fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.55, 'slope a : {:0.2g} m '.format(a) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.60, 'intercept t0 : {:0.2g} m'.format(t0) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.65, 'mean residual : {:0.2g} m'.format(mr) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.135, -0.70, '2 standard deviation : {:0.2g} m'.format(sr) , fontsize=14, transform=plt.gcf().transFigure)
ax1 = fig.add_subplot(111)
ax1.set_xlabel('Time in seconds')
ax1.set_ylabel('Drawdown in meters')
ax1.set_title(ttle)
ax1.loglog(t, s, c='r',marker = '+', linestyle = '', label = 'drawdown')
ax1.loglog(td, sd, c='b',marker = 'x', linestyle = '', label = 'Derivative')
ax1.loglog(tc, sc, c='g', label = 'Theis (1935) Model')
ax1.loglog(tdc, sdc, c='y', label = 'Model derivative')
ax1.grid(True)
ax1.legend()
plt.show()
fig.savefig('ths_rapport.pdf', bbox_inches = 'tight')
if filetype == 'img':
fig = plt.figure()
fig.set_size_inches(8, 6)
fig.text(0.125, 1, Author, fontsize=14, transform=plt.gcf().transFigure)
fig.text(0.125, 0.95, Rapport, fontsize=14, transform=plt.gcf().transFigure)
fig.text(1, 0.85, 'Test Data : ', fontsize=14, transform=plt.gcf().transFigure)
fig.text(1.05, 0.8, 'Discharge rate : {:3.2e} m³/s'.format(q), fontsize=14, transform=plt.gcf().transFigure)
fig.text(1.05, 0.75, 'Radial distance : {:0.2g} m '.format(r), fontsize=14, transform=plt.gcf().transFigure)
fig.text(1, 0.65, 'Hydraulic parameters :', fontsize=14, transform=plt.gcf().transFigure)
fig.text(1.05, 0.6, 'Transmissivity T : {:3.2e} m²/s'.format(T), fontsize=14, transform=plt.gcf().transFigure)
fig.text(1.05, 0.55, 'Storativity S : {:3.2e} '.format(S), fontsize=14, transform=plt.gcf().transFigure)
fig.text(1.05, 0.5, 'Radius of Investigation Ri : {:0.2g} m'.format(Ri) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(1, 0.4, 'Fitting parameters :' , fontsize=14, transform=plt.gcf().transFigure)
fig.text(1.05, 0.35, 'slope a : {:0.2g} m '.format(a) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(1.05, 0.3, 'intercept t0 : {:0.2g} m'.format(t0) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(1.05, 0.25, 'mean residual : {:0.2g} m'.format(mr) , fontsize=14, transform=plt.gcf().transFigure)
fig.text(1.05, 0.2, '2 standard deviation : {:0.2g} m'.format(sr) , fontsize=14, transform=plt.gcf().transFigure)
ax1 = fig.add_subplot(111)
ax1.set_xlabel('Time in seconds')
ax1.set_ylabel('Drawdown in meters')
ax1.set_title(ttle)
ax1.loglog(t, s, c='r',marker = '+', linestyle = '', label = 'drawdown')
ax1.loglog(td, sd, c='b',marker = 'x', linestyle = '', label = 'Derivative')
ax1.loglog(tc, sc, c='g', label = 'Theis (1935) Model')
ax1.loglog(tdc, sdc, c='y', label = 'Model derivative')
ax1.grid(True)
ax1.legend()
plt.show()
fig.savefig('ths_rapport.png', bbox_inches = 'tight')