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/porosity.py ADDED
@@ -0,0 +1,341 @@
1
+ import numpy as np
2
+
3
+ from quick_pp.config import Config
4
+ from quick_pp.utils import length_a_b, line_intersection
5
+
6
+
7
+ def normalize_volumetric(phit, **volumetrics):
8
+ """Normalize lithology given total porosity.
9
+
10
+ Args:
11
+ phit (float): Total porosity in fraction (v/v).
12
+ **volumetrics: Keyword arguments representing volumetric fractions (v/v).
13
+
14
+ Returns:
15
+ dict: Normalized volumetric fractions.
16
+ """
17
+ # Normalize the volumetrics
18
+ vmatrix = 1 - phit
19
+ normalized_volumetrics = {key: value * vmatrix for key, value in volumetrics.items()}
20
+
21
+ return normalized_volumetrics
22
+
23
+
24
+ def effective_porosity(phit, phi_shale, vshale):
25
+ """
26
+ Computes effective porosity from total porosity, total porosity of shale and shale volume.
27
+
28
+ Parameters
29
+ ----------
30
+ phit : float
31
+ Total porosity [fraction].
32
+ phi_vsh : float
33
+ Total porosity of shale [fraction].
34
+ vshale : float
35
+ Shale volume [fraction].
36
+
37
+ Returns
38
+ -------
39
+ porosity : float
40
+ Effective porosity [fraction].
41
+
42
+ """
43
+ return phit - (vshale * phi_shale)
44
+
45
+
46
+ def clay_porosity(rho_clw: np.ndarray, rho_dry_clay: float = 2.72, rho_fluid: float = 1.0):
47
+ """Calculate clay porosity given bulk density of wet clay line.
48
+
49
+ Args:
50
+ rho_clw (float): Bulk density of wet clay line.
51
+ rho_dry_clay (float, optional): Bulk density of dry clay. Defaults to 2.72.
52
+ rho_fluid (float, optional): Bulk density of fluid. Defaults to 1.0.
53
+
54
+ Returns:
55
+ float: Clay porosity.
56
+ """
57
+ return (rho_dry_clay - rho_clw) / (rho_dry_clay - rho_fluid)
58
+
59
+
60
+ def shale_porosity(vshale, phi_shale):
61
+ """
62
+ Computes shale porosity from shale volume and total porosity of shale.
63
+
64
+ Parameters
65
+ ----------
66
+ vshale : float
67
+ Shale volume [fraction].
68
+ phi_vsh : float
69
+ Total porosity of shale [fraction].
70
+
71
+ Returns
72
+ -------
73
+ porosity : float
74
+ Shale porosity [fraction].
75
+
76
+ """
77
+ return vshale * phi_shale
78
+
79
+
80
+ def rho_matrix(vsand=0, vsilt=0, vclay=0, vcalc=0, vdolo=0, vheavy=0,
81
+ rho_sand: float = 0, rho_silt: float = 0, rho_clay: float = 0,
82
+ rho_calc: float = 0, rho_dolo: float = 0, rho_heavy: float = 0):
83
+ """Estimate average matrix density based on dry sand, dry silt, dry clay, dry calcite and
84
+ dry dolomite volume and density of each.
85
+
86
+ Args:
87
+ vsand (float): Volume of sand.
88
+ vsilt (float): Volume of silt.
89
+ vclay (float): Volume of clay.
90
+ vcalc (float): Volume of calcite.
91
+ vdolo (float): Volume of dolomite.
92
+ vheavy (float): Volume of heavy minerals.
93
+ rho_sand (float, optional): Density of sand in g/cc. Defaults to None.
94
+ rho_silt (float, optional): Density of silt in g/cc. Defaults to None.
95
+ rho_clay (float, optional): Density of clay in g/cc. Defaults to None.
96
+ rho_calc (float, optional): Density of calcite in g/cc. Defaults to None.
97
+ rho_dolo (float, optional): Density of dolomite in g/cc. Defaults to None.
98
+ rho_heavy (float, optional): Density of heavy minerals in g/cc. Defaults to 0.
99
+
100
+ Returns:
101
+ float: Matrix density in g/cc.
102
+ """
103
+ minerals_log_value = Config.MINERALS_LOG_VALUE
104
+ rho_sand = rho_sand or minerals_log_value['RHOB_QUARTZ']
105
+ rho_silt = rho_silt or minerals_log_value['RHOB_SILT']
106
+ rho_clay = rho_clay or minerals_log_value['RHOB_SH']
107
+ rho_calc = rho_calc or minerals_log_value['RHOB_CALCITE']
108
+ rho_dolo = rho_dolo or minerals_log_value['RHOB_DOLOMITE']
109
+ return vsand * rho_sand + vsilt * rho_silt + vclay * rho_clay + \
110
+ vcalc * rho_calc + vdolo * rho_dolo + vheavy * rho_heavy
111
+
112
+
113
+ def density_porosity(rhob, rho_matrix, rho_fluid: float = 1.0):
114
+ """Computes density porosity from bulk, matrix and fluid densities
115
+
116
+ Args:
117
+ rhob (float): Bulk density log in g/cc.
118
+ rho_matrix (float): Matrix density in g/cc.
119
+ rho_fluid (float, optional): Density of fluid in g/cc. Defaults to 1.0 g/cc.
120
+
121
+ Returns:
122
+ float: Density porosity [fraction]
123
+ """
124
+ return (rho_matrix - rhob) / (rho_matrix - rho_fluid)
125
+
126
+
127
+ def dt_matrix(vsand=0, vsilt=0, vclay=0, vcalc=0, vdolo=0, vheavy=0,
128
+ dt_sand: float = 0, dt_silt: float = 0, dt_clay: float = 0,
129
+ dt_calc: float = 0, dt_dolo: float = 0, dt_heavy: float = 0):
130
+ """Estimate average matrix sonic transit time based on dry sand, dry silt dry calcite and
131
+ dry dolomite volume and transit time of each.
132
+
133
+ Args:
134
+ vsand (float): Volume of sand.
135
+ vsilt (float): Volume of silt.
136
+ vclay (float): Volume of clay.
137
+ vcalc (float): Volume of calcite.
138
+ vdolo (float): Volume of dolomite.
139
+ vheavy (float): Volume of heavy minerals.
140
+ dt_sand (float, optional): Sonic transit time of sand in us/ft. Defaults to None.
141
+ dt_silt (float, optional): Sonic transit time of silt in us/ft. Defaults to None.
142
+ dt_clay (float, optional): Sonic transit time of clay in us/ft. Defaults to None.
143
+ dt_calc (float, optional): Sonic transit time of calcite in us/ft. Defaults to None.
144
+ dt_dolo (float, optional): Sonic transit time of dolomite in us/ft. Defaults to None.
145
+ dt_heavy (float, optional): Sonic transit time of heavy minerals in us/ft. Defaults to 0.
146
+
147
+ Returns:
148
+ float: Matrix sonic transit time in us/ft.
149
+ """
150
+ minerals_log_value = Config.MINERALS_LOG_VALUE
151
+ dt_sand = dt_sand or minerals_log_value['DTC_QUARTZ']
152
+ dt_silt = dt_silt or minerals_log_value['DTC_SILT']
153
+ dt_clay = dt_clay or minerals_log_value['DTC_SH']
154
+ dt_calc = dt_calc or minerals_log_value['DTC_CALCITE']
155
+ dt_dolo = dt_dolo or minerals_log_value['DTC_DOLOMITE']
156
+ return vsand * dt_sand + vsilt * dt_silt + vclay * dt_clay + vcalc * dt_calc + vdolo * dt_dolo + vheavy * dt_heavy
157
+
158
+
159
+ def sonic_porosity_wyllie(dt, dt_matrix, dt_fluid):
160
+ """
161
+ Computes sonic porosity based on Wyllie's equation from interval, matrix, and fluid transit time.
162
+
163
+ Parameters
164
+ ----------
165
+ dt : float
166
+ Interval transit time [us/ft].
167
+ dt_matrix : float
168
+ Matrix transit time [us/ft]. Sandstone: 51-55, Limestone: 43-48, Dolomite: 43-39, Shale: 60-170.
169
+ dt_fluid : float
170
+ Fluid transit time [us/ft]. Water: 190, Oil: 240, Gas: 630.
171
+
172
+ Returns
173
+ -------
174
+ porosity : float
175
+ Sonic porosity [fraction].
176
+
177
+ """
178
+ return (dt - dt_matrix) / (dt_fluid - dt_matrix)
179
+
180
+
181
+ def sonic_porosity_hunt_raymer(dt, dt_matrix, dt_fluid):
182
+ """
183
+ Computes sonic porosity based on Hunt-Raymer's equation from interval, matrix and transit time.
184
+
185
+ Parameters
186
+ ----------
187
+ dt : float
188
+ Interval transit time [us/ft].
189
+ dt_matrix : float
190
+ Matrix transit time [us/ft]. Sandstone: 51-55, Limestone: 43-48, Dolomite: 43-39, Shale: 60-170.
191
+ dt_fluid : float
192
+ Fluid transit time [us/ft]. Water: 190, Oil: 240, Gas: 630.
193
+
194
+ Returns
195
+ -------
196
+ porosity : float
197
+ Sonic porosity [fraction].
198
+
199
+ """
200
+ c = (dt_matrix / (2 * dt_fluid)) - 1
201
+ return - c - (c**2 + (dt_matrix / dt) - 1)**0.5
202
+
203
+
204
+ def neu_den_xplot_poro_pt(
205
+ nphi: float, rhob: float, model: str = 'ssc',
206
+ dry_min1_point: tuple = (),
207
+ dry_silt_point: tuple = (),
208
+ dry_clay_point: tuple = (),
209
+ fluid_point: tuple = (1.0, 1.0)):
210
+ """Calculate porosity given a pair of neutron porosity and bulk density data point.
211
+
212
+ Args:
213
+ nphi (float): Neutron porosity log.
214
+ rhob (float): Bulk density log.
215
+ model (str, optional): Lithology model, either 'ssc' (Sand Silt Clay) or 'ss' (Sand Shale). Defaults to 'ssc'.
216
+ reservoir (bool, optional): Either in reservoir or non-reservoir section. Defaults to False.
217
+ dry_min1_point (tuple): Neutron porosity and bulk density of mineral 1 point.
218
+ dry_silt_point (tuple): Neutron porosity and bulk density of dry silt point.
219
+ dry_clay_point (tuple): Neutron porosity and bulk density of dry clay point.
220
+ fluid_point (tuple): Neutron porosity and bulk density of fluid point. Defaults to (1.0, 1.0).
221
+
222
+ Returns:
223
+ float: Total porosity.
224
+ """
225
+ assert model in ['ssc', 'ss', 'carb'], "Please specify either 'ssc', 'ss' or 'carb' model."
226
+
227
+ A = dry_min1_point
228
+ B = dry_silt_point
229
+ C = dry_clay_point
230
+ D = fluid_point
231
+
232
+ phit = []
233
+ if model == 'ssc':
234
+ # Check if the point is in the reservoir or non-reservoir section
235
+ thold_pt = line_intersection((A, C), (D, B))
236
+ thold_line = length_a_b(thold_pt, A)
237
+ proj_pt = line_intersection((A, C), (D, (nphi, rhob)))
238
+ proj_line = length_a_b(proj_pt, A)
239
+ if proj_line < thold_line:
240
+ m = (A[1] - B[1]) / (A[0] - B[0])
241
+ else:
242
+ m = (C[1] - B[1]) / (C[0] - B[0])
243
+
244
+ c = rhob - m * nphi
245
+ iso_poro_pt = line_intersection(((0, c), (nphi, rhob)), (D, B))
246
+ iso_poro_line = length_a_b(iso_poro_pt, B)
247
+ poro_line = length_a_b(D, B)
248
+ phit = iso_poro_line / poro_line
249
+ else:
250
+ m = (A[1] - C[1]) / (A[0] - C[0])
251
+ c = rhob - m * nphi
252
+ iso_poro_pt = line_intersection(((0, c), (nphi, rhob)), (D, A))
253
+ iso_poro_line = length_a_b(iso_poro_pt, A)
254
+ poro_line = length_a_b(D, A)
255
+
256
+ phit = iso_poro_line / poro_line
257
+ return phit
258
+
259
+
260
+ def neu_den_xplot_poro(nphi, rhob, model: str = 'ssc',
261
+ dry_min1_point: tuple = (),
262
+ dry_silt_point: tuple = (),
263
+ dry_clay_point: tuple = (),
264
+ fluid_point: tuple = (1.0, 1.0)):
265
+ """Calculate porosity given neutron porosity and bulk density logs.
266
+
267
+ Args:
268
+ nphi (float): Neutron porosity log.
269
+ rhob (float): Bulk density log.
270
+ model (str, optional): Lithology model, either 'ssc' (Sand Silt Clay), 'ss' (Sand Shale) or 'carb' (Carbonate).
271
+ Defaults to 'ssc'.
272
+ reservoir (bool, optional): Either in reservoir or non-reservoir section. Defaults to False.
273
+ dry_min1_point (tuple): Neutron porosity and bulk density of dry min1 point. Defaults to None.
274
+ dry_silt_point (tuple): Neutron porosity and bulk density of dry silt point. Defaults to None.
275
+ dry_clay_point (tuple): Neutron porosity and bulk density of dry clay point. Defaults to None.
276
+ fluid_point (tuple): Neutron porosity and bulk density of fluid point. Defaults to (1.0, 1.0).
277
+
278
+ Returns:
279
+ float: Total porosity.
280
+ """
281
+ assert model in ['ssc', 'ss', 'carb'], "Please specify either 'ssc', 'ss' or 'carb' model."
282
+
283
+ A = dry_min1_point
284
+ B = dry_silt_point
285
+ C = dry_clay_point
286
+ D = fluid_point
287
+ E = list(zip(nphi, rhob))
288
+
289
+ phit = np.empty(0)
290
+ for i, point in enumerate(E):
291
+ if model == 'ssc':
292
+ phit = np.append(phit, neu_den_xplot_poro_pt(point[0], point[1], 'ssc', A, B, C, D))
293
+ else:
294
+ phit = np.append(phit, neu_den_xplot_poro_pt(point[0], point[1], 'ss', A, (0, 0), C, D))
295
+
296
+ return phit
297
+
298
+
299
+ def porosity_correction_averaging(nphi, rhob, rho_ma=2.65, method='weighted'):
300
+ """Correct porosity using averaging method.
301
+ Weighted average: (2 * dphi + nphi) / 3
302
+ Arithmetic average: (dphi + nphi) / 2
303
+ Gaymard average: sqrt((dphi**2 + nphi**2) / 2)
304
+ Gas average: sqrt((dphi**2 + nphi**2) / 2)
305
+
306
+ Args:
307
+ nphi (float): Neutron porosity.
308
+ dphi (float): Density porosity.
309
+ method (str, optional): Averaging method selection from 'weighted', 'arithmetic' or 'gaymard'.
310
+ Defaults to 'weighted'.
311
+
312
+ Returns:
313
+ float: Corrected porosity.
314
+ """
315
+ assert method in ['weighted', 'arithmetic', 'gaymard', 'gas'], "method must be either \
316
+ 'weighted', 'arithmetic', 'gaymard' or 'gas"
317
+ dphi = density_porosity(rhob, rho_ma, 1.0)
318
+ if method == 'weighted':
319
+ return (2 * dphi + nphi) / 3
320
+ elif method == 'arithmetic':
321
+ return (dphi + nphi) / 2
322
+ elif method == 'gaymard':
323
+ return np.sqrt((dphi**2 + nphi**2) / 2)
324
+ elif method == 'gas':
325
+ return ((nphi**2 + dphi**2) / 2)**0.5
326
+
327
+
328
+ def porosity_trend(tvdss, unit='ft'):
329
+ """Calculate porosity trend based on TVDSS (Schmoker, 1982)
330
+
331
+ Args:
332
+ tvdss (float): True Vertical Depth Subsea.
333
+
334
+ Returns:
335
+ float: Porosity trend.
336
+ """
337
+ assert unit in ['ft', 'm'], 'Please specify either ft or m as unit.'
338
+ if unit == 'ft':
339
+ return 41.73 * np.exp(-tvdss / 8197)
340
+ else:
341
+ return 41.73 * np.exp(-tvdss / 2498)