quick-pp 0.2.68__tar.gz → 0.2.69__tar.gz
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.
- {quick_pp-0.2.68 → quick_pp-0.2.69}/PKG-INFO +1 -1
- {quick_pp-0.2.68 → quick_pp-0.2.69}/pyproject.toml +1 -1
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/__init__.py +1 -1
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/config.py +34 -6
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/lithology/multi_mineral.py +81 -70
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/plotter/well_log_config.py +63 -21
- {quick_pp-0.2.68 → quick_pp-0.2.69}/.gitignore +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/LICENSE +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/README.md +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/exceptions.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/fastapi_mlflow/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/fastapi_mlflow/_mlflow_types.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/fastapi_mlflow/applications.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/fastapi_mlflow/exceptions.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/fastapi_mlflow/predictors.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/main.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/mlflow_model_deployment.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/router.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/schemas/lithology_hc_correction.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/schemas/lithology_ssc.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/schemas/lithology_vsh_gr.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/schemas/permeability_choo.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/schemas/permeability_others.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/schemas/porosity.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/schemas/ressum.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/schemas/saturation_archie.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/schemas/saturation_b.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/schemas/saturation_qv.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/schemas/saturation_rw.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/schemas/saturation_temp_grad.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/schemas/saturation_waxman_smits.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/services/chat.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/services/las_handler.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/services/lithology.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/services/permeability.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/services/porosity.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/services/reservoir_summary.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/services/saturation.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/static/favicon.ico +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/static/logo.png +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/template/chat.html +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/api/template/home.html +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/cli.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/core_calibration.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/database/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/database/db_connector.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/database/models.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/database/objects.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/database/setup_postgresql_db.sql +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/database/setup_sqlite_db.sql +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/fluid_type.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/las_handler.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/lithology/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/lithology/carbonate.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/lithology/sand_shale.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/lithology/sand_silt_clay.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/lithology/thin_beds.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/machine_learning/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/machine_learning/config.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/machine_learning/feature_engineering.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/machine_learning/mock_data/mock_data.parquet +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/machine_learning/predict_pipeline.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/machine_learning/train_pipeline.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/machine_learning/utils.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/permeability.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/plotter/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/plotter/plotter.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/plotter/well_log.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/porosity.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/qaqc.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/ressum.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/rock_physics/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/rock_physics/geomechanics.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/rock_physics/geophysics.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/rock_physics/rpm.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/rock_type.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/saturation.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.69}/quick_pp/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quick-pp
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.69
|
|
4
4
|
Summary: Python package to assist in providing quick-look/ preliminary petrophysical estimation.
|
|
5
5
|
Project-URL: Homepage, https://github.com/imranfadhil/quick_pp
|
|
6
6
|
Author-email: Imran Fadhil <imranfadhil@gmail.com>
|
|
@@ -20,4 +20,4 @@ logging.getLogger("mlflow").setLevel(logging.WARNING)
|
|
|
20
20
|
|
|
21
21
|
__author__ = """Imran Fadhil"""
|
|
22
22
|
__email__ = 'imranfadhil@gmail.com'
|
|
23
|
-
__version__ = '0.2.
|
|
23
|
+
__version__ = '0.2.69' # Need to be updated manually when releasing a new version/ change in pyproject.toml
|
|
@@ -75,12 +75,26 @@ class Config(object):
|
|
|
75
75
|
'DTC_DOLOMITE': 43.5,
|
|
76
76
|
'PEF_DOLOMITE': 3.1,
|
|
77
77
|
|
|
78
|
-
#
|
|
79
|
-
'GR_SHALE':
|
|
80
|
-
'NPHI_SHALE': 0.
|
|
81
|
-
'RHOB_SHALE': 2.
|
|
82
|
-
'DTC_SHALE':
|
|
83
|
-
'PEF_SHALE':
|
|
78
|
+
# Generic Shale (e.g., Illite/Smectite mix)
|
|
79
|
+
'GR_SHALE': 150.0,
|
|
80
|
+
'NPHI_SHALE': 0.30,
|
|
81
|
+
'RHOB_SHALE': 2.55,
|
|
82
|
+
'DTC_SHALE': 120.0,
|
|
83
|
+
'PEF_SHALE': 3.5,
|
|
84
|
+
|
|
85
|
+
# Kaolinite (as a separate mineral option)
|
|
86
|
+
'GR_KAOLINITE': 35.0,
|
|
87
|
+
'NPHI_KAOLINITE': 0.37,
|
|
88
|
+
'RHOB_KAOLINITE': 2.41,
|
|
89
|
+
'DTC_KAOLINITE': 143.0,
|
|
90
|
+
'PEF_KAOLINITE': 1.8,
|
|
91
|
+
|
|
92
|
+
# Feldspar
|
|
93
|
+
'GR_FELDSPAR': 150.0,
|
|
94
|
+
'NPHI_FELDSPAR': 0.02,
|
|
95
|
+
'RHOB_FELDSPAR': 2.56,
|
|
96
|
+
'DTC_FELDSPAR': 70.0,
|
|
97
|
+
'PEF_FELDSPAR': 3.1,
|
|
84
98
|
|
|
85
99
|
# Anhydrite
|
|
86
100
|
'GR_ANHYDRITE': 0.0,
|
|
@@ -102,6 +116,20 @@ class Config(object):
|
|
|
102
116
|
'RHOB_HALITE': 2.04,
|
|
103
117
|
'DTC_HALITE': 67.0,
|
|
104
118
|
'PEF_HALITE': 4.7,
|
|
119
|
+
|
|
120
|
+
# Pyrite
|
|
121
|
+
'GR_PYRITE': 0.0,
|
|
122
|
+
'NPHI_PYRITE': -0.02,
|
|
123
|
+
'RHOB_PYRITE': 5.0,
|
|
124
|
+
'DTC_PYRITE': 65.0,
|
|
125
|
+
'PEF_PYRITE': 17.0,
|
|
126
|
+
|
|
127
|
+
# Coal
|
|
128
|
+
'GR_COAL': 30.0,
|
|
129
|
+
'NPHI_COAL': 0.50,
|
|
130
|
+
'RHOB_COAL': 1.3,
|
|
131
|
+
'DTC_COAL': 150.0,
|
|
132
|
+
'PEF_COAL': 0.2,
|
|
105
133
|
}
|
|
106
134
|
|
|
107
135
|
GEOMECHANICS_VALUE = dict(
|
|
@@ -9,7 +9,7 @@ from quick_pp import logger
|
|
|
9
9
|
from quick_pp.porosity import neu_den_xplot_poro_pt, density_porosity
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class
|
|
12
|
+
class MultiMineral:
|
|
13
13
|
"""Optimization-based multi-mineral model for lithology estimation with fluid volumes."""
|
|
14
14
|
|
|
15
15
|
def __init__(self, minerals: Optional[List[str]] = None,
|
|
@@ -21,8 +21,9 @@ class MultiMineralOptimizer:
|
|
|
21
21
|
|
|
22
22
|
Args:
|
|
23
23
|
minerals: List of minerals to include in the optimization.
|
|
24
|
-
If None, uses default minerals: ['QUARTZ', 'CALCITE', 'DOLOMITE', 'SHALE'
|
|
25
|
-
Available options: 'QUARTZ', 'CALCITE', 'DOLOMITE', 'SHALE', 'ANHYDRITE',
|
|
24
|
+
If None, uses default minerals: ['QUARTZ', 'CALCITE', 'DOLOMITE', 'SHALE']
|
|
25
|
+
Available options: 'QUARTZ', 'CALCITE', 'DOLOMITE', 'SHALE', 'ANHYDRITE',
|
|
26
|
+
'GYPSUM', 'HALITE', 'PYRITE', 'FELDSPAR', 'COAL'
|
|
26
27
|
fluid_properties: Dictionary containing fluid properties for oil, gas, and water.
|
|
27
28
|
If None, uses default properties:
|
|
28
29
|
{
|
|
@@ -35,7 +36,7 @@ class MultiMineralOptimizer:
|
|
|
35
36
|
"""
|
|
36
37
|
# Default minerals if none specified
|
|
37
38
|
if minerals is None:
|
|
38
|
-
minerals = ['QUARTZ', 'CALCITE', 'DOLOMITE', 'SHALE'
|
|
39
|
+
minerals = ['QUARTZ', 'CALCITE', 'DOLOMITE', 'SHALE']
|
|
39
40
|
|
|
40
41
|
self.minerals = minerals
|
|
41
42
|
self.porosity_method = porosity_method
|
|
@@ -50,17 +51,22 @@ class MultiMineralOptimizer:
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
self.fluid_properties = fluid_properties
|
|
54
|
+
self.rho_fluid = self.fluid_properties['WATER']['density'] # Assume water for fluid density
|
|
53
55
|
self.fluids = ['OIL', 'GAS', 'WATER']
|
|
54
56
|
|
|
55
57
|
# Define bounds for each mineral type
|
|
56
58
|
mineral_bounds = {
|
|
57
59
|
'QUARTZ': (0, 1),
|
|
58
60
|
'CALCITE': (0, 1),
|
|
59
|
-
'DOLOMITE': (0,
|
|
61
|
+
'DOLOMITE': (0, 1),
|
|
60
62
|
'SHALE': (0, 1),
|
|
63
|
+
'KAOLINITE': (0, 1),
|
|
64
|
+
'FELDSPAR': (0, 1),
|
|
61
65
|
'ANHYDRITE': (0, 1),
|
|
62
66
|
'GYPSUM': (0, 1),
|
|
63
|
-
'HALITE': (0, 1)
|
|
67
|
+
'HALITE': (0, 1),
|
|
68
|
+
'PYRITE': (0, 1),
|
|
69
|
+
'COAL': (0, 1)
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
# Define bounds for fluid volumes (0 to 1 for each fluid)
|
|
@@ -96,7 +102,8 @@ class MultiMineralOptimizer:
|
|
|
96
102
|
"""Constraint function ensuring mineral volumes + fluid volumes sum to 1."""
|
|
97
103
|
return np.sum(volumes) - 1
|
|
98
104
|
|
|
99
|
-
def _calculate_porosity(self, nphi: float, rhob: float, dtc: Optional[float] = None
|
|
105
|
+
def _calculate_porosity(self, nphi: float, rhob: float, dtc: Optional[float] = None,
|
|
106
|
+
volumes: Optional[np.ndarray] = None) -> float:
|
|
100
107
|
"""Calculate porosity using the specified method."""
|
|
101
108
|
if self.porosity_method == 'neutron_density':
|
|
102
109
|
# Use neutron-density crossplot porosity
|
|
@@ -112,9 +119,16 @@ class MultiMineralOptimizer:
|
|
|
112
119
|
)
|
|
113
120
|
|
|
114
121
|
elif self.porosity_method == 'density':
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
if volumes is not None:
|
|
123
|
+
# Calculate matrix density from the current mineral volumes during optimization
|
|
124
|
+
mineral_vols = volumes[:len(self.minerals)]
|
|
125
|
+
matrix_vol = np.sum(mineral_vols)
|
|
126
|
+
if matrix_vol > 1e-3:
|
|
127
|
+
rho_ma = self._calculate_matrix_density(mineral_vols) / matrix_vol
|
|
128
|
+
else:
|
|
129
|
+
rho_ma = 2.65 # Fallback if no matrix
|
|
130
|
+
else:
|
|
131
|
+
rho_ma = 2.65 # Default for initial guess if volumes are not provided
|
|
118
132
|
return density_porosity(rhob, rho_ma, self.rho_fluid)
|
|
119
133
|
|
|
120
134
|
elif self.porosity_method == 'sonic':
|
|
@@ -201,16 +215,26 @@ class MultiMineralOptimizer:
|
|
|
201
215
|
"""
|
|
202
216
|
total_error = 0.0
|
|
203
217
|
|
|
218
|
+
# Porosity is the sum of fluid volumes
|
|
219
|
+
porosity = np.sum(volumes[len(self.minerals):])
|
|
220
|
+
|
|
204
221
|
for log_type, measured_value in log_values.items():
|
|
205
222
|
if measured_value is not None and not np.isnan(measured_value):
|
|
206
|
-
|
|
223
|
+
if self.porosity_method == 'density' and log_type == 'RHOB':
|
|
224
|
+
# For density porosity, RHOB is reconstructed from porosity and matrix density
|
|
225
|
+
mineral_vols = volumes[:len(self.minerals)]
|
|
226
|
+
rho_ma = self._calculate_matrix_density(mineral_vols)
|
|
227
|
+
reconstructed_value = rho_ma * (1 - porosity) + self.rho_fluid * porosity
|
|
228
|
+
else:
|
|
229
|
+
reconstructed_value = self._calculate_log_response(volumes, log_type)
|
|
230
|
+
|
|
207
231
|
scaling = self.scaling_factors.get(log_type, 1.0)
|
|
208
232
|
error = (scaling * (measured_value - reconstructed_value)) ** 2
|
|
209
233
|
total_error += error
|
|
210
234
|
|
|
211
235
|
return total_error
|
|
212
236
|
|
|
213
|
-
def _optimize_volumes(self, log_values: Dict[str, float]) -> Tuple[np.ndarray, np.ndarray]:
|
|
237
|
+
def _optimize_volumes(self, log_values: Dict[str, float]) -> Tuple[np.ndarray, np.ndarray, bool]:
|
|
214
238
|
"""
|
|
215
239
|
Optimize mineral and fluid volumes given available log measurements.
|
|
216
240
|
|
|
@@ -218,7 +242,7 @@ class MultiMineralOptimizer:
|
|
|
218
242
|
log_values: Dictionary of measured log values
|
|
219
243
|
|
|
220
244
|
Returns:
|
|
221
|
-
Tuple of (optimized mineral volumes, fluid volumes)
|
|
245
|
+
Tuple of (optimized mineral volumes, fluid volumes, success_flag)
|
|
222
246
|
"""
|
|
223
247
|
# Filter out None and NaN values
|
|
224
248
|
valid_logs = {k: v for k, v in log_values.items()
|
|
@@ -232,16 +256,21 @@ class MultiMineralOptimizer:
|
|
|
232
256
|
rhob = log_values.get('RHOB', 2.65)
|
|
233
257
|
dtc = log_values.get('DTC', None)
|
|
234
258
|
|
|
235
|
-
if nphi is not None and rhob is not None:
|
|
236
|
-
initial_porosity = self._calculate_porosity(nphi, rhob, dtc)
|
|
237
|
-
initial_porosity = max(0.0, min(0.5, initial_porosity)) # Constrain to reasonable range
|
|
238
|
-
else:
|
|
239
|
-
initial_porosity = 0.1 # Default porosity
|
|
240
|
-
|
|
241
259
|
# Initial guess: equal distribution among minerals and fluids
|
|
242
260
|
n_minerals = len(self.minerals)
|
|
243
261
|
n_fluids = len(self.fluids)
|
|
244
262
|
|
|
263
|
+
# Create an initial guess for volumes to pass to porosity calculation
|
|
264
|
+
initial_mineral_guess = np.full(n_minerals, (1.0 - 0.1) / n_minerals)
|
|
265
|
+
initial_fluid_guess = np.full(n_fluids, 0.1 / n_fluids)
|
|
266
|
+
initial_guess_for_poro = np.concatenate([initial_mineral_guess, initial_fluid_guess])
|
|
267
|
+
|
|
268
|
+
if nphi is not None and rhob is not None:
|
|
269
|
+
initial_porosity = self._calculate_porosity(nphi, rhob, dtc, volumes=initial_guess_for_poro)
|
|
270
|
+
initial_porosity = max(0.0, min(0.4, initial_porosity)) # Constrain to reasonable range
|
|
271
|
+
else:
|
|
272
|
+
initial_porosity = 0.01 # Default porosity
|
|
273
|
+
|
|
245
274
|
# Distribute volume between minerals and fluids
|
|
246
275
|
mineral_volume = (1.0 - initial_porosity) / n_minerals
|
|
247
276
|
fluid_volume = initial_porosity / n_fluids
|
|
@@ -265,10 +294,10 @@ class MultiMineralOptimizer:
|
|
|
265
294
|
mineral_volumes = result.x[:n_minerals]
|
|
266
295
|
fluid_volumes = result.x[n_minerals:]
|
|
267
296
|
|
|
268
|
-
return mineral_volumes, fluid_volumes
|
|
297
|
+
return mineral_volumes, fluid_volumes, result.success
|
|
269
298
|
|
|
270
299
|
def estimate_lithology(self, gr: np.ndarray, nphi: np.ndarray, rhob: np.ndarray, pef: Optional[np.ndarray] = None,
|
|
271
|
-
dtc: Optional[np.ndarray] = None) -> pd.DataFrame:
|
|
300
|
+
dtc: Optional[np.ndarray] = None, auto_scale: bool = True) -> pd.DataFrame:
|
|
272
301
|
"""
|
|
273
302
|
Estimate mineral and fluid volumes using available log measurements.
|
|
274
303
|
|
|
@@ -278,6 +307,7 @@ class MultiMineralOptimizer:
|
|
|
278
307
|
rhob: Bulk Density log in g/cc
|
|
279
308
|
pef: Photoelectric Factor log in barns/electron (optional)
|
|
280
309
|
dtc: Compressional slowness log in us/ft (optional)
|
|
310
|
+
auto_scale: If True, automatically calculate scaling factors based on log ranges.
|
|
281
311
|
|
|
282
312
|
Returns:
|
|
283
313
|
DataFrame containing:
|
|
@@ -285,6 +315,7 @@ class MultiMineralOptimizer:
|
|
|
285
315
|
- Fluid volume fractions for each fluid in self.fluids
|
|
286
316
|
- PHIT_CONSTRUCTED: Total porosity (sum of fluid volumes)
|
|
287
317
|
- AVERAGE_ERROR: Average error between measured and reconstructed logs
|
|
318
|
+
- OPTIMIZER_SUCCESS: Boolean flag indicating if the optimization was successful.
|
|
288
319
|
- *_RECONSTRUCTED: Reconstructed log values for each log type
|
|
289
320
|
"""
|
|
290
321
|
# Initialize output arrays
|
|
@@ -313,6 +344,26 @@ class MultiMineralOptimizer:
|
|
|
313
344
|
# Initialize error array
|
|
314
345
|
average_errors = np.full(n_samples, np.nan)
|
|
315
346
|
|
|
347
|
+
# Initialize QC flags
|
|
348
|
+
success_flags = np.full(n_samples, False, dtype=bool)
|
|
349
|
+
|
|
350
|
+
# Dynamic scaling based on log ranges for robustness
|
|
351
|
+
if auto_scale:
|
|
352
|
+
all_logs = {'GR': gr, 'NPHI': nphi, 'RHOB': rhob, 'PEF': pef, 'DTC': dtc}
|
|
353
|
+
for log_type, log_data in all_logs.items():
|
|
354
|
+
if log_data is not None:
|
|
355
|
+
# Use 5th and 95th percentiles to calculate a robust range, ignoring NaNs
|
|
356
|
+
valid_data = log_data[~np.isnan(log_data)]
|
|
357
|
+
if len(valid_data) > 1:
|
|
358
|
+
p05 = np.percentile(valid_data, 5)
|
|
359
|
+
p95 = np.percentile(valid_data, 95)
|
|
360
|
+
log_range = p95 - p05
|
|
361
|
+
if log_range > 1e-6: # Avoid division by zero for flat logs
|
|
362
|
+
self.scaling_factors[log_type] = round(1.0 / log_range, 4)
|
|
363
|
+
else:
|
|
364
|
+
self.scaling_factors[log_type] = 1.0 # Default if range is zero
|
|
365
|
+
|
|
366
|
+
logger.info(f"Scaling factors: {self.scaling_factors}")
|
|
316
367
|
# Process each depth point
|
|
317
368
|
for i in tqdm(range(n_samples), desc="Processing depth points", unit="points"):
|
|
318
369
|
# Prepare log values for current depth
|
|
@@ -331,7 +382,7 @@ class MultiMineralOptimizer:
|
|
|
331
382
|
if len(valid_measurements) >= 3: # Need at least 3 measurements
|
|
332
383
|
try:
|
|
333
384
|
# Optimize mineral and fluid volumes
|
|
334
|
-
mineral_vols, fluid_vols = self._optimize_volumes(log_values)
|
|
385
|
+
mineral_vols, fluid_vols, success = self._optimize_volumes(log_values)
|
|
335
386
|
|
|
336
387
|
# Store results for each mineral
|
|
337
388
|
for j, mineral in enumerate(self.minerals):
|
|
@@ -343,6 +394,7 @@ class MultiMineralOptimizer:
|
|
|
343
394
|
|
|
344
395
|
# Store total porosity (sum of fluid volumes)
|
|
345
396
|
porosity_constructed[i] = np.sum(fluid_vols)
|
|
397
|
+
success_flags[i] = success
|
|
346
398
|
|
|
347
399
|
# Combine volumes for error calculation and log reconstruction
|
|
348
400
|
combined_volumes = np.concatenate([mineral_vols, fluid_vols])
|
|
@@ -363,10 +415,8 @@ class MultiMineralOptimizer:
|
|
|
363
415
|
combined_volumes, 'DTC') if log_values['DTC'] is not None else np.nan
|
|
364
416
|
|
|
365
417
|
except Exception as e:
|
|
366
|
-
|
|
418
|
+
tqdm.write(f'\rError at depth {i}: {e}', end='\r')
|
|
367
419
|
continue
|
|
368
|
-
else:
|
|
369
|
-
logger.error(f'\rInsufficient data at depth {i}')
|
|
370
420
|
|
|
371
421
|
# Create output DataFrame
|
|
372
422
|
output_data = {}
|
|
@@ -377,9 +427,13 @@ class MultiMineralOptimizer:
|
|
|
377
427
|
'CALCITE': 'VCALC',
|
|
378
428
|
'DOLOMITE': 'VDOLO',
|
|
379
429
|
'SHALE': 'VCLAY',
|
|
430
|
+
'KAOLINITE': 'VKAOL',
|
|
431
|
+
'FELDSPAR': 'VFELD',
|
|
380
432
|
'ANHYDRITE': 'VANHY',
|
|
381
433
|
'GYPSUM': 'VGYPS',
|
|
382
|
-
'HALITE': 'VHALI'
|
|
434
|
+
'HALITE': 'VHALI',
|
|
435
|
+
'PYRITE': 'VPYRI',
|
|
436
|
+
'COAL': 'VCOAL'
|
|
383
437
|
}
|
|
384
438
|
|
|
385
439
|
for mineral in self.minerals:
|
|
@@ -403,6 +457,7 @@ class MultiMineralOptimizer:
|
|
|
403
457
|
# Add error and reconstructed logs
|
|
404
458
|
output_data.update({
|
|
405
459
|
'AVG_ERROR': average_errors,
|
|
460
|
+
'OPTIMIZER_SUCCESS': success_flags,
|
|
406
461
|
'GR_RECONSTRUCTED': gr_reconstructed,
|
|
407
462
|
'NPHI_RECONSTRUCTED': nphi_reconstructed,
|
|
408
463
|
'RHOB_RECONSTRUCTED': rhob_reconstructed,
|
|
@@ -411,47 +466,3 @@ class MultiMineralOptimizer:
|
|
|
411
466
|
})
|
|
412
467
|
|
|
413
468
|
return pd.DataFrame(output_data)
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
class MultiMineral:
|
|
417
|
-
"""Legacy interface for backward compatibility."""
|
|
418
|
-
|
|
419
|
-
def __init__(self, minerals: Optional[List[str]] = None,
|
|
420
|
-
fluid_properties: Optional[Dict] = None,
|
|
421
|
-
porosity_method: str = 'neutron_density',
|
|
422
|
-
porosity_endpoints: Optional[Dict] = None):
|
|
423
|
-
"""
|
|
424
|
-
Initialize MultiMineral with optional mineral and fluid specification.
|
|
425
|
-
|
|
426
|
-
Args:
|
|
427
|
-
minerals: List of minerals to include in the optimization.
|
|
428
|
-
If None, uses default minerals:
|
|
429
|
-
['QUARTZ', 'CALCITE', 'DOLOMITE', 'SHALE', 'ANHYDRITE']
|
|
430
|
-
Available options: 'QUARTZ', 'CALCITE', 'DOLOMITE', 'SHALE', 'ANHYDRITE', 'GYPSUM', 'HALITE'
|
|
431
|
-
fluid_properties: Dictionary containing fluid properties for oil, gas, and water.
|
|
432
|
-
If None, uses default properties
|
|
433
|
-
porosity_method: Method for calculating porosity ('neutron_density', 'density', 'sonic')
|
|
434
|
-
porosity_endpoints: Endpoints for porosity calculation (for neutron_density method)
|
|
435
|
-
"""
|
|
436
|
-
self.optimizer = MultiMineralOptimizer(
|
|
437
|
-
minerals=minerals,
|
|
438
|
-
fluid_properties=fluid_properties,
|
|
439
|
-
porosity_method=porosity_method,
|
|
440
|
-
porosity_endpoints=porosity_endpoints
|
|
441
|
-
)
|
|
442
|
-
|
|
443
|
-
def estimate_lithology(self, gr, nphi, rhob, pef=None, dtc=None):
|
|
444
|
-
"""
|
|
445
|
-
Estimate lithology and fluid volumes using multi-mineral optimization.
|
|
446
|
-
|
|
447
|
-
Args:
|
|
448
|
-
gr (np.ndarray): Gamma Ray log in GAPI.
|
|
449
|
-
nphi (np.ndarray): Neutron Porosity log in v/v.
|
|
450
|
-
rhob (np.ndarray): Bulk Density log in g/cc.
|
|
451
|
-
pef (np.ndarray, optional): Photoelectric Factor log in barns/electron.
|
|
452
|
-
dtc (np.ndarray, optional): Compressional slowness log in us/ft.
|
|
453
|
-
|
|
454
|
-
Returns:
|
|
455
|
-
pd.DataFrame: DataFrame containing mineral volumes, fluid volumes, and reconstructed logs
|
|
456
|
-
"""
|
|
457
|
-
return self.optimizer.estimate_lithology(gr, nphi, rhob, pef, dtc)
|
|
@@ -4,7 +4,7 @@ import numpy as np
|
|
|
4
4
|
COLOR_DICT = {
|
|
5
5
|
'BADHOLE': 'rgba(0, 0, 0, .25)',
|
|
6
6
|
'BS': 'brown',
|
|
7
|
-
'BVW': "#
|
|
7
|
+
'BVW': "#B7EDFF",
|
|
8
8
|
'CALI': '#618F63',
|
|
9
9
|
'COAL_FLAG': '#262626',
|
|
10
10
|
'CPERM': '#FF0000',
|
|
@@ -28,8 +28,10 @@ COLOR_DICT = {
|
|
|
28
28
|
'SWT': '#262626',
|
|
29
29
|
'VANHY': '#E9DF53',
|
|
30
30
|
'VCALC': '#b0e0e6',
|
|
31
|
-
'VCLAY':
|
|
32
|
-
'
|
|
31
|
+
'VCLAY': "#949494",
|
|
32
|
+
'VFELD': "#B6B5B5",
|
|
33
|
+
'VKAOL': '#D3D3D3',
|
|
34
|
+
'VCOAL': "#000000",
|
|
33
35
|
'VDOLO': '#ba55d3',
|
|
34
36
|
'VGAS': '#FF0000',
|
|
35
37
|
'VGYPS': '#6C55D3',
|
|
@@ -38,8 +40,9 @@ COLOR_DICT = {
|
|
|
38
40
|
'VOIL': '#00FF00',
|
|
39
41
|
'VSAND': '#F6F674',
|
|
40
42
|
'VSHALE': '#A65628',
|
|
43
|
+
'VPYRI': "#007FD4",
|
|
41
44
|
'VSILT': '#FE9800',
|
|
42
|
-
'VWATER':
|
|
45
|
+
'VWATER': "#B7EDFF",
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
# Define the trace definitions for the well log plot
|
|
@@ -169,44 +172,43 @@ TRACE_DEFS = dict(
|
|
|
169
172
|
hide_xaxis=False,
|
|
170
173
|
style={'line_width': 0, 'fill': 'tozerox', 'fillcolor': 'rgba(0, 0, 0, .15)'}
|
|
171
174
|
),
|
|
172
|
-
|
|
175
|
+
VFELD=dict(
|
|
173
176
|
track=8,
|
|
174
177
|
secondary_y=False,
|
|
175
178
|
hide_xaxis=True,
|
|
176
179
|
style={
|
|
177
|
-
'line_width': .5, 'line_color': 'black', 'fill': 'tonextx', 'fillpattern_bgcolor': COLOR_DICT['
|
|
178
|
-
'fillpattern_fgcolor': '#000000', 'fillpattern_fillmode': 'replace', 'fillpattern_shape': '
|
|
179
|
-
'fillpattern_size': 3, 'fillpattern_solidity': 0.
|
|
180
|
+
'line_width': .5, 'line_color': 'black', 'fill': 'tonextx', 'fillpattern_bgcolor': COLOR_DICT['VFELD'],
|
|
181
|
+
'fillpattern_fgcolor': '#000000', 'fillpattern_fillmode': 'replace', 'fillpattern_shape': '+',
|
|
182
|
+
'fillpattern_size': 3, 'fillpattern_solidity': 0.2, 'stackgroup': 'litho', 'orientation': 'h'
|
|
180
183
|
}
|
|
181
184
|
),
|
|
182
|
-
|
|
185
|
+
VKAOL=dict(
|
|
183
186
|
track=8,
|
|
184
187
|
secondary_y=False,
|
|
185
188
|
hide_xaxis=True,
|
|
186
189
|
style={
|
|
187
|
-
'line_width': .5, 'line_color': 'black', 'fill': 'tonextx', 'fillpattern_bgcolor': COLOR_DICT['
|
|
188
|
-
'fillpattern_fgcolor': '#000000', 'fillpattern_fillmode': 'replace', 'fillpattern_shape': '
|
|
189
|
-
'fillpattern_size':
|
|
190
|
+
'line_width': .5, 'line_color': 'black', 'fill': 'tonextx', 'fillpattern_bgcolor': COLOR_DICT['VKAOL'],
|
|
191
|
+
'fillpattern_fgcolor': '#000000', 'fillpattern_fillmode': 'replace', 'fillpattern_shape': '-',
|
|
192
|
+
'fillpattern_size': 2, 'fillpattern_solidity': 0.1, 'stackgroup': 'litho', 'orientation': 'h'
|
|
190
193
|
}
|
|
191
194
|
),
|
|
192
|
-
|
|
195
|
+
VCOAL=dict(
|
|
193
196
|
track=8,
|
|
194
197
|
secondary_y=False,
|
|
195
198
|
hide_xaxis=True,
|
|
196
199
|
style={
|
|
197
|
-
'line_width': .5, 'line_color': 'black', 'fill': 'tonextx', 'fillpattern_bgcolor': COLOR_DICT['
|
|
198
|
-
'
|
|
199
|
-
'fillpattern_size': 3, 'fillpattern_solidity': 0.1, 'stackgroup': 'litho', 'orientation': 'h'
|
|
200
|
+
'line_width': .5, 'line_color': 'black', 'fill': 'tonextx', 'fillpattern_bgcolor': COLOR_DICT['VCOAL'],
|
|
201
|
+
'stackgroup': 'litho', 'orientation': 'h'
|
|
200
202
|
}
|
|
201
203
|
),
|
|
202
|
-
|
|
204
|
+
VPYRI=dict(
|
|
203
205
|
track=8,
|
|
204
206
|
secondary_y=False,
|
|
205
207
|
hide_xaxis=True,
|
|
206
208
|
style={
|
|
207
|
-
'line_width': .5, 'line_color': 'black', 'fill': 'tonextx', 'fillpattern_bgcolor': COLOR_DICT['
|
|
208
|
-
'fillpattern_fgcolor': '#000000', 'fillpattern_fillmode': 'replace', 'fillpattern_shape': '
|
|
209
|
-
'fillpattern_size':
|
|
209
|
+
'line_width': .5, 'line_color': 'black', 'fill': 'tonextx', 'fillpattern_bgcolor': COLOR_DICT['VPYRI'],
|
|
210
|
+
'fillpattern_fgcolor': '#000000', 'fillpattern_fillmode': 'replace', 'fillpattern_shape': 'x',
|
|
211
|
+
'fillpattern_size': 2, 'fillpattern_solidity': 0.4, 'stackgroup': 'litho', 'orientation': 'h'
|
|
210
212
|
}
|
|
211
213
|
),
|
|
212
214
|
VANHY=dict(
|
|
@@ -239,6 +241,46 @@ TRACE_DEFS = dict(
|
|
|
239
241
|
'fillpattern_size': 4, 'fillpattern_solidity': 0.1, 'stackgroup': 'litho', 'orientation': 'h'
|
|
240
242
|
}
|
|
241
243
|
),
|
|
244
|
+
VSILT=dict(
|
|
245
|
+
track=8,
|
|
246
|
+
secondary_y=False,
|
|
247
|
+
hide_xaxis=True,
|
|
248
|
+
style={
|
|
249
|
+
'line_width': .5, 'line_color': 'black', 'fill': 'tonextx', 'fillpattern_bgcolor': COLOR_DICT['VSILT'],
|
|
250
|
+
'fillpattern_fgcolor': '#000000', 'fillpattern_fillmode': 'replace', 'fillpattern_shape': '.',
|
|
251
|
+
'fillpattern_size': 3, 'fillpattern_solidity': 0.1, 'stackgroup': 'litho', 'orientation': 'h'
|
|
252
|
+
}
|
|
253
|
+
),
|
|
254
|
+
VSAND=dict(
|
|
255
|
+
track=8,
|
|
256
|
+
secondary_y=False,
|
|
257
|
+
hide_xaxis=True,
|
|
258
|
+
style={
|
|
259
|
+
'line_width': .5, 'line_color': 'black', 'fill': 'tonextx', 'fillpattern_bgcolor': COLOR_DICT['VSAND'],
|
|
260
|
+
'fillpattern_fgcolor': '#000000', 'fillpattern_fillmode': 'replace', 'fillpattern_shape': '.',
|
|
261
|
+
'fillpattern_size': 3, 'fillpattern_solidity': 0.1, 'stackgroup': 'litho', 'orientation': 'h'
|
|
262
|
+
}
|
|
263
|
+
),
|
|
264
|
+
VCALC=dict(
|
|
265
|
+
track=8,
|
|
266
|
+
secondary_y=False,
|
|
267
|
+
hide_xaxis=True,
|
|
268
|
+
style={
|
|
269
|
+
'line_width': .5, 'line_color': 'black', 'fill': 'tonextx', 'fillpattern_bgcolor': COLOR_DICT['VCALC'],
|
|
270
|
+
'fillpattern_fgcolor': '#000000', 'fillpattern_fillmode': 'replace', 'fillpattern_shape': '.',
|
|
271
|
+
'fillpattern_size': 3, 'fillpattern_solidity': 0.1, 'stackgroup': 'litho', 'orientation': 'h'
|
|
272
|
+
}
|
|
273
|
+
),
|
|
274
|
+
VDOLO=dict(
|
|
275
|
+
track=8,
|
|
276
|
+
secondary_y=False,
|
|
277
|
+
hide_xaxis=True,
|
|
278
|
+
style={
|
|
279
|
+
'line_width': .5, 'line_color': 'black', 'fill': 'tonextx', 'fillpattern_bgcolor': COLOR_DICT['VDOLO'],
|
|
280
|
+
'fillpattern_fgcolor': '#000000', 'fillpattern_fillmode': 'replace', 'fillpattern_shape': '-',
|
|
281
|
+
'fillpattern_size': 3, 'fillpattern_solidity': 0.3, 'stackgroup': 'litho', 'orientation': 'h'
|
|
282
|
+
}
|
|
283
|
+
),
|
|
242
284
|
VHC=dict(
|
|
243
285
|
track=8,
|
|
244
286
|
secondary_y=False,
|
|
@@ -351,7 +393,7 @@ XAXIS_DEFS = dict(
|
|
|
351
393
|
title={'text': 'PERM (mD)', 'font': {'color': COLOR_DICT['PERM'], 'size': font_size}},
|
|
352
394
|
tickfont={'color': COLOR_DICT['PERM'], 'size': font_size},
|
|
353
395
|
side='top', anchor='free', position=.91, title_standoff=.1,
|
|
354
|
-
dtick=0.1, range=[np.log10(0.1), np.log10(1e5)], type='log',
|
|
396
|
+
dtick=0.1, range=[np.log10(0.1), np.log10(1e5)], type='log',
|
|
355
397
|
tickmode='array', tickvals=np.geomspace(0.1, 1e5, 7), tickangle=-90,
|
|
356
398
|
minor_showgrid=True
|
|
357
399
|
),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|