quick-pp 0.2.68__tar.gz → 0.2.70__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.70}/PKG-INFO +1 -1
- {quick_pp-0.2.68 → quick_pp-0.2.70}/pyproject.toml +1 -1
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/__init__.py +1 -1
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/config.py +24 -44
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/lithology/multi_mineral.py +99 -107
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/plotter/well_log_config.py +63 -21
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/porosity.py +66 -31
- {quick_pp-0.2.68 → quick_pp-0.2.70}/.gitignore +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/LICENSE +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/README.md +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/exceptions.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/fastapi_mlflow/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/fastapi_mlflow/_mlflow_types.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/fastapi_mlflow/applications.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/fastapi_mlflow/exceptions.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/fastapi_mlflow/predictors.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/main.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/mlflow_model_deployment.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/router.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/schemas/lithology_hc_correction.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/schemas/lithology_ssc.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/schemas/lithology_vsh_gr.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/schemas/permeability_choo.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/schemas/permeability_others.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/schemas/porosity.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/schemas/ressum.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/schemas/saturation_archie.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/schemas/saturation_b.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/schemas/saturation_qv.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/schemas/saturation_rw.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/schemas/saturation_temp_grad.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/schemas/saturation_waxman_smits.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/services/chat.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/services/las_handler.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/services/lithology.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/services/permeability.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/services/porosity.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/services/reservoir_summary.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/services/saturation.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/static/favicon.ico +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/static/logo.png +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/template/chat.html +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/api/template/home.html +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/cli.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/core_calibration.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/database/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/database/db_connector.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/database/models.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/database/objects.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/database/setup_postgresql_db.sql +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/database/setup_sqlite_db.sql +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/fluid_type.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/las_handler.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/lithology/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/lithology/carbonate.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/lithology/sand_shale.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/lithology/sand_silt_clay.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/lithology/thin_beds.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/machine_learning/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/machine_learning/config.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/machine_learning/feature_engineering.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/machine_learning/mock_data/mock_data.parquet +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/machine_learning/predict_pipeline.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/machine_learning/train_pipeline.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/machine_learning/utils.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/permeability.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/plotter/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/plotter/plotter.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/plotter/well_log.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/qaqc.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/ressum.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/rock_physics/__init__.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/rock_physics/geomechanics.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/rock_physics/geophysics.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/rock_physics/rpm.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/rock_type.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/quick_pp/saturation.py +0 -0
- {quick_pp-0.2.68 → quick_pp-0.2.70}/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.70
|
|
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.70' # Need to be updated manually when releasing a new version/ change in pyproject.toml
|
|
@@ -57,51 +57,31 @@ class Config(object):
|
|
|
57
57
|
)
|
|
58
58
|
|
|
59
59
|
MINERALS_LOG_VALUE = {
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
|
|
72
|
-
'GR_DOLOMITE': 0.0,
|
|
73
|
-
'NPHI_DOLOMITE': 0.01,
|
|
74
|
-
'RHOB_DOLOMITE': 2.85,
|
|
75
|
-
'DTC_DOLOMITE': 43.5,
|
|
76
|
-
'PEF_DOLOMITE': 3.1,
|
|
77
|
-
|
|
78
|
-
# Kaolinite
|
|
79
|
-
'GR_SHALE': 130.0,
|
|
80
|
-
'NPHI_SHALE': 0.37,
|
|
81
|
-
'RHOB_SHALE': 2.41,
|
|
82
|
-
'DTC_SHALE': 143.0,
|
|
83
|
-
'PEF_SHALE': 1.8,
|
|
84
|
-
|
|
85
|
-
# Anhydrite
|
|
86
|
-
'GR_ANHYDRITE': 0.0,
|
|
87
|
-
'NPHI_ANHYDRITE': -0.02,
|
|
88
|
-
'RHOB_ANHYDRITE': 2.98,
|
|
89
|
-
'DTC_ANHYDRITE': 50.0,
|
|
90
|
-
'PEF_ANHYDRITE': 5.1,
|
|
91
|
-
|
|
92
|
-
# Gypsum
|
|
93
|
-
'GR_GYPSUM': 0.0,
|
|
94
|
-
'NPHI_GYPSUM': 0.6,
|
|
95
|
-
'RHOB_GYPSUM': 2.35,
|
|
96
|
-
'DTC_GYPSUM': 52.0,
|
|
97
|
-
'PEF_GYPSUM': 4.0,
|
|
60
|
+
'QUARTZ': {'GR': 0.0, 'NPHI': -0.02, 'RHOB': 2.64, 'DTC': 52.9, 'PEF': 1.8},
|
|
61
|
+
'CALCITE': {'GR': 0.0, 'NPHI': 0.0, 'RHOB': 2.71, 'DTC': 49.7, 'PEF': 5.1},
|
|
62
|
+
'DOLOMITE': {'GR': 0.0, 'NPHI': 0.01, 'RHOB': 2.85, 'DTC': 43.5, 'PEF': 3.1},
|
|
63
|
+
'SHALE': {'GR': 150.0, 'NPHI': 0.30, 'RHOB': 2.55, 'DTC': 120.0, 'PEF': 3.5},
|
|
64
|
+
'KAOLINITE': {'GR': 35.0, 'NPHI': 0.37, 'RHOB': 2.41, 'DTC': 143.0, 'PEF': 1.8},
|
|
65
|
+
'FELDSPAR': {'GR': 150.0, 'NPHI': 0.02, 'RHOB': 2.56, 'DTC': 70.0, 'PEF': 3.1},
|
|
66
|
+
'ANHYDRITE': {'GR': 0.0, 'NPHI': -0.02, 'RHOB': 2.98, 'DTC': 50.0, 'PEF': 5.1},
|
|
67
|
+
'GYPSUM': {'GR': 0.0, 'NPHI': 0.6, 'RHOB': 2.35, 'DTC': 52.0, 'PEF': 4.0},
|
|
68
|
+
'HALITE': {'GR': 0.0, 'NPHI': -0.03, 'RHOB': 2.04, 'DTC': 67.0, 'PEF': 4.7},
|
|
69
|
+
'PYRITE': {'GR': 0.0, 'NPHI': -0.02, 'RHOB': 5.0, 'DTC': 65.0, 'PEF': 17.0},
|
|
70
|
+
'COAL': {'GR': 30.0, 'NPHI': 0.50, 'RHOB': 1.3, 'DTC': 150.0, 'PEF': 0.2},
|
|
71
|
+
}
|
|
98
72
|
|
|
99
|
-
|
|
100
|
-
'
|
|
101
|
-
'
|
|
102
|
-
'
|
|
103
|
-
'
|
|
104
|
-
'
|
|
73
|
+
MINERALS_NAME_MAPPING = {
|
|
74
|
+
'QUARTZ': 'VSAND',
|
|
75
|
+
'CALCITE': 'VCALC',
|
|
76
|
+
'DOLOMITE': 'VDOLO',
|
|
77
|
+
'SHALE': 'VCLAY',
|
|
78
|
+
'KAOLINITE': 'VKAOL',
|
|
79
|
+
'FELDSPAR': 'VFELD',
|
|
80
|
+
'ANHYDRITE': 'VANHY',
|
|
81
|
+
'GYPSUM': 'VGYPS',
|
|
82
|
+
'HALITE': 'VHALI',
|
|
83
|
+
'PYRITE': 'VPYRI',
|
|
84
|
+
'COAL': 'VCOAL'
|
|
105
85
|
}
|
|
106
86
|
|
|
107
87
|
GEOMECHANICS_VALUE = dict(
|
|
@@ -9,20 +9,20 @@ 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,
|
|
16
16
|
fluid_properties: Optional[Dict] = None,
|
|
17
|
-
porosity_method: str = '
|
|
17
|
+
porosity_method: str = 'density',
|
|
18
18
|
porosity_endpoints: Optional[Dict] = None):
|
|
19
19
|
"""
|
|
20
20
|
Initialize the 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
|
|
24
|
+
If None, uses default minerals: ['QUARTZ', 'CALCITE', 'DOLOMITE', 'SHALE'].
|
|
25
|
+
Available minerals are dynamically loaded from `Config.MINERALS_LOG_VALUE`.
|
|
26
26
|
fluid_properties: Dictionary containing fluid properties for oil, gas, and water.
|
|
27
27
|
If None, uses default properties:
|
|
28
28
|
{
|
|
@@ -33,9 +33,16 @@ class MultiMineralOptimizer:
|
|
|
33
33
|
porosity_method: Method for calculating porosity ('neutron_density', 'density', 'sonic')
|
|
34
34
|
porosity_endpoints: Endpoints for porosity calculation (for neutron_density method)
|
|
35
35
|
"""
|
|
36
|
+
self.responses = Config.MINERALS_LOG_VALUE
|
|
37
|
+
available_minerals = list(self.responses.keys())
|
|
38
|
+
|
|
36
39
|
# Default minerals if none specified
|
|
37
40
|
if minerals is None:
|
|
38
|
-
minerals = ['QUARTZ', 'CALCITE', 'DOLOMITE', 'SHALE'
|
|
41
|
+
minerals = ['QUARTZ', 'CALCITE', 'DOLOMITE', 'SHALE']
|
|
42
|
+
|
|
43
|
+
for mineral in minerals:
|
|
44
|
+
if mineral not in available_minerals:
|
|
45
|
+
raise ValueError(f"Mineral '{mineral}' is not defined in Config.MINERALS_LOG_VALUE.")
|
|
39
46
|
|
|
40
47
|
self.minerals = minerals
|
|
41
48
|
self.porosity_method = porosity_method
|
|
@@ -48,20 +55,11 @@ class MultiMineralOptimizer:
|
|
|
48
55
|
'GAS': {'density': 0.2, 'nphi': 0.0, 'pef': 0.0, 'dtc': 400.0},
|
|
49
56
|
'WATER': {'density': 1.0, 'nphi': 1.0, 'pef': 0.0, 'dtc': 190.0}
|
|
50
57
|
}
|
|
51
|
-
|
|
52
58
|
self.fluid_properties = fluid_properties
|
|
53
59
|
self.fluids = ['OIL', 'GAS', 'WATER']
|
|
54
60
|
|
|
55
61
|
# Define bounds for each mineral type
|
|
56
|
-
mineral_bounds = {
|
|
57
|
-
'QUARTZ': (0, 1),
|
|
58
|
-
'CALCITE': (0, 1),
|
|
59
|
-
'DOLOMITE': (0, 0.1),
|
|
60
|
-
'SHALE': (0, 1),
|
|
61
|
-
'ANHYDRITE': (0, 1),
|
|
62
|
-
'GYPSUM': (0, 1),
|
|
63
|
-
'HALITE': (0, 1)
|
|
64
|
-
}
|
|
62
|
+
mineral_bounds = {mineral: (0, 1) for mineral in available_minerals}
|
|
65
63
|
|
|
66
64
|
# Define bounds for fluid volumes (0 to 1 for each fluid)
|
|
67
65
|
fluid_bounds = {
|
|
@@ -79,18 +77,7 @@ class MultiMineralOptimizer:
|
|
|
79
77
|
|
|
80
78
|
# Constraint: sum of mineral volumes + fluid volumes must equal 1
|
|
81
79
|
self.constraints = [{"type": "eq", "fun": self._volume_constraint}]
|
|
82
|
-
|
|
83
|
-
# Mineral log responses from Config
|
|
84
|
-
self.responses = Config.MINERALS_LOG_VALUE
|
|
85
|
-
|
|
86
|
-
# Scaling factors for different log types to balance their contribution to the error
|
|
87
|
-
self.scaling_factors = {
|
|
88
|
-
'GR': 1.0,
|
|
89
|
-
'NPHI': 300.0,
|
|
90
|
-
'RHOB': 100.0,
|
|
91
|
-
'PEF': 30.0,
|
|
92
|
-
'DTC': 1.0
|
|
93
|
-
}
|
|
80
|
+
self.scaling_factors = {}
|
|
94
81
|
|
|
95
82
|
def _volume_constraint(self, volumes: np.ndarray) -> float:
|
|
96
83
|
"""Constraint function ensuring mineral volumes + fluid volumes sum to 1."""
|
|
@@ -98,25 +85,38 @@ class MultiMineralOptimizer:
|
|
|
98
85
|
|
|
99
86
|
def _calculate_porosity(self, nphi: float, rhob: float, dtc: Optional[float] = None) -> float:
|
|
100
87
|
"""Calculate porosity using the specified method."""
|
|
101
|
-
if self.porosity_method == '
|
|
88
|
+
if self.porosity_method == 'density':
|
|
89
|
+
# Calculate an initial rho_ma based on the selected minerals
|
|
90
|
+
initial_rho_ma = sum(
|
|
91
|
+
self.responses[mineral].get('RHOB', 0) for mineral in self.minerals if mineral in self.responses
|
|
92
|
+
)
|
|
93
|
+
count_minerals_with_density = sum(
|
|
94
|
+
1 for mineral in self.minerals if mineral in self.responses and 'RHOB' in self.responses[mineral]
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
if count_minerals_with_density > 0:
|
|
98
|
+
rho_ma = initial_rho_ma / count_minerals_with_density
|
|
99
|
+
else:
|
|
100
|
+
rho_ma = 2.65 # Default matrix density (Quartz)
|
|
101
|
+
|
|
102
|
+
# Calculate average fluid density for porosity calculation
|
|
103
|
+
rho_fluid_avg = np.mean([prop['density'] for prop in self.fluid_properties.values()])
|
|
104
|
+
|
|
105
|
+
return density_porosity(rhob, rho_ma, rho_fluid_avg)
|
|
106
|
+
|
|
107
|
+
elif self.porosity_method == 'neutron_density':
|
|
102
108
|
# Use neutron-density crossplot porosity
|
|
103
|
-
|
|
109
|
+
dry_min1_point = self.porosity_endpoints.get('dry_min1_point', (-0.02, 2.65))
|
|
104
110
|
dry_clay_point = self.porosity_endpoints.get('dry_clay_point', (0.37, 2.41))
|
|
105
111
|
fluid_point = self.porosity_endpoints.get('fluid_point', (1.0, 1.0))
|
|
106
112
|
|
|
107
113
|
return neu_den_xplot_poro_pt(
|
|
108
114
|
nphi, rhob, model='ss',
|
|
109
|
-
dry_min1_point=
|
|
115
|
+
dry_min1_point=dry_min1_point,
|
|
110
116
|
dry_clay_point=dry_clay_point,
|
|
111
117
|
fluid_point=fluid_point,
|
|
112
118
|
)
|
|
113
119
|
|
|
114
|
-
elif self.porosity_method == 'density':
|
|
115
|
-
# Calculate matrix density from mineral volumes (will be updated during optimization)
|
|
116
|
-
# For now, use a default matrix density
|
|
117
|
-
rho_ma = 2.65 # Default matrix density
|
|
118
|
-
return density_porosity(rhob, rho_ma, self.rho_fluid)
|
|
119
|
-
|
|
120
120
|
elif self.porosity_method == 'sonic':
|
|
121
121
|
# Sonic porosity calculation (simplified)
|
|
122
122
|
if dtc is None:
|
|
@@ -128,14 +128,25 @@ class MultiMineralOptimizer:
|
|
|
128
128
|
else:
|
|
129
129
|
raise ValueError(f"Unknown porosity method: {self.porosity_method}")
|
|
130
130
|
|
|
131
|
-
def _calculate_matrix_density(self,
|
|
131
|
+
def _calculate_matrix_density(self, mineral_volumes: np.ndarray) -> float:
|
|
132
132
|
"""Calculate matrix density from mineral volumes."""
|
|
133
133
|
rho_ma = 0.0
|
|
134
|
+
total_mineral_vol = np.sum(mineral_volumes)
|
|
135
|
+
if total_mineral_vol < 1e-6:
|
|
136
|
+
return 2.65 # Return default if no minerals
|
|
137
|
+
|
|
134
138
|
for i, mineral in enumerate(self.minerals):
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return rho_ma
|
|
139
|
+
if mineral in self.responses and 'RHOB' in self.responses[mineral]:
|
|
140
|
+
rho_ma += mineral_volumes[i] * self.responses[mineral]['RHOB']
|
|
141
|
+
|
|
142
|
+
return rho_ma / total_mineral_vol
|
|
143
|
+
|
|
144
|
+
def _calculate_fluid_density(self, fluid_volumes: np.ndarray) -> float:
|
|
145
|
+
"""Calculate average fluid density from fluid volumes."""
|
|
146
|
+
rho_fluid = 0.0
|
|
147
|
+
for i, fluid in enumerate(self.fluids):
|
|
148
|
+
rho_fluid += fluid_volumes[i] * self.fluid_properties[fluid]['density']
|
|
149
|
+
return rho_fluid
|
|
139
150
|
|
|
140
151
|
def _calculate_log_response(self, volumes: np.ndarray, log_type: str) -> float:
|
|
141
152
|
"""Calculate reconstructed log response for a given log type."""
|
|
@@ -144,9 +155,8 @@ class MultiMineralOptimizer:
|
|
|
144
155
|
# Add mineral contributions
|
|
145
156
|
n_minerals = len(self.minerals)
|
|
146
157
|
for i, mineral in enumerate(self.minerals):
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
response += volumes[i] * self.responses[response_key]
|
|
158
|
+
if mineral in self.responses and log_type in self.responses[mineral]:
|
|
159
|
+
response += volumes[i] * self.responses[mineral][log_type]
|
|
150
160
|
|
|
151
161
|
# Add fluid contributions
|
|
152
162
|
for i, fluid in enumerate(self.fluids):
|
|
@@ -203,14 +213,26 @@ class MultiMineralOptimizer:
|
|
|
203
213
|
|
|
204
214
|
for log_type, measured_value in log_values.items():
|
|
205
215
|
if measured_value is not None and not np.isnan(measured_value):
|
|
206
|
-
|
|
216
|
+
# Special handling for RHOB when using density porosity method
|
|
217
|
+
if self.porosity_method == 'density' and log_type == 'RHOB':
|
|
218
|
+
mineral_vols = volumes[:len(self.minerals)]
|
|
219
|
+
fluid_vols = volumes[len(self.minerals):]
|
|
220
|
+
porosity = np.sum(fluid_vols)
|
|
221
|
+
|
|
222
|
+
# For density porosity, RHOB is reconstructed from porosity and matrix density
|
|
223
|
+
rho_ma = self._calculate_matrix_density(mineral_vols)
|
|
224
|
+
rho_fluid = self._calculate_fluid_density(fluid_vols)
|
|
225
|
+
reconstructed_value = rho_ma * (1 - porosity) + rho_fluid * porosity
|
|
226
|
+
else:
|
|
227
|
+
reconstructed_value = self._calculate_log_response(volumes, log_type)
|
|
228
|
+
|
|
207
229
|
scaling = self.scaling_factors.get(log_type, 1.0)
|
|
208
230
|
error = (scaling * (measured_value - reconstructed_value)) ** 2
|
|
209
231
|
total_error += error
|
|
210
232
|
|
|
211
233
|
return total_error
|
|
212
234
|
|
|
213
|
-
def _optimize_volumes(self, log_values: Dict[str, float]) -> Tuple[np.ndarray, np.ndarray]:
|
|
235
|
+
def _optimize_volumes(self, log_values: Dict[str, float]) -> Tuple[np.ndarray, np.ndarray, bool]:
|
|
214
236
|
"""
|
|
215
237
|
Optimize mineral and fluid volumes given available log measurements.
|
|
216
238
|
|
|
@@ -218,7 +240,7 @@ class MultiMineralOptimizer:
|
|
|
218
240
|
log_values: Dictionary of measured log values
|
|
219
241
|
|
|
220
242
|
Returns:
|
|
221
|
-
Tuple of (optimized mineral volumes, fluid volumes)
|
|
243
|
+
Tuple of (optimized mineral volumes, fluid volumes, success_flag)
|
|
222
244
|
"""
|
|
223
245
|
# Filter out None and NaN values
|
|
224
246
|
valid_logs = {k: v for k, v in log_values.items()
|
|
@@ -234,14 +256,12 @@ class MultiMineralOptimizer:
|
|
|
234
256
|
|
|
235
257
|
if nphi is not None and rhob is not None:
|
|
236
258
|
initial_porosity = self._calculate_porosity(nphi, rhob, dtc)
|
|
237
|
-
initial_porosity = max(0.0, min(0.
|
|
259
|
+
initial_porosity = max(0.0, min(0.4, initial_porosity)) # Constrain to reasonable range
|
|
238
260
|
else:
|
|
239
261
|
initial_porosity = 0.1 # Default porosity
|
|
240
262
|
|
|
241
|
-
# Initial guess: equal distribution among minerals and fluids
|
|
242
263
|
n_minerals = len(self.minerals)
|
|
243
264
|
n_fluids = len(self.fluids)
|
|
244
|
-
|
|
245
265
|
# Distribute volume between minerals and fluids
|
|
246
266
|
mineral_volume = (1.0 - initial_porosity) / n_minerals
|
|
247
267
|
fluid_volume = initial_porosity / n_fluids
|
|
@@ -265,10 +285,10 @@ class MultiMineralOptimizer:
|
|
|
265
285
|
mineral_volumes = result.x[:n_minerals]
|
|
266
286
|
fluid_volumes = result.x[n_minerals:]
|
|
267
287
|
|
|
268
|
-
return mineral_volumes, fluid_volumes
|
|
288
|
+
return mineral_volumes, fluid_volumes, result.success
|
|
269
289
|
|
|
270
290
|
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:
|
|
291
|
+
dtc: Optional[np.ndarray] = None, auto_scale: bool = True) -> pd.DataFrame:
|
|
272
292
|
"""
|
|
273
293
|
Estimate mineral and fluid volumes using available log measurements.
|
|
274
294
|
|
|
@@ -278,6 +298,7 @@ class MultiMineralOptimizer:
|
|
|
278
298
|
rhob: Bulk Density log in g/cc
|
|
279
299
|
pef: Photoelectric Factor log in barns/electron (optional)
|
|
280
300
|
dtc: Compressional slowness log in us/ft (optional)
|
|
301
|
+
auto_scale: If True, automatically calculate scaling factors based on log ranges.
|
|
281
302
|
|
|
282
303
|
Returns:
|
|
283
304
|
DataFrame containing:
|
|
@@ -285,6 +306,7 @@ class MultiMineralOptimizer:
|
|
|
285
306
|
- Fluid volume fractions for each fluid in self.fluids
|
|
286
307
|
- PHIT_CONSTRUCTED: Total porosity (sum of fluid volumes)
|
|
287
308
|
- AVERAGE_ERROR: Average error between measured and reconstructed logs
|
|
309
|
+
- OPTIMIZER_SUCCESS: Boolean flag indicating if the optimization was successful.
|
|
288
310
|
- *_RECONSTRUCTED: Reconstructed log values for each log type
|
|
289
311
|
"""
|
|
290
312
|
# Initialize output arrays
|
|
@@ -313,6 +335,26 @@ class MultiMineralOptimizer:
|
|
|
313
335
|
# Initialize error array
|
|
314
336
|
average_errors = np.full(n_samples, np.nan)
|
|
315
337
|
|
|
338
|
+
# Initialize QC flags
|
|
339
|
+
success_flags = np.full(n_samples, False, dtype=bool)
|
|
340
|
+
|
|
341
|
+
# Dynamic scaling based on log ranges for robustness
|
|
342
|
+
if auto_scale:
|
|
343
|
+
all_logs = {'GR': gr, 'NPHI': nphi, 'RHOB': rhob, 'PEF': pef, 'DTC': dtc}
|
|
344
|
+
for log_type, log_data in all_logs.items():
|
|
345
|
+
if log_data is not None:
|
|
346
|
+
# Use 5th and 95th percentiles to calculate a robust range, ignoring NaNs
|
|
347
|
+
valid_data = log_data[~np.isnan(log_data)]
|
|
348
|
+
if len(valid_data) > 1:
|
|
349
|
+
p05 = np.percentile(valid_data, 5)
|
|
350
|
+
p95 = np.percentile(valid_data, 95)
|
|
351
|
+
log_range = p95 - p05
|
|
352
|
+
if log_range > 1e-6: # Avoid division by zero for flat logs
|
|
353
|
+
self.scaling_factors[log_type] = round(1.0 / log_range, 4)
|
|
354
|
+
else:
|
|
355
|
+
self.scaling_factors[log_type] = 1.0 # Default if range is zero
|
|
356
|
+
|
|
357
|
+
logger.info(f"Scaling factors: {self.scaling_factors}")
|
|
316
358
|
# Process each depth point
|
|
317
359
|
for i in tqdm(range(n_samples), desc="Processing depth points", unit="points"):
|
|
318
360
|
# Prepare log values for current depth
|
|
@@ -331,7 +373,7 @@ class MultiMineralOptimizer:
|
|
|
331
373
|
if len(valid_measurements) >= 3: # Need at least 3 measurements
|
|
332
374
|
try:
|
|
333
375
|
# Optimize mineral and fluid volumes
|
|
334
|
-
mineral_vols, fluid_vols = self._optimize_volumes(log_values)
|
|
376
|
+
mineral_vols, fluid_vols, success = self._optimize_volumes(log_values)
|
|
335
377
|
|
|
336
378
|
# Store results for each mineral
|
|
337
379
|
for j, mineral in enumerate(self.minerals):
|
|
@@ -343,6 +385,7 @@ class MultiMineralOptimizer:
|
|
|
343
385
|
|
|
344
386
|
# Store total porosity (sum of fluid volumes)
|
|
345
387
|
porosity_constructed[i] = np.sum(fluid_vols)
|
|
388
|
+
success_flags[i] = success
|
|
346
389
|
|
|
347
390
|
# Combine volumes for error calculation and log reconstruction
|
|
348
391
|
combined_volumes = np.concatenate([mineral_vols, fluid_vols])
|
|
@@ -363,23 +406,15 @@ class MultiMineralOptimizer:
|
|
|
363
406
|
combined_volumes, 'DTC') if log_values['DTC'] is not None else np.nan
|
|
364
407
|
|
|
365
408
|
except Exception as e:
|
|
366
|
-
|
|
409
|
+
tqdm.write(f'\rError at depth {i}: {e}', end='\r')
|
|
367
410
|
continue
|
|
368
|
-
else:
|
|
369
|
-
logger.error(f'\rInsufficient data at depth {i}')
|
|
370
411
|
|
|
371
412
|
# Create output DataFrame
|
|
372
413
|
output_data = {}
|
|
373
414
|
|
|
374
415
|
# Add mineral volumes with appropriate column names
|
|
375
416
|
mineral_column_mapping = {
|
|
376
|
-
|
|
377
|
-
'CALCITE': 'VCALC',
|
|
378
|
-
'DOLOMITE': 'VDOLO',
|
|
379
|
-
'SHALE': 'VCLAY',
|
|
380
|
-
'ANHYDRITE': 'VANHY',
|
|
381
|
-
'GYPSUM': 'VGYPS',
|
|
382
|
-
'HALITE': 'VHALI'
|
|
417
|
+
mineral: Config.MINERALS_NAME_MAPPING.get(mineral, f'V{mineral}') for mineral in self.minerals
|
|
383
418
|
}
|
|
384
419
|
|
|
385
420
|
for mineral in self.minerals:
|
|
@@ -403,6 +438,7 @@ class MultiMineralOptimizer:
|
|
|
403
438
|
# Add error and reconstructed logs
|
|
404
439
|
output_data.update({
|
|
405
440
|
'AVG_ERROR': average_errors,
|
|
441
|
+
'OPTIMIZER_SUCCESS': success_flags,
|
|
406
442
|
'GR_RECONSTRUCTED': gr_reconstructed,
|
|
407
443
|
'NPHI_RECONSTRUCTED': nphi_reconstructed,
|
|
408
444
|
'RHOB_RECONSTRUCTED': rhob_reconstructed,
|
|
@@ -411,47 +447,3 @@ class MultiMineralOptimizer:
|
|
|
411
447
|
})
|
|
412
448
|
|
|
413
449
|
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
|
),
|
|
@@ -23,6 +23,47 @@ def normalize_volumetric(phit, **volumetrics):
|
|
|
23
23
|
return normalized_volumetrics
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
def unnormalize_volumetric(phit, **normalized_volumetrics):
|
|
27
|
+
"""Unnormalize lithology given total porosity.
|
|
28
|
+
|
|
29
|
+
This is the reverse of normalize_volumetric. It calculates the matrix-relative
|
|
30
|
+
volumetrics from bulk-relative (normalized) volumetrics.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
phit (np.ndarray or float): Total porosity in fraction (v/v).
|
|
34
|
+
**normalized_volumetrics: Keyword arguments representing normalized
|
|
35
|
+
volumetric fractions of the bulk volume (v/v).
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
dict: Unnormalized volumetric fractions relative to the matrix volume.
|
|
39
|
+
"""
|
|
40
|
+
logger.debug("Unnormalizing volumetrics with total porosity")
|
|
41
|
+
# Unnormalize the volumetrics
|
|
42
|
+
vmatrix = 1 - phit
|
|
43
|
+
# Use np.divide for safe division by zero, returning np.nan
|
|
44
|
+
unnormalized_volumetrics = {key: np.divide(value, vmatrix, out=np.full_like(value, np.nan), where=vmatrix != 0)
|
|
45
|
+
for key, value in normalized_volumetrics.items()}
|
|
46
|
+
logger.debug(f"Unnormalized volumetrics: {list(unnormalized_volumetrics.keys())}")
|
|
47
|
+
return unnormalized_volumetrics
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def get_volumetric_dict(df):
|
|
51
|
+
"""Given dataframe, return a dictionary of the key and values of lithology metrics in the data.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
df (pd.DataFrame): Dataframe with well log data.
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
dict: Dictionary of the key and values of lithology metrics in the data.
|
|
58
|
+
"""
|
|
59
|
+
volumetric_dict = {}
|
|
60
|
+
for vol_log in Config.MINERALS_LOG_VALUE.keys():
|
|
61
|
+
vol_log = Config.MINERALS_NAME_MAPPING.get(vol_log, vol_log)
|
|
62
|
+
if vol_log in df.columns:
|
|
63
|
+
volumetric_dict[vol_log.lower()] = df[vol_log].values
|
|
64
|
+
return volumetric_dict
|
|
65
|
+
|
|
66
|
+
|
|
26
67
|
def effective_porosity(phit, phi_shale, vshale):
|
|
27
68
|
"""
|
|
28
69
|
Computes effective porosity from total porosity, total porosity of shale and shale volume.
|
|
@@ -81,42 +122,36 @@ def estimate_shale_porosity(nphi, phit):
|
|
|
81
122
|
return np.where(phit_sh > 0, phit_sh, phit).clip(1e-2, 1.0)
|
|
82
123
|
|
|
83
124
|
|
|
84
|
-
def rho_matrix(
|
|
85
|
-
|
|
86
|
-
rho_calc: float = 0, rho_dolo: float = 0, rho_heavy: float = 0):
|
|
87
|
-
"""Estimate average matrix density based on dry sand, dry silt, dry clay, dry calcite and
|
|
88
|
-
dry dolomite volume and density of each.
|
|
125
|
+
def rho_matrix(**volumetrics):
|
|
126
|
+
"""Estimate average matrix density based on mineral volumes and their densities from Config.
|
|
89
127
|
|
|
90
128
|
Args:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
vcalc (float): Volume of calcite.
|
|
95
|
-
vdolo (float): Volume of dolomite.
|
|
96
|
-
vheavy (float): Volume of heavy minerals.
|
|
97
|
-
rho_sand (float, optional): Density of sand in g/cc. Defaults to None.
|
|
98
|
-
rho_silt (float, optional): Density of silt in g/cc. Defaults to None.
|
|
99
|
-
rho_clay (float, optional): Density of clay in g/cc. Defaults to None.
|
|
100
|
-
rho_calc (float, optional): Density of calcite in g/cc. Defaults to None.
|
|
101
|
-
rho_dolo (float, optional): Density of dolomite in g/cc. Defaults to None.
|
|
102
|
-
rho_heavy (float, optional): Density of heavy minerals in g/cc. Defaults to 0.
|
|
129
|
+
**volumetrics: Keyword arguments where keys are mineral volume names
|
|
130
|
+
(e.g., VSAND, VCLAY) and values are their volume fractions.
|
|
131
|
+
|
|
103
132
|
|
|
104
133
|
Returns:
|
|
105
134
|
float: Matrix density in g/cc.
|
|
106
135
|
"""
|
|
107
136
|
logger.debug("Calculating matrix density from mineral volumes")
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
137
|
+
rho_ma = 0.0
|
|
138
|
+
mineral_properties = Config.MINERALS_LOG_VALUE
|
|
139
|
+
# Create a reverse mapping from volume name (e.g., 'VSAND') to mineral name (e.g., 'QUARTZ')
|
|
140
|
+
name_to_mineral_map = {v: k for k, v in Config.MINERALS_NAME_MAPPING.items()}
|
|
141
|
+
|
|
142
|
+
for vol_name, vol_value in volumetrics.items():
|
|
143
|
+
# Find the mineral name (e.g., 'QUARTZ') from the volume name (e.g., 'VSAND')
|
|
144
|
+
mineral_name = name_to_mineral_map.get(vol_name.upper())
|
|
114
145
|
|
|
115
|
-
|
|
116
|
-
|
|
146
|
+
if mineral_name and mineral_name in mineral_properties:
|
|
147
|
+
rho_mineral = mineral_properties[mineral_name].get('RHOB')
|
|
148
|
+
if rho_mineral is not None:
|
|
149
|
+
rho_ma += vol_value * rho_mineral
|
|
150
|
+
elif vol_name.upper() == 'VSILT': # Handle silt separately if not in main config
|
|
151
|
+
rho_ma += vol_value * 2.68
|
|
117
152
|
|
|
118
|
-
logger.debug(f"Matrix density range: {
|
|
119
|
-
return
|
|
153
|
+
logger.debug(f"Matrix density range: {np.nanmin(rho_ma):.3f} - {np.nanmax(rho_ma):.3f} g/cm³")
|
|
154
|
+
return rho_ma
|
|
120
155
|
|
|
121
156
|
|
|
122
157
|
def density_porosity(rhob, rho_matrix, rho_fluid: float = 1.0):
|
|
@@ -160,10 +195,10 @@ def dt_matrix(vsand=0, vclay=0, vcalc=0, vdolo=0, vheavy=0,
|
|
|
160
195
|
"""
|
|
161
196
|
logger.debug("Calculating matrix sonic transit time from mineral volumes")
|
|
162
197
|
minerals_log_value = Config.MINERALS_LOG_VALUE
|
|
163
|
-
dt_sand = dt_sand or minerals_log_value['
|
|
164
|
-
dt_clay = dt_clay or minerals_log_value['
|
|
165
|
-
dt_calc = dt_calc or minerals_log_value['
|
|
166
|
-
dt_dolo = dt_dolo or minerals_log_value['
|
|
198
|
+
dt_sand = dt_sand or minerals_log_value['QUARTZ']['DTC']
|
|
199
|
+
dt_clay = dt_clay or minerals_log_value['SHALE']['DTC']
|
|
200
|
+
dt_calc = dt_calc or minerals_log_value['CALCITE']['DTC']
|
|
201
|
+
dt_dolo = dt_dolo or minerals_log_value['DOLOMITE']['DTC']
|
|
167
202
|
|
|
168
203
|
dt_matrix = (vsand * dt_sand + vclay * dt_clay +
|
|
169
204
|
vcalc * dt_calc + vdolo * dt_dolo + vheavy * dt_heavy)
|
|
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
|