quick-pp 0.2.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. quick_pp/__init__.py +0 -0
  2. quick_pp/api/__init__.py +0 -0
  3. quick_pp/api/exceptions.py +61 -0
  4. quick_pp/api/fastapi_mlflow/__init__.py +1 -0
  5. quick_pp/api/fastapi_mlflow/_mlflow_types.py +59 -0
  6. quick_pp/api/fastapi_mlflow/applications.py +72 -0
  7. quick_pp/api/fastapi_mlflow/exceptions.py +22 -0
  8. quick_pp/api/fastapi_mlflow/predictors.py +96 -0
  9. quick_pp/api/main.py +90 -0
  10. quick_pp/api/mlflow_model_deployment.py +99 -0
  11. quick_pp/api/qpp_assistant.py +160 -0
  12. quick_pp/api/router.py +18 -0
  13. quick_pp/api/schemas/lithology_hc_correction.py +39 -0
  14. quick_pp/api/schemas/lithology_ssc.py +37 -0
  15. quick_pp/api/schemas/lithology_vsh_gr.py +25 -0
  16. quick_pp/api/schemas/permeability_choo.py +25 -0
  17. quick_pp/api/schemas/permeability_others.py +24 -0
  18. quick_pp/api/schemas/porosity.py +22 -0
  19. quick_pp/api/schemas/ressum.py +29 -0
  20. quick_pp/api/schemas/saturation_archie.py +25 -0
  21. quick_pp/api/schemas/saturation_b.py +24 -0
  22. quick_pp/api/schemas/saturation_qv.py +26 -0
  23. quick_pp/api/schemas/saturation_rw.py +24 -0
  24. quick_pp/api/schemas/saturation_temp_grad.py +24 -0
  25. quick_pp/api/schemas/saturation_waxman_smits.py +28 -0
  26. quick_pp/api/services/las_handler.py +136 -0
  27. quick_pp/api/services/lithology.py +278 -0
  28. quick_pp/api/services/permeability.py +252 -0
  29. quick_pp/api/services/porosity.py +151 -0
  30. quick_pp/api/services/reservoir_summary.py +78 -0
  31. quick_pp/api/services/saturation.py +359 -0
  32. quick_pp/api/static/favicon.ico +0 -0
  33. quick_pp/api/static/logo.png +0 -0
  34. quick_pp/cli.py +118 -0
  35. quick_pp/config.py +94 -0
  36. quick_pp/core_calibration.py +394 -0
  37. quick_pp/fluid_type.py +128 -0
  38. quick_pp/geomechanics.py +195 -0
  39. quick_pp/las_handler.py +327 -0
  40. quick_pp/lithology/__init__.py +80 -0
  41. quick_pp/lithology/carbonate.py +166 -0
  42. quick_pp/lithology/multi_mineral.py +151 -0
  43. quick_pp/lithology/sand_shale.py +79 -0
  44. quick_pp/lithology/sand_silt_clay.py +131 -0
  45. quick_pp/logger.py +19 -0
  46. quick_pp/modelling/__init__.py +0 -0
  47. quick_pp/modelling/config.py +72 -0
  48. quick_pp/modelling/mock_data/mock_data.parquet +0 -0
  49. quick_pp/modelling/predict_pipeline.py +126 -0
  50. quick_pp/modelling/train_pipeline.py +220 -0
  51. quick_pp/modelling/utils.py +111 -0
  52. quick_pp/objects.py +177 -0
  53. quick_pp/permeability.py +151 -0
  54. quick_pp/plotter/__init__.py +0 -0
  55. quick_pp/plotter/plotter.py +315 -0
  56. quick_pp/plotter/well_log.py +187 -0
  57. quick_pp/plotter/well_log_config.py +409 -0
  58. quick_pp/porosity.py +341 -0
  59. quick_pp/qaqc.py +436 -0
  60. quick_pp/ressum.py +326 -0
  61. quick_pp/rock_type.py +499 -0
  62. quick_pp/saturation.py +455 -0
  63. quick_pp/utils.py +328 -0
  64. quick_pp-0.2.3.dist-info/METADATA +103 -0
  65. quick_pp-0.2.3.dist-info/RECORD +69 -0
  66. quick_pp-0.2.3.dist-info/WHEEL +4 -0
  67. quick_pp-0.2.3.dist-info/entry_points.txt +2 -0
  68. quick_pp-0.2.3.dist-info/licenses/AUTHORS.rst +13 -0
  69. quick_pp-0.2.3.dist-info/licenses/LICENSE +22 -0
quick_pp/saturation.py ADDED
@@ -0,0 +1,455 @@
1
+ import numpy as np
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+ import matplotlib.ticker as ticker
5
+
6
+ from quick_pp.utils import min_max_line
7
+
8
+ plt.style.use('seaborn-v0_8-paper')
9
+ plt.rcParams.update(
10
+ {
11
+ 'axes.labelsize': 8,
12
+ 'xtick.labelsize': 10,
13
+ 'legend.fontsize': 'small'
14
+ }
15
+ )
16
+
17
+
18
+ def archie_saturation(rt, rw, phit, a=1, m=2, n=2):
19
+ """Estimate water saturation based on Archie's model for clean sand.
20
+
21
+ Args:
22
+ rt (float): True resistivity or deep resistivity log.
23
+ rw (float): Formation water resistivity.
24
+ phit (float): Total porosity.
25
+ a (float): Cementation exponent.
26
+ m (float): Saturation exponent.
27
+ n (float): Porosity exponent.
28
+
29
+ Returns:
30
+ float: Water saturation.
31
+
32
+ """
33
+ return ((a / (phit ** m)) * (rw / rt)) ** (1 / n)
34
+
35
+
36
+ def waxman_smits_saturation(rt, rw, phit, Qv=None, B=None, m=2, n=2):
37
+ """Estimate water saturation based on Waxman-Smits model for dispersed clay mineral.
38
+ Based on Ausburn, Brian E., and Robert Freedman. "The Waxman-smits Equation For Shaly Sands:
39
+ i. Simple Methods Of Solution
40
+ ii. Error Analysis." The Log Analyst 26 (1985)
41
+
42
+ Args:
43
+ rt (float): True resistivity or deep resistivity log.
44
+ rw (float): Formation water resistivity.
45
+ phit (float): Total porosity.
46
+ B (float): Conductance parameter.
47
+ Qv (float): Cation exchange capacity per unit total pore volume (meq/cm3).
48
+ m (float): Saturation factor.
49
+ n (float): Cementartion factor.
50
+
51
+ Returns:
52
+ float: Water saturation.
53
+ """
54
+ # Estimate B at 25 degC if not provided
55
+ if B is None:
56
+ B = (1 - 0.83 * np.exp(-0.5 / rw)) * 3.83
57
+
58
+ if Qv is None:
59
+ Qv = 0.3
60
+
61
+ # Initial guess
62
+ swt = 1
63
+ swt_i = 0
64
+ for i in range(50):
65
+ fx = swt**n + rw * B * Qv * swt**(n - 1) - (phit**-m * rw / rt) # Ausburn, 1985
66
+ delta_sat = abs(swt - swt_i) / 2
67
+ swt_i = swt
68
+ swt = np.where(fx < 0, swt + delta_sat, swt - delta_sat)
69
+
70
+ return swt
71
+
72
+
73
+ def dual_water_saturation(rt, rw, phit, a, m, n, swb, rwb):
74
+ """Estimate water saturation based on dual water model, an extension from Waxman-Smits.
75
+ TODO: Estimate swb and rwb if not provided
76
+
77
+ Args:
78
+ rt (float): True resistivity or deep resistivity log.
79
+ rw (float): Formation water resistivity.
80
+ phit (float): Total porosity
81
+ a (float): Cementation exponent.
82
+ m (float): Saturation exponent.
83
+ n (float): Porosity exponent.
84
+ swb (float): Bound water saturation.
85
+ rwb (float): Bound water resistivity.
86
+
87
+ Returns:
88
+ float: Water saturation.
89
+
90
+ """
91
+ # Initial guess
92
+ swt = 1
93
+ swt_i = 0
94
+ for i in range(50):
95
+ fx = phit**m * swt**n / a * (1 / rw * (swb / swt) * (1 / rwb - 1 / rw)) - 1 / rt
96
+ delta_sat = abs(swt - swt_i) / 2
97
+ swt_i = swt
98
+ swt = np.where(fx < 0, swt + delta_sat, swt - delta_sat)
99
+
100
+ return swt
101
+
102
+
103
+ def indonesian_saturation(rt, rw, phie, vsh, rsh, a, m, n):
104
+ """Estimate water saturation based on Indonesian model which may work well with fresh formation water.
105
+ Based on Poupon-Leveaux 1971.
106
+
107
+ Args:
108
+ rt (float): True resistivity or deep resistivity log.
109
+ rw (float): Formation water resistivity.
110
+ phie (float): Effective porosity.
111
+ vsh (float): Volume of shale.
112
+ rsh (float): Resistivity of shale.
113
+ a (float): Cementation exponent.
114
+ m (float): Saturation exponent.
115
+ n (float): Porosity exponent.
116
+
117
+ Returns:
118
+ float: Water saturation.
119
+
120
+ """
121
+ return ((1 / rt)**(1 / 2) / ((vsh**(1 - 0.5 * vsh) / rsh**(1 / 2)) + (phie**m / (a * rw))**(1 / 2)))**(2 / n)
122
+
123
+
124
+ def simandoux_saturation(rt, rw, phit, vsh, rsh, a, m):
125
+ """Estimate water saturation based on Simandoux's model.
126
+
127
+ Args:
128
+ rt (float): True resistivity or deep resistivity log.
129
+ rw (float): Formation water resistivity.
130
+ phit (float): Total porosity.
131
+ vsh (float): Volume of shale.
132
+ rsh (float): Resistivity of shale.
133
+ a (float): Cementation exponent.
134
+ m (float): Saturation exponent.
135
+
136
+ Returns:
137
+ float: Water saturation.
138
+
139
+ """
140
+ shale_factor = vsh / rsh
141
+ return (a * rw / (2 * phit**m)) * ((shale_factor**2 + (4 * phit**m / (a * rw * rt)))**(1 / 2) - shale_factor)
142
+
143
+
144
+ def modified_simandoux_saturation():
145
+ """ TODO: Estimate water saturation based on modified Simandoux's model.
146
+ """
147
+ pass
148
+
149
+
150
+ def estimate_temperature_gradient(tvd, unit='metric'):
151
+ """Estimate formation temperature based on gradient of 25 degC/km or 15 degF/1000ft.
152
+
153
+ Args:
154
+ tvd (float): True vertical depth in m.
155
+
156
+ Returns:
157
+ float: Formation temperature in degC.
158
+ """
159
+ assert unit in ['metric', 'imperial'], "Please choose from 'metric' or 'imperial' units."
160
+ return 32 + 25 * tvd / 1000 if unit == 'metric' else 90 + 15 * tvd / 1000
161
+
162
+
163
+ def estimate_b_waxman_smits(T, rw):
164
+ """Estimate B (conductance parameter) for Waxman-Smits model based on Juhasz 1981.
165
+
166
+ Args:
167
+ T (float): Temperature in degC.
168
+ rw (float): Water resistivity in ohm.m.
169
+
170
+ Returns:
171
+ float: B parameter.
172
+ """
173
+ return (-1.28 + 0.225 * T - 0.0004059 * T**2) / (1 + (0.045 * T - 0.27) * rw**1.23)
174
+
175
+
176
+ def estimate_rw_temperature_salinity(temperature_gradient, water_salinity):
177
+ """Estimate formation water resistivity based on temperature gradient and water salinity.
178
+
179
+ Args:
180
+ temperature_gradient (float): Temperature gradient in degC/meter
181
+ water_salinity (float): Water salinity in ppm
182
+
183
+ Returns:
184
+ float: Formation water resistivity.
185
+ """
186
+ return (400000 / temperature_gradient / water_salinity)**.88
187
+
188
+
189
+ def estimate_rw_archie(phit, rt, a=1, m=2):
190
+ """Estimate water saturation based on Archie's equation.
191
+
192
+ Args:
193
+ phit (float): Total porosity.
194
+ rt (float): True resistivity.
195
+
196
+ Returns:
197
+ float: Formation water resistivity.
198
+ """
199
+ rw = pd.Series(phit**m * rt / a)
200
+ _, rw = min_max_line(rw, alpha=0.2)
201
+ return rw
202
+
203
+
204
+ def estimate_rw_waxman_smits(phit, rt, a=1, m=2, B=None, Qv=None):
205
+ """Estimate water saturation based on Archie's equation.
206
+
207
+ Args:
208
+ phit (float): Total porosity.
209
+ rt (float): True resistivity.
210
+
211
+ Returns:
212
+ float: Formation water resistivity.
213
+ """
214
+ if B is None:
215
+ B = 2
216
+ if Qv is None:
217
+ Qv = 0.3
218
+
219
+ rw = pd.Series(1 / ((a / (phit**m * rt)) - (B * Qv)))
220
+ _, rw = min_max_line(rw, alpha=0.2)
221
+ return rw
222
+
223
+
224
+ def estimate_rt_water_trend(rt, alpha=0.3):
225
+ """Estimate trend RT of formation water (experiment).
226
+
227
+ Args:
228
+ rt (float): True resistivity.
229
+ RES_FLAG (int): Reservoir flag.
230
+
231
+ Returns:
232
+ float: Formation water resistivity.
233
+ """
234
+ rt = np.log(rt)
235
+ rt = np.where(rt <= 0, 1e-3, rt)
236
+ min_rt, _ = min_max_line(rt, alpha)
237
+ return np.exp(min_rt)
238
+
239
+
240
+ def estimate_rw_from_shale_trend(rt, phit, m=1.3, alpha=0.1):
241
+ """Estimate Rw from shale trend.
242
+
243
+ Args:
244
+ rt (float): True resistivity.
245
+ phit (float): Total porosity.
246
+ m (float): Shale cementation or shape factor. Defaults to 1.3.
247
+ alpha (float): Alpha value for percentile calculation. Defaults to 0.1.
248
+
249
+ Returns:
250
+ float: Formation water resistivity.
251
+ """
252
+ min_rt = estimate_rt_water_trend(rt, alpha=alpha)
253
+ min_phit, _ = min_max_line(phit, alpha=alpha)
254
+ return min_phit ** m * np.exp(min_rt)
255
+
256
+
257
+ def estimate_qv(vcld, phit, rho_clay=2.65, cec_clay=.062):
258
+ """Estimate Qv, cation exchange capacity per unit total pore volume (meq/cm3).
259
+
260
+ Args:
261
+ vcld (float): Volume of dry clay in fraction
262
+ phit (float): Total porosity in fraction
263
+ rho_clay (float): Bulk density of clay in g/cc
264
+ cec_clay (float): Cation exchange capacity of clay in meq/g
265
+
266
+ Returns:
267
+ float: Qv in meq/cm3.
268
+ """
269
+ return vcld * rho_clay * cec_clay / phit
270
+
271
+
272
+ def estimate_qv_hill(vclb, phit, water_salinity=10000):
273
+ """Estimating Qv based on Hill et. al, 1979.
274
+
275
+ Args:
276
+ vclb (float): Volume of clay bound water in fraction.
277
+ phit (float): Total porosity in fraction.
278
+ water_salinity (float): Water salinity in ppm or meq/cc.
279
+
280
+ Returns:
281
+ float: Qv in meq/cc
282
+ """
283
+ return (vclb / phit) / (0.084 * water_salinity**-0.5 + 0.22)
284
+
285
+
286
+ def estimate_qv_lavers(phit, a=3.05e-4, b=3.49):
287
+ """Based on Lavers, 1975.
288
+
289
+ Args:
290
+ phit (float): Total porosity in fraction.
291
+ a (float): Constant, defaults to 3.05e-4.
292
+ b (float): Constant, defaults to 3.49.
293
+
294
+ Returns:
295
+ float: Qv in meq/cc.
296
+ """
297
+ return a * phit**-b
298
+
299
+
300
+ def estimate_m_archie(rt, rw, phit):
301
+ """Estimate apparent m (saturation factor) based on Archie's equation in water bearing zone.
302
+
303
+ Args:
304
+ rt (float): True resistivity or deep resistivity log.
305
+ rw (float): Formation water resistivity.
306
+ phit (float): Total porosity.
307
+
308
+ Returns:
309
+ float: Apparent m parameter.
310
+ """
311
+ return np.log(rw / rt) / np.log(phit)
312
+
313
+
314
+ def estimate_m_indonesian(rt, rw, phie, vsh, rsh):
315
+ """Estimate apparent m based on Indonesian model in water bearing zone (shaly ~ vshale < 25%).
316
+
317
+ Args:
318
+ rt (float): True resistivity or deep resistivity log.
319
+ rw (float): Formation water resistivity.
320
+ phie (float): Effective porosity.
321
+ vsh (float): Volume of shale.
322
+ rsh (float): Resistivity of shale
323
+
324
+ Returns:
325
+ float: Apparent m parameter.
326
+ """
327
+ m = (2 / np.log(phie)) * np.log(rw**0.5 * ((1 / rt)**0.5 - (vsh**(1 - 0.5 * vsh) / rsh**0.5)))
328
+ return m
329
+
330
+
331
+ def swirr_xplot(swt, phit, c=.0125, label='', log_log=False, title=''):
332
+ """Plot SWT vs PHIT for sand intervales only and estimate Swirr from cross plot.
333
+ Based on Buckles, 1965.
334
+
335
+ Args:
336
+ swt (float): Water saturation.
337
+ phit (float): Total porosity.
338
+ c (float): Constant. Defaults to 0.125.
339
+ """
340
+ fig, ax = plt.subplots()
341
+ ax.set_title(title)
342
+ sc = ax.scatter(swt, phit, marker='.', label=label)
343
+ if c:
344
+ line_color = sc.get_facecolors()[0]
345
+ line_color[-1] = 0.75
346
+ cphit = np.geomspace(0.0001, 0.4, 30)
347
+ ax.plot(c / cphit, cphit, label=rf'$\phi$ S = {c}',
348
+ color=line_color, linestyle='dashed')
349
+ ax.set_ylabel('PHIT (frac)')
350
+ ax.set_xlabel('SWT (frac)')
351
+ ax.set_xlim(0, 1)
352
+ ax.legend()
353
+ if log_log:
354
+ ax.set_xscale('log')
355
+ ax.set_yscale('log')
356
+ fig.tight_layout()
357
+
358
+
359
+ def pickett_plot(rt, phit, m=-2, min_rw=0.1, shift=.2, title='Pickett Plot'):
360
+ """Generate Pickett plot which is used to plot phit and rt at water bearing interval to determine;
361
+ m = The slope of best-fit line crossing the cleanest sand.
362
+ rw = Formation water resistivity. The intercept of the best-fit line at rt when phit = 100%.
363
+
364
+ Args:
365
+ rt (float): True resistivity or deep resistivity log.
366
+ phit (float): Total porosity.
367
+
368
+ Returns:
369
+ matplotlib.pyplot.Figure: Picket plot.
370
+ """
371
+ m = m if m < 0 else -m
372
+ fig, ax = plt.subplots(figsize=(5, 5))
373
+ ax.set_title(title)
374
+ ax.scatter(rt, phit, marker='.', color='b')
375
+ # Add iso-lines
376
+ phit_i = np.arange(0, 1, 1 / len(phit))
377
+ for i in np.geomspace(1, 5, num=5):
378
+ c = min_rw + (i - 1) * shift
379
+ sw = round(min_rw / c * 100)
380
+ rt_i = (phit_i**m) * c
381
+ ax.plot(rt_i, phit_i, linestyle='dashed', alpha=0.5, label=f'SW={sw}%')
382
+ # Set up y axis
383
+ ax.set_yscale('log')
384
+ ax.set_ylim(0.01, 1)
385
+ ax.yaxis.set_major_formatter(ticker.FuncFormatter(
386
+ lambda x, pos: ('{{:.{:1d}f}}'.format(int(np.maximum(-np.log10(x), 0)))).format(x)))
387
+ ax.set_ylabel('PHIT (v/v)')
388
+ # Set up x axis
389
+ ax.set_xscale('log')
390
+ ax.set_xlim(0.01, 1000)
391
+ ax.tick_params(top=True, labeltop=True)
392
+ ax.xaxis.set_major_formatter(ticker.FuncFormatter(
393
+ lambda x, pos: ('{{:.{:1d}f}}'.format(int(np.maximum(-np.log10(x), 0)))).format(x)))
394
+ ax.set_xlabel('RT (ohm.m)')
395
+
396
+ ax.legend()
397
+ fig.tight_layout()
398
+
399
+
400
+ def RI_plot(sw, rt, ro):
401
+ """Generate resistivity index plot to estimate saturation exponent. The inputs are from lab measurements.
402
+ - Assumed a = 1.
403
+ - Trend line must cross (1, 1) point.
404
+ - The slope of the trend line is the saturation exponent.
405
+
406
+ Args:
407
+ sw (float): Water saturation.
408
+ rt (float): True resistivity or deep resistivity log.
409
+ ro (float): Resistivity of 100% water saturated rock.
410
+
411
+ Returns:
412
+ matplotlib.pyplot.Figure: RI plot.
413
+ """
414
+ fig, ax = plt.subplots(figsize=(5, 5))
415
+ ax.set_title('Resistivity Index Plot')
416
+ ax.scatter(sw, rt / ro)
417
+ ax.set_xlim(0.01, 1)
418
+ ax.set_ylim(1, 1000)
419
+ ax.set_xscale('log')
420
+ ax.set_yscale('log')
421
+ ax.set_xlabel('SW')
422
+ ax.set_ylabel('RT/Rw')
423
+ ax.grid(True)
424
+ fig.tight_layout()
425
+
426
+ return fig
427
+
428
+
429
+ def FF_plot(phit, ro, rw):
430
+ """Generate formation factor plot to estimate cementation exponent. The inputs are from lab measurements.
431
+ - Assumed a = 1.
432
+ - Trend line must cross (1, 1) point.
433
+ - The slope of the trend line is the cementation exponent.
434
+
435
+ Args:
436
+ phit (float): Total porosity.
437
+ ro (float): Resistivity of 100% water saturated rock.
438
+ rw (float): Formation water resistivity.
439
+
440
+ Returns:
441
+ matplotlib.pyplot.Figure: FF plot.
442
+ """
443
+ fig, ax = plt.subplots(figsize=(5, 5))
444
+ ax.set_title('Formation Factor Plot')
445
+ ax.scatter(phit, ro / rw)
446
+ ax.set_xlim(0.01, 1)
447
+ ax.set_ylim(1, 1000)
448
+ ax.set_xscale('log')
449
+ ax.set_yscale('log')
450
+ ax.set_xlabel('PHIT')
451
+ ax.set_ylabel('Ro/Rw')
452
+ ax.grid(True)
453
+ fig.tight_layout()
454
+
455
+ return fig