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
@@ -0,0 +1,166 @@
1
+ import numpy as np
2
+
3
+ from quick_pp.utils import length_a_b, line_intersection
4
+ from quick_pp.config import Config
5
+
6
+
7
+ class Carbonate:
8
+ """Carbonate model based on neutron density or density pef cross plots."""
9
+
10
+ def __init__(self, dry_calc_point: tuple = (float, float), dry_dolo_point: tuple = (float, float),
11
+ dry_clay_point: tuple = (float, float), fluid_point: tuple = (float, float), **kwargs):
12
+ # Initialize the endpoints
13
+ self.dry_calc_point = dry_calc_point or Config.CARB_NEU_DEN_ENDPOINTS["DRY_CALC_POINT"]
14
+ self.dry_dolo_point = dry_dolo_point or Config.CARB_NEU_DEN_ENDPOINTS["DRY_DOLO_POINT"]
15
+ self.dry_clay_point = dry_clay_point or Config.CARB_NEU_DEN_ENDPOINTS["DRY_CLAY_POINT"]
16
+ self.fluid_point = fluid_point or Config.CARB_NEU_DEN_ENDPOINTS["FLUID_POINT"]
17
+
18
+ def estimate_lithology(self, nphi, rhob, pef=None, vsh_gr=None, model: str = 'single',
19
+ method: str = 'neu_den', carbonate_type: str = 'limestone'):
20
+ """Estimate sand silt clay lithology volumetrics.
21
+
22
+ Args:
23
+ nphi (float): Neutron Porosity log in v/v
24
+ rhob (float): Bulk Density log in g/cc
25
+ pef (float, optional): Photoelectric Factor log in barns/electron. Defaults to [0].
26
+ vsh_gr (float, optional): Volume of shale from gamma ray log in v/v. Defaults to None.
27
+ model (str, optional): Model to choose from 'single' or 'double'. Defaults to 'single'.
28
+ method (str, optional): Method for 2 minerals model, to choose from 'neu_den' or 'den_pef'.
29
+ Defaults to 'neu_den'.
30
+ carbonate_type (str, optional): Carbonate type to choose from 'limestone' or 'dolostone'.
31
+ Defaults to 'limestone'.
32
+
33
+ Returns:
34
+ (float, float, float): vcld, vcalc, vdolo
35
+ """
36
+ assert model in ['single', 'double'], f"'{model}' model is not available."
37
+ assert method in ['neu_den', 'den_pef'], f"'{method}' method is not available."
38
+
39
+ vcld = vsh_gr if vsh_gr is not None else np.zeros(len(nphi))
40
+ if model == 'single':
41
+ # Estimate vshale
42
+ vcarb = 1 - vcld
43
+ vdolo = vcarb if carbonate_type == 'dolostone' else 0
44
+ vcalc = vcarb if carbonate_type == 'limestone' else 0
45
+ return vcld, vcalc, vdolo
46
+ elif model == 'double':
47
+ # Estimate vshale
48
+ if method == 'neu_den':
49
+ vcalc, vdolo = self.lithology_fraction_neu_den(nphi, rhob, model='double')
50
+ else:
51
+ assert pef is not None, "PEF log is required for 'den_pef' method."
52
+ vcalc, vdolo = self.lithology_fraction_pef(pef, rhob)
53
+ vcalc = vcalc * (1 - vcld)
54
+ vdolo = vdolo * (1 - vcld)
55
+ return vcld, vcalc, vdolo
56
+
57
+ def lithology_fraction_neu_den(self, nphi, rhob, model: str = 'single', carbonate_type: str = 'limestone'):
58
+ """Estimate clay and carbonate (either limestone or dolostone) based on neutron density cross plot.
59
+
60
+ Args:
61
+ nphi (float): Neutron Porosity log in v/v
62
+ rhob (float): Bulk Density log in g/cc
63
+ model (str, optional): Model to choose from 'single' or 'double'. Defaults to 'single'.
64
+ carbonate_type (str, optional): Carbonate type to choose from 'limestone' or 'dolostone'.
65
+
66
+ Returns:
67
+ (float, float): vlitho1, vlitho2
68
+ """
69
+ if model == 'single':
70
+ A = self.dry_clay_point
71
+ C = self.dry_calc_point if carbonate_type == 'limestone' else self.dry_dolo_point
72
+ else:
73
+ A = self.dry_dolo_point
74
+ C = self.dry_calc_point
75
+ D = self.fluid_point
76
+ E = zip(nphi, rhob)
77
+ rocklithofrac = length_a_b(A, C)
78
+
79
+ vlitho1 = np.empty(0)
80
+ vlitho2 = np.empty(0)
81
+ for i, point in enumerate(E):
82
+ var_pt = line_intersection((A, C), (D, point))
83
+ projlithofrac = length_a_b(var_pt, A)
84
+ vfrac = projlithofrac / rocklithofrac
85
+
86
+ vlitho1 = np.append(vlitho1, (1 - vfrac))
87
+ vlitho2 = np.append(vlitho2, vfrac)
88
+
89
+ return vlitho1, vlitho2
90
+
91
+ def lithology_fraction_pef(self, pef, rhob):
92
+ """Estimate limestone and dolostone based on pef density cross plot. Expecting the inputs are clay corrected.
93
+
94
+ Args:
95
+ pef (float): Photoelectric Factor in barns/electron
96
+ rhob (float): Bulk Density log in g/cc
97
+
98
+ Returns:
99
+ (float, float): vcalc, vdolo
100
+ """
101
+ A = (Config.MINERALS_LOG_VALUE['PEF_CALCITE'], self.dry_calc_point[1])
102
+ C = (Config.MINERALS_LOG_VALUE['PEF_DOLOMITE'], self.dry_dolo_point[1])
103
+ D = self.fluid_point
104
+ E = zip(pef, rhob)
105
+ rocklithofrac = length_a_b(A, C)
106
+
107
+ vcalc = np.empty(0)
108
+ vdolo = np.empty(0)
109
+ for i, point in enumerate(E):
110
+ var_pt = line_intersection((A, C), (D, point))
111
+ projlithofrac = length_a_b(var_pt, A)
112
+ dolo_frac = projlithofrac / rocklithofrac
113
+
114
+ vcalc = np.append(vcalc, (1 - dolo_frac))
115
+ vdolo = np.append(vdolo, dolo_frac)
116
+
117
+ return vcalc, vdolo
118
+
119
+ def clay_correction(self, vcld, nphi, rhob, pef):
120
+ """Apply clay correction to the input logs.
121
+
122
+ Args:
123
+ vcld (float): Volume of clay in v/v
124
+ nphi (float): Neutron Porosity log in v/v
125
+ rhob (float): Bulk Density log in g/cc
126
+ pef (float): Photoelectric Factor log in barns/electron
127
+
128
+ Returns:
129
+ float, float, float: nphicc, rhobcc, pefcc
130
+ """
131
+ # Convert to numpy array for vectorized operations
132
+ nphi = np.array(nphi)
133
+ rhob = np.array(rhob)
134
+ pef = np.array(pef)
135
+
136
+ nphicc = (nphi - vcld * self.dry_clay_point[0]) / (1 - vcld)
137
+ rhobcc = (rhob - vcld * self.dry_clay_point[1]) / (1 - vcld)
138
+ pefcc = (pef - vcld * Config.MINERALS_LOG_VALUE['PEF_SH']) / (1 - vcld)
139
+
140
+ return nphicc, rhobcc, pefcc
141
+
142
+
143
+ def sep_vug_poro(phit, phis, dtc=None, model='base', alpha=2.0, p=0.1):
144
+ """Separate vug porosity from total porosity and sonic porosity.
145
+ Base model (Lucia-Conti, 1987)
146
+ Power model (Wang-Lucia, 1993)
147
+ Quadratic model (Wang-Lucia, 1993)
148
+
149
+ Args:
150
+ phit (float): Total porosity in v/v
151
+ phis (float): Sonic porosity in v/v
152
+ dtc (float, optional): Compressional slowness log in us/ft. Defaults to None.
153
+ model (str, optional): Model to choose from 'base', 'power', or 'quadratic'. Defaults to 'base'.
154
+ alpha (float, optional): Scaling factor for power model. Defaults to 2.0.
155
+ p (float, optional): Emperical coefficient for quadratic model. Defaults to 0.1.
156
+
157
+ Returns:
158
+ float: Separate vug porosity in v/v
159
+ """
160
+ assert model in ['base', 'power', 'quadratic'], 'Please choose from "base", "power", or "quadratic" model.'
161
+ if model == 'base' and dtc is not None:
162
+ return 10 ** (4.09 - 0.145 * (dtc - 141.5 * phit))
163
+ elif model == 'power':
164
+ return (phit / phis) ** alpha * (phit - phis)
165
+ elif model == 'quadratic':
166
+ return (phit - phis) + p * (phit - phis) ** 2
@@ -0,0 +1,151 @@
1
+ from scipy.optimize import minimize
2
+ import numpy as np
3
+
4
+ from quick_pp.config import Config
5
+
6
+
7
+ def constraint_(x):
8
+ return x[0] + x[1] + x[2] + x[3] + x[4] - 1
9
+
10
+
11
+ constrains = [{"type": "eq", "fun": constraint_}]
12
+ # Mineral volume bounds (quartz, calcite, dolomite, shale, mud)
13
+ bounds = ((0, 1), (0, 1), (0, 0.1), (0, 1), (0, 0.45))
14
+ # Getting default values from Config which may need to be changed based on the dataset
15
+ responses = Config.MINERALS_LOG_VALUE
16
+
17
+
18
+ class MultiMineral():
19
+ """This multi-mineral model utilizes optimization method to determine each mineral components."""
20
+
21
+ def estimate_lithology(self, gr, nphi, rhob, pef, dtc):
22
+ """Modified from https://github.com/ruben-charles/petrophysical_evaluation_optimization_methods.git
23
+ This module takes in gr, nphi, rhob, pef and dtc to estimate the volumetric of
24
+ quartz, calcite, dolomite and shale.
25
+
26
+ Args:
27
+ gr (float): Gamma Ray log in GAPI.
28
+ nphi (float): Neutron Porosity log in v/v.
29
+ rhob (float): Bulk Density log in g/cc.
30
+ dtc (float): Compressional slowness log in us/ft.
31
+ pef (float): Photoelectric Factor log in barns/electron.
32
+
33
+ Returns:
34
+ (float, float, float, float, float): vol_quartz, vol_calcite, vol_dolomite, vol_shale, vol_mud
35
+ """
36
+ vol_quartz = np.empty(0)
37
+ vol_calcite = np.empty(0)
38
+ vol_dolomite = np.empty(0)
39
+ vol_shale = np.empty(0)
40
+ vol_mud = np.empty(0)
41
+ for i, input in enumerate(zip(gr, nphi, rhob, pef, dtc)):
42
+ if all([not np.isnan(c) for c in input]):
43
+ print(f'\r Using all inputs {input}', end='')
44
+ res = minimizer_4(input[0], input[1], input[2], input[3], input[4])
45
+ elif not np.isnan(input[3]):
46
+ print(f'\r Using PEF {input}', end='')
47
+ res = minimizer_2(input[0], input[1], input[2], input[3])
48
+ elif not np.isnan(input[4]):
49
+ print(f'\r Using DTC {input}', end='')
50
+ res = minimizer_3(input[0], input[1], input[2], input[4])
51
+ else:
52
+ print(f'\r Using GR, RHOB and NPHI {input}', end='')
53
+ res = minimizer_1(input[0], input[1], input[2])
54
+ vol_quartz = np.append(vol_quartz, res.x[0])
55
+ vol_calcite = np.append(vol_calcite, res.x[1])
56
+ vol_dolomite = np.append(vol_dolomite, res.x[2])
57
+ vol_shale = np.append(vol_shale, res.x[3])
58
+ vol_mud = np.append(vol_mud, res.x[4])
59
+
60
+ return vol_quartz, vol_calcite, vol_dolomite, vol_shale, vol_mud
61
+
62
+
63
+ def minimizer_1(gr, nphi, rhob):
64
+ def error_recon(volumes, *args):
65
+ vol_quartz, vol_calcite, vol_dolomite, vol_shale, vol_mud = volumes
66
+ GR, NPHI, RHOB = args
67
+ GR_RECON = vol_quartz * responses["GR_QUARTZ"] + vol_calcite * responses["GR_CALCITE"] + \
68
+ vol_dolomite * responses["GR_DOLOMITE"] + vol_shale * responses["GR_SH"] + vol_mud * responses["GR_MUD"]
69
+ NPHI_RECON = vol_quartz * responses["NPHI_QUARTZ"] + vol_calcite * responses["NPHI_CALCITE"] + \
70
+ vol_dolomite * responses["NPHI_DOLOMITE"] + vol_shale * responses["NPHI_SH"] + \
71
+ vol_mud * responses["NPHI_MUD"]
72
+ RHOB_RECON = vol_quartz * responses["RHOB_QUARTZ"] + vol_calcite * responses["RHOB_CALCITE"] + \
73
+ vol_dolomite * responses["RHOB_DOLOMITE"] + vol_shale * responses["RHOB_SH"] + \
74
+ vol_mud * responses["RHOB_MUD"]
75
+
76
+ # Some magic numbers to adjust the precision of differents magnitude orders (needs improvement)
77
+ return (GR - GR_RECON)**2 + (NPHI * 300 - NPHI_RECON * 300)**2 + (RHOB * 100 - RHOB_RECON * 100)**2
78
+
79
+ return minimize(error_recon, ((0, 0, 0, 0, 0)),
80
+ args=(gr, nphi, rhob), bounds=bounds, constraints=constrains)
81
+
82
+
83
+ def minimizer_2(gr, nphi, rhob, pef):
84
+ def error_recon(volumes, *args):
85
+ vol_quartz, vol_calcite, vol_dolomite, vol_shale, vol_mud = volumes
86
+ GR, NPHI, RHOB, PEF = args
87
+ GR_RECON = vol_quartz * responses["GR_QUARTZ"] + vol_calcite * responses["GR_CALCITE"] + \
88
+ vol_dolomite * responses["GR_DOLOMITE"] + vol_shale * responses["GR_SH"] + vol_mud * responses["GR_MUD"]
89
+ NPHI_RECON = vol_quartz * responses["NPHI_QUARTZ"] + vol_calcite * responses["NPHI_CALCITE"] + \
90
+ vol_dolomite * responses["NPHI_DOLOMITE"] + vol_shale * responses["NPHI_SH"] + \
91
+ vol_mud * responses["NPHI_MUD"]
92
+ RHOB_RECON = vol_quartz * responses["RHOB_QUARTZ"] + vol_calcite * responses["RHOB_CALCITE"] + \
93
+ vol_dolomite * responses["RHOB_DOLOMITE"] + vol_shale * responses["RHOB_SH"] + \
94
+ vol_mud * responses["RHOB_MUD"]
95
+ PEF_RECON = vol_quartz * responses["PEF_QUARTZ"] + vol_calcite * responses["PEF_CALCITE"] + \
96
+ vol_dolomite * responses["PEF_DOLOMITE"] + vol_shale * responses["PEF_SH"] + vol_mud * responses["PEF_MUD"]
97
+
98
+ # Some magic numbers to adjust the precision of differents magnitude orders (needs improvement)
99
+ return (GR - GR_RECON)**2 + (NPHI * 300 - NPHI_RECON * 300)**2 + (RHOB * 100 - RHOB_RECON * 100)**2 + \
100
+ (PEF - PEF_RECON)**2
101
+
102
+ return minimize(error_recon, ((0, 0, 0, 0, 0)),
103
+ args=(gr, nphi, rhob, pef), bounds=bounds, constraints=constrains)
104
+
105
+
106
+ def minimizer_3(gr, nphi, rhob, dtc):
107
+ def error_recon(volumes, *args):
108
+ vol_quartz, vol_calcite, vol_dolomite, vol_shale, vol_mud = volumes
109
+ GR, NPHI, RHOB, DTC = args
110
+ GR_RECON = vol_quartz * responses["GR_QUARTZ"] + vol_calcite * responses["GR_CALCITE"] + \
111
+ vol_dolomite * responses["GR_DOLOMITE"] + vol_shale * responses["GR_SH"] + vol_mud * responses["GR_MUD"]
112
+ NPHI_RECON = vol_quartz * responses["NPHI_QUARTZ"] + vol_calcite * responses["NPHI_CALCITE"] + \
113
+ vol_dolomite * responses["NPHI_DOLOMITE"] + vol_shale * responses["NPHI_SH"] + \
114
+ vol_mud * responses["NPHI_MUD"]
115
+ RHOB_RECON = vol_quartz * responses["RHOB_QUARTZ"] + vol_calcite * responses["RHOB_CALCITE"] + \
116
+ vol_dolomite * responses["RHOB_DOLOMITE"] + vol_shale * responses["RHOB_SH"] + \
117
+ vol_mud * responses["RHOB_MUD"]
118
+ DTC_RECON = vol_quartz * responses["DTC_QUARTZ"] + vol_calcite * responses["DTC_CALCITE"] + \
119
+ vol_dolomite * responses["DTC_DOLOMITE"] + vol_shale * responses["DTC_SH"] + vol_mud * responses["DTC_MUD"]
120
+
121
+ # Some magic numbers to adjust the precision of differents magnitude orders (needs improvement)
122
+ return (GR - GR_RECON)**2 + (NPHI * 300 - NPHI_RECON * 300)**2 + (RHOB * 100 - RHOB_RECON * 100)**2 + \
123
+ (DTC - DTC_RECON)**2
124
+
125
+ return minimize(error_recon, ((0, 0, 0, 0, 0)),
126
+ args=(gr, nphi, rhob, dtc), bounds=bounds, constraints=constrains)
127
+
128
+
129
+ def minimizer_4(gr, nphi, rhob, pef, dtc):
130
+ def error_recon(volumes, *args):
131
+ vol_quartz, vol_calcite, vol_dolomite, vol_shale, vol_mud = volumes
132
+ GR, NPHI, RHOB, PEF, DTC = args
133
+ GR_RECON = vol_quartz * responses["GR_QUARTZ"] + vol_calcite * responses["GR_CALCITE"] + \
134
+ vol_dolomite * responses["GR_DOLOMITE"] + vol_shale * responses["GR_SH"] + vol_mud * responses["GR_MUD"]
135
+ NPHI_RECON = vol_quartz * responses["NPHI_QUARTZ"] + vol_calcite * responses["NPHI_CALCITE"] + \
136
+ vol_dolomite * responses["NPHI_DOLOMITE"] + vol_shale * responses["NPHI_SH"] + \
137
+ vol_mud * responses["NPHI_MUD"]
138
+ RHOB_RECON = vol_quartz * responses["RHOB_QUARTZ"] + vol_calcite * responses["RHOB_CALCITE"] + \
139
+ vol_dolomite * responses["RHOB_DOLOMITE"] + vol_shale * responses["RHOB_SH"] + \
140
+ vol_mud * responses["RHOB_MUD"]
141
+ PEF_RECON = vol_quartz * responses["PEF_QUARTZ"] + vol_calcite * responses["PEF_CALCITE"] + \
142
+ vol_dolomite * responses["PEF_DOLOMITE"] + vol_shale * responses["PEF_SH"] + vol_mud * responses["PEF_MUD"]
143
+ DTC_RECON = vol_quartz * responses["DTC_QUARTZ"] + vol_calcite * responses["DTC_CALCITE"] + \
144
+ vol_dolomite * responses["DTC_DOLOMITE"] + vol_shale * responses["DTC_SH"] + vol_mud * responses["DTC_MUD"]
145
+
146
+ # Some magic numbers to adjust the precision of differents magnitude orders (needs improvement)
147
+ return (GR - GR_RECON)**2 + (NPHI * 300 - NPHI_RECON * 300)**2 + (RHOB * 100 - RHOB_RECON * 100)**2 + \
148
+ (PEF - PEF_RECON)**2 + (DTC - DTC_RECON)**2
149
+
150
+ return minimize(error_recon, ((0, 0, 0, 0, 0)),
151
+ args=(gr, nphi, rhob, pef, dtc), bounds=bounds, constraints=constrains)
@@ -0,0 +1,79 @@
1
+ import numpy as np
2
+
3
+ from quick_pp.utils import min_max_line, length_a_b, line_intersection
4
+ from quick_pp.config import Config
5
+
6
+
7
+ class SandShale:
8
+ """This binary model only consider a combination of sand-shale components. """
9
+
10
+ def __init__(self, dry_sand_point: tuple = (float, float), dry_clay_point: tuple = (float, float),
11
+ fluid_point: tuple = (float, float), wet_clay_point: tuple = (float, float), silt_line_angle: float = 0, **kwargs):
12
+ # Initialize the endpoints
13
+ self.dry_sand_point = dry_sand_point or Config.SSC_ENDPOINTS["DRY_SAND_POINT"]
14
+ self.dry_clay_point = dry_clay_point or Config.SSC_ENDPOINTS["DRY_CLAY_POINT"]
15
+ self.fluid_point = fluid_point or Config.SSC_ENDPOINTS["FLUID_POINT"]
16
+ self.wet_clay_point = wet_clay_point or Config.SSC_ENDPOINTS["WET_CLAY_POINT"]
17
+ self.silt_line_angle = silt_line_angle or Config.SSC_ENDPOINTS["SILT_LINE_ANGLE"]
18
+
19
+ def estimate_lithology(self, nphi, rhob):
20
+ """Estimate lithology volumetrics based on neutron density cross plot.
21
+
22
+ Args:
23
+ nphi (float): Neutron Porosity log in v/v
24
+ rhob (float): Bulk Density log in g/cc
25
+ xplot (bool, optional): To plot Neutron Density cross plot. Defaults to False.
26
+
27
+ Returns:
28
+ (float, float): vsand, vcld, cross-plot if xplot True else None
29
+ """
30
+ # Initialize the endpoints
31
+ C = self.dry_clay_point
32
+ D = self.fluid_point
33
+
34
+ # Redefine wetclay point
35
+ _, rhob_max_line = min_max_line(rhob, 0.05)
36
+ _, nphi_max_line = min_max_line(nphi, 0.05)
37
+ wetclay_RHOB = np.min(rhob_max_line)
38
+ wetclay_NPHI = np.max(nphi_max_line)
39
+ if not all(self.wet_clay_point):
40
+ self.wet_clay_point = (wetclay_NPHI, wetclay_RHOB)
41
+ # print(f'#### wet_clay_point: {wet_clay_point}')
42
+
43
+ # Define dryclay point
44
+ if not all(C):
45
+ m = (D[1] - self.wet_clay_point[1]) / (D[0] - self.wet_clay_point[0])
46
+ dryclay_NPHI = ((C[1] - D[1]) / m) + D[0]
47
+ C = self.dry_clay_point = (dryclay_NPHI, C[1])
48
+ # print(f'#### dryclay_pt: {C}, {m}')
49
+
50
+ vsand, vcld = self.lithology_fraction(nphi, rhob)
51
+
52
+ return vsand, vcld
53
+
54
+ def lithology_fraction(self, nphi, rhob):
55
+ """Estimate sand and shale based on neutron density cross plot.
56
+
57
+ Args:
58
+ nphi (float): Neutron Porosity log in v/v
59
+ rhob (float): Bulk Density log in g/cc
60
+
61
+ Returns:
62
+ (float, float): vsand, vcld
63
+ """
64
+ A = self.dry_sand_point
65
+ C = self.dry_clay_point
66
+ D = self.fluid_point
67
+ E = list(zip(nphi, rhob))
68
+ rocklithofrac = length_a_b(A, C)
69
+
70
+ vsand = np.empty(0)
71
+ vcld = np.empty(0)
72
+ for i, point in enumerate(E):
73
+ var_pt = line_intersection((A, C), (D, point))
74
+ projlithofrac = length_a_b(var_pt, A)
75
+ vshale = projlithofrac / rocklithofrac
76
+ vsand = np.append(vsand, (1 - vshale))
77
+ vcld = np.append(vcld, vshale)
78
+
79
+ return vsand, vcld
@@ -0,0 +1,131 @@
1
+ import numpy as np
2
+ import math
3
+
4
+ from quick_pp.utils import min_max_line, length_a_b, line_intersection
5
+ from quick_pp.config import Config
6
+
7
+
8
+ class SandSiltClay:
9
+ """Sand-silt-clay model based on Kuttan's litho-porosity model.
10
+
11
+ The original is a binary model where reservoir sections (left to the silt line) consist of combination of
12
+ sand-silt while non-reservoir sections (right to the silt line) consist of silt-clay combination.
13
+
14
+ This module is modified based on Kuttan, where the reservoir sections consist of combination of sand-silt-clay
15
+ while non-reservoir sections remain a combination of silt-clay only."""
16
+
17
+ def __init__(self, dry_sand_point: tuple = (float, float), dry_silt_point: tuple = (float, float),
18
+ dry_clay_point: tuple = (float, float), fluid_point: tuple = (float, float),
19
+ wet_clay_point: tuple = (float, float), silt_line_angle: float = 0, **kwargs):
20
+ # Initialize the endpoints
21
+ self.dry_sand_point = dry_sand_point or Config.SSC_ENDPOINTS["DRY_SAND_POINT"]
22
+ self.dry_silt_point = dry_silt_point or Config.SSC_ENDPOINTS["DRY_SILT_POINT"]
23
+ self.dry_clay_point = dry_clay_point or Config.SSC_ENDPOINTS["DRY_CLAY_POINT"]
24
+ self.fluid_point = fluid_point or Config.SSC_ENDPOINTS["FLUID_POINT"]
25
+ self.wet_clay_point = wet_clay_point or Config.SSC_ENDPOINTS["WET_CLAY_POINT"]
26
+ self.silt_line_angle = silt_line_angle or Config.SSC_ENDPOINTS["SILT_LINE_ANGLE"]
27
+
28
+ def estimate_lithology(self, nphi, rhob):
29
+ """Estimate sand silt clay lithology volumetrics.
30
+
31
+ Args:
32
+ nphi (float): Neutron Porosity log in v/v
33
+ rhob (float): Bulk Density log in g/cc
34
+
35
+ Returns:
36
+ (float, float, float, boolean): vsand, vsilt, vcld, vclb, cross-plot if xplot True else None
37
+ """
38
+ # Initialize the endpoints
39
+ B = self.dry_silt_point
40
+ C = self.dry_clay_point
41
+ D = self.fluid_point
42
+
43
+ # Redefine wetclay point
44
+ _, rhob_max_line = min_max_line(rhob, 0.1)
45
+ _, nphi_max_line = min_max_line(nphi, 0.1)
46
+ wetclay_RHOB = np.nanmin(rhob_max_line)
47
+ wetclay_NPHI = np.nanmax(nphi_max_line)
48
+ if not all(self.wet_clay_point):
49
+ self.wet_clay_point = (wetclay_NPHI, wetclay_RHOB)
50
+
51
+ # Redefine drysilt point
52
+ drysilt_NPHI = 1 - 1.68 * (math.tan(float(self.silt_line_angle - 90) * math.pi / 180))
53
+ if not all(B):
54
+ B = self.dry_silt_point = (drysilt_NPHI, B[1])
55
+
56
+ # Define dryclay point
57
+ if not all(C):
58
+ # Calculate dryclay_NPHI given dryclay_RHOB
59
+ m = (D[1] - self.wet_clay_point[1]) / (D[0] - self.wet_clay_point[0])
60
+ dryclay_NPHI = ((C[1] - D[1]) / m) + D[0]
61
+ C = self.dry_clay_point = (dryclay_NPHI, C[1])
62
+
63
+ # # Calculate dryclay point, the intersection between rock line and clay line
64
+ # drysilt_RHOB = B[1] # if B[1] > np.nanmax(rhob) else np.nanmax(rhob)
65
+ # updated_drysilt_pt = (B[0], drysilt_RHOB)
66
+ # A = self.dry_sand_point
67
+ # C = self.dry_clay_point = line_intersection((A, updated_drysilt_pt), (D, self.wet_clay_point))
68
+
69
+ # Calculate lithology fraction
70
+ vsand, vsilt, vcld = self.lithology_fraction_kuttan_modified(nphi, rhob)
71
+
72
+ return vsand, vsilt, vcld, (nphi_max_line, rhob_max_line)
73
+
74
+ def lithology_fraction_kuttan_modified(self, nphi, rhob):
75
+ """Estimate lithology volumetrics based on modified Kuttan's litho-porosity model.
76
+
77
+ Args:
78
+ nphi (float): Neutron Porosity log in v/v.
79
+ rhob (float): Bulk Density log in g/cc.
80
+
81
+ Returns:
82
+ (float, float, float): vsand, vsilt, vcld
83
+ """
84
+ A = self.dry_sand_point
85
+ B = self.dry_silt_point
86
+ C = self.dry_clay_point
87
+ D = self.fluid_point
88
+ E = list(zip(nphi, rhob))
89
+
90
+ rock_len = length_a_b(A, C)
91
+ res_len = length_a_b(A, B)
92
+ res_ratio = res_len / rock_len
93
+
94
+ vsand = np.empty(0)
95
+ vsilt = np.empty(0)
96
+ vcld = np.empty(0)
97
+ for i, point in enumerate(E):
98
+ var_pt = line_intersection((A, C), (D, point))
99
+ proj_len = length_a_b(var_pt, A)
100
+ vsand_pt, vsilt_pt, vcld_pt = self.lithology_chart(proj_len, rock_len, res_ratio)
101
+ vsand = np.append(vsand, vsand_pt)
102
+ vsilt = np.append(vsilt, vsilt_pt)
103
+ vcld = np.append(vcld, vcld_pt)
104
+
105
+ return vsand, vsilt, vcld
106
+
107
+ def lithology_chart(self, proj_len, rock_len, res_ratio):
108
+ """Estimate lithology fraction based on Kuttan's modified chart.
109
+
110
+ Args:
111
+ proj_len (float): Length of projected point from dry sand point.
112
+ rock_len (float): Length of rock line.
113
+ res_ratio (float): Ratio of reservoir length to rock length.
114
+
115
+ Returns:
116
+ (float, float, float): vsand, vsilt, vcld
117
+ """
118
+ siltclayratio = 0.25 # empirical value
119
+ res_len = rock_len * res_ratio
120
+ non_res_len = rock_len * (1 - res_ratio)
121
+ pt_ratio = proj_len / rock_len
122
+ if pt_ratio <= res_ratio:
123
+ vsand = (-proj_len / res_len) + 1
124
+ vsilt = siltclayratio / res_len * proj_len
125
+ vcld = (1 - siltclayratio) / res_len * proj_len
126
+ else:
127
+ vsand = 0
128
+ vsilt = -siltclayratio / non_res_len * proj_len + (rock_len * siltclayratio / non_res_len)
129
+ vcld = siltclayratio / non_res_len * proj_len + (1 - (siltclayratio * rock_len / non_res_len))
130
+
131
+ return vsand, vsilt, vcld
quick_pp/logger.py ADDED
@@ -0,0 +1,19 @@
1
+ from loguru import logger
2
+ import logging
3
+ import sys
4
+
5
+ # Remove default loguru handler
6
+ logger.remove()
7
+
8
+ # Add a new handler with custom formatting and color
9
+ logger.add(
10
+ sys.stdout,
11
+ colorize=True,
12
+ format="<green>[{time:YYYY-MM-DD HH:mm:ss}]</green> <level>{level: <8}</level> | <cyan>{name}</cyan> | "
13
+ "<level>{message}</level>",
14
+ level="INFO"
15
+ )
16
+
17
+ # Silence overly verbose loggers from dependencies (if needed, using stdlib logging)
18
+ logging.getLogger("matplotlib").setLevel(logging.WARNING)
19
+ logging.getLogger("mlflow").setLevel(logging.WARNING)
File without changes
@@ -0,0 +1,72 @@
1
+ from collections import OrderedDict
2
+ from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
3
+
4
+ MLFLOW_CONFIG = dict(
5
+ local=dict(
6
+ tracking_host='localhost',
7
+ tracking_port=5015,
8
+ backend_store_uri='sqlite:///./mlruns/mlflow.db',
9
+ artifact_location='./mlruns/',
10
+ ),
11
+ remote=dict(
12
+ tracking_host='<your-mlflow-server>',
13
+ tracking_port=5000,
14
+ backend_store_uri='postgresql://<username>:<password>@<hostname>:<port>/<database>?sslmode=require',
15
+ artifact_location='wasbs://<your-blob-storage-account-name>.blob.core.windows.net/<your-container-name>/',
16
+ # artifact_location='s3://<your-s3-bucket-name>/<your-folder-name>/',
17
+ ),
18
+ )
19
+
20
+ RAW_FEATURES = ['GR', 'RT', 'NPHI', 'RHOB']
21
+ MODELLING_CONFIG = dict(
22
+ mock=OrderedDict(
23
+ POROSAT=dict(
24
+ alg=RandomForestRegressor,
25
+ targets=['PHIE', 'SW'],
26
+ features=RAW_FEATURES,
27
+ description=('Mock clastic properties prediction consisting of total porosity and total water saturation.'),
28
+ ),
29
+ ),
30
+ clastic=OrderedDict(
31
+ OIL=dict(
32
+ alg=RandomForestClassifier,
33
+ targets=['OIL_FLAG'],
34
+ features=RAW_FEATURES,
35
+ description='Oil flag classification',
36
+ ),
37
+ GAS=dict(
38
+ alg=RandomForestClassifier,
39
+ targets=['GAS_FLAG'],
40
+ features=RAW_FEATURES + ['OIL_FLAG'],
41
+ description='Gas flag classification',
42
+ ),
43
+ CLASTIC=dict(
44
+ alg=RandomForestRegressor,
45
+ targets=['PHIT', 'SWT', 'LOG_PERM', 'VSAND', 'VSILT', 'VCLW'],
46
+ features=RAW_FEATURES,
47
+ description=('Clastic properties prediction consisting of total porosity, total water saturation, '
48
+ 'log permeability, sand volume, silt volume, and clay volume'),
49
+ ),
50
+ ),
51
+ carbonate=OrderedDict(
52
+ OIL=dict(
53
+ alg=RandomForestClassifier,
54
+ targets=['OIL_FLAG'],
55
+ features=RAW_FEATURES,
56
+ description='Oil flag classification',
57
+ ),
58
+ GAS=dict(
59
+ alg=RandomForestClassifier,
60
+ targets=['GAS_FLAG'],
61
+ features=RAW_FEATURES + ['OIL_FLAG'],
62
+ description='Gas flag classification',
63
+ ),
64
+ CARBONATE=dict(
65
+ alg=RandomForestRegressor,
66
+ targets=['PHIT', 'SWT', 'LOG_PERM', 'VCALC', 'VCLW', 'VDOLO'],
67
+ features=RAW_FEATURES,
68
+ description=('Carbonate properties prediction consisting of total porosity, total water saturation, '
69
+ 'log permeability, calcite volume, clay volume, and dolomite volume'),
70
+ ),
71
+ )
72
+ )