quick-pp 0.2.69__tar.gz → 0.2.71__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.69 → quick_pp-0.2.71}/PKG-INFO +3 -3
- {quick_pp-0.2.69 → quick_pp-0.2.71}/pyproject.toml +6 -5
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/__init__.py +1 -1
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/config.py +24 -72
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/core_calibration.py +77 -64
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/lithology/multi_mineral.py +65 -84
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/lithology/sand_shale.py +4 -3
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/plotter/well_log_config.py +3 -3
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/porosity.py +66 -31
- quick_pp-0.2.71/quick_pp/saturation.py +927 -0
- quick_pp-0.2.69/quick_pp/saturation.py +0 -792
- {quick_pp-0.2.69 → quick_pp-0.2.71}/.gitignore +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/LICENSE +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/README.md +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/__init__.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/exceptions.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/fastapi_mlflow/__init__.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/fastapi_mlflow/_mlflow_types.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/fastapi_mlflow/applications.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/fastapi_mlflow/exceptions.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/fastapi_mlflow/predictors.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/main.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/mlflow_model_deployment.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/router.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/schemas/lithology_hc_correction.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/schemas/lithology_ssc.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/schemas/lithology_vsh_gr.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/schemas/permeability_choo.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/schemas/permeability_others.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/schemas/porosity.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/schemas/ressum.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/schemas/saturation_archie.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/schemas/saturation_b.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/schemas/saturation_qv.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/schemas/saturation_rw.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/schemas/saturation_temp_grad.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/schemas/saturation_waxman_smits.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/services/chat.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/services/las_handler.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/services/lithology.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/services/permeability.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/services/porosity.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/services/reservoir_summary.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/services/saturation.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/static/favicon.ico +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/static/logo.png +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/template/chat.html +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/api/template/home.html +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/cli.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/database/__init__.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/database/db_connector.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/database/models.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/database/objects.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/database/setup_postgresql_db.sql +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/database/setup_sqlite_db.sql +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/fluid_type.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/las_handler.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/lithology/__init__.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/lithology/carbonate.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/lithology/sand_silt_clay.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/lithology/thin_beds.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/machine_learning/__init__.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/machine_learning/config.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/machine_learning/feature_engineering.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/machine_learning/mock_data/mock_data.parquet +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/machine_learning/predict_pipeline.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/machine_learning/train_pipeline.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/machine_learning/utils.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/permeability.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/plotter/__init__.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/plotter/plotter.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/plotter/well_log.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/qaqc.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/ressum.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/rock_physics/__init__.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/rock_physics/geomechanics.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/rock_physics/geophysics.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/rock_physics/rpm.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/rock_type.py +0 -0
- {quick_pp-0.2.69 → quick_pp-0.2.71}/quick_pp/utils.py +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quick-pp
|
|
3
|
-
Version: 0.2.
|
|
4
|
-
Summary: Python package to assist in providing quick-look
|
|
3
|
+
Version: 0.2.71
|
|
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>
|
|
7
7
|
License-Expression: MIT
|
|
8
8
|
License-File: LICENSE
|
|
9
|
-
Keywords:
|
|
9
|
+
Keywords: geoscience,multi mineral,petrophysics,quick_pp,rock typing,saturation height function,shf,well log,well plot
|
|
10
10
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
12
12
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "quick-pp"
|
|
7
|
-
version = "0.2.
|
|
8
|
-
description = "Python package to assist in providing quick-look
|
|
7
|
+
version = "0.2.71"
|
|
8
|
+
description = "Python package to assist in providing quick-look preliminary petrophysical estimation."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
11
11
|
requires-python = ">=3.11"
|
|
@@ -13,12 +13,13 @@ authors = [
|
|
|
13
13
|
{ name = "Imran Fadhil", email = "imranfadhil@gmail.com" },
|
|
14
14
|
]
|
|
15
15
|
keywords = [
|
|
16
|
-
"analysis",
|
|
17
16
|
"geoscience",
|
|
18
|
-
"log",
|
|
19
17
|
"petrophysics",
|
|
18
|
+
"well log", "well plot",
|
|
20
19
|
"quick_pp",
|
|
21
|
-
"
|
|
20
|
+
"multi mineral",
|
|
21
|
+
"rock typing",
|
|
22
|
+
"saturation height function", "shf",
|
|
22
23
|
]
|
|
23
24
|
classifiers = [
|
|
24
25
|
"Development Status :: 2 - Pre-Alpha",
|
|
@@ -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.71' # Need to be updated manually when releasing a new version/ change in pyproject.toml
|
|
@@ -57,79 +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
|
-
# 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,
|
|
98
|
-
|
|
99
|
-
# Anhydrite
|
|
100
|
-
'GR_ANHYDRITE': 0.0,
|
|
101
|
-
'NPHI_ANHYDRITE': -0.02,
|
|
102
|
-
'RHOB_ANHYDRITE': 2.98,
|
|
103
|
-
'DTC_ANHYDRITE': 50.0,
|
|
104
|
-
'PEF_ANHYDRITE': 5.1,
|
|
105
|
-
|
|
106
|
-
# Gypsum
|
|
107
|
-
'GR_GYPSUM': 0.0,
|
|
108
|
-
'NPHI_GYPSUM': 0.6,
|
|
109
|
-
'RHOB_GYPSUM': 2.35,
|
|
110
|
-
'DTC_GYPSUM': 52.0,
|
|
111
|
-
'PEF_GYPSUM': 4.0,
|
|
112
|
-
|
|
113
|
-
# Halite
|
|
114
|
-
'GR_HALITE': 0.0,
|
|
115
|
-
'NPHI_HALITE': -0.03,
|
|
116
|
-
'RHOB_HALITE': 2.04,
|
|
117
|
-
'DTC_HALITE': 67.0,
|
|
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,
|
|
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
|
+
}
|
|
126
72
|
|
|
127
|
-
|
|
128
|
-
'
|
|
129
|
-
'
|
|
130
|
-
'
|
|
131
|
-
'
|
|
132
|
-
'
|
|
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'
|
|
133
85
|
}
|
|
134
86
|
|
|
135
87
|
GEOMECHANICS_VALUE = dict(
|
|
@@ -438,18 +438,20 @@ def autocorrelate_core_depth(df):
|
|
|
438
438
|
and 'DEPTH_SHIFT'.
|
|
439
439
|
"""
|
|
440
440
|
from dtw import dtw
|
|
441
|
+
from sklearn.preprocessing import minmax_scale
|
|
441
442
|
required_cols = ['WELL_NAME', 'DEPTH', 'PHIT', 'CPORE', 'CPERM', 'CORE_ID']
|
|
442
443
|
for col in required_cols:
|
|
443
444
|
if col not in df.columns:
|
|
444
445
|
raise AssertionError(f"Missing required column: {col}")
|
|
445
446
|
|
|
447
|
+
all_wells_data = []
|
|
446
448
|
shift_summaries = []
|
|
447
|
-
|
|
449
|
+
|
|
448
450
|
for well, data in tqdm(df.groupby('WELL_NAME'), desc='Correlating core depths'):
|
|
449
451
|
core_data = data[['DEPTH', 'CORE_ID', 'CPORE', 'CPERM']].dropna().sort_values('DEPTH').reset_index(drop=True)
|
|
450
452
|
|
|
451
453
|
if core_data.empty:
|
|
452
|
-
|
|
454
|
+
all_wells_data.append(data)
|
|
453
455
|
continue
|
|
454
456
|
|
|
455
457
|
log_data = data[['DEPTH', 'PHIT']].dropna().sort_values('DEPTH').reset_index(drop=True)
|
|
@@ -457,74 +459,85 @@ def autocorrelate_core_depth(df):
|
|
|
457
459
|
|
|
458
460
|
# Create a window of log data around core points to speed up DTW
|
|
459
461
|
core_indices_in_log = np.searchsorted(log_data.DEPTH, core_data.DEPTH, side='left')
|
|
460
|
-
window =
|
|
462
|
+
window = 50 # Increased window size to allow for larger shifts
|
|
461
463
|
window_indices = core_indices_in_log[:, None] + np.arange(-window, window + 1)
|
|
462
464
|
window_indices = np.clip(window_indices, 0, len(log_data) - 1)
|
|
463
465
|
unique_indices = np.unique(window_indices.flatten())
|
|
464
466
|
log_data_subset = log_data.iloc[unique_indices].reset_index(drop=True)
|
|
465
467
|
|
|
466
|
-
# Extract
|
|
467
|
-
phit_vals = log_data_subset['PHIT'].values
|
|
468
|
-
cpore_vals = core_data['CPORE'].values
|
|
469
|
-
|
|
470
|
-
alignment = dtw(cpore_vals, phit_vals,
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
#
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
468
|
+
# Extract numpy arrays for DTW
|
|
469
|
+
phit_vals = minmax_scale(log_data_subset['PHIT'].values)
|
|
470
|
+
cpore_vals = minmax_scale(core_data['CPORE'].values)
|
|
471
|
+
|
|
472
|
+
alignment = dtw(cpore_vals, phit_vals, keep_internals=True, step_pattern="symmetric2")
|
|
473
|
+
|
|
474
|
+
# Map alignment indices back to original data
|
|
475
|
+
core_indices = alignment.index1
|
|
476
|
+
log_subset_indices = alignment.index2
|
|
477
|
+
|
|
478
|
+
original_depths = core_data.loc[core_indices, 'DEPTH'].values
|
|
479
|
+
corrected_depths = log_data_subset.loc[log_subset_indices, 'DEPTH'].values
|
|
480
|
+
|
|
481
|
+
# Calculate the shift for each point in the DTW path
|
|
482
|
+
depth_shifts = corrected_depths - original_depths
|
|
483
|
+
|
|
484
|
+
# Determine the single best shift for the entire core sequence (using the median for robustness)
|
|
485
|
+
if len(depth_shifts) > 0:
|
|
486
|
+
best_shift = round(np.median(depth_shifts), 4)
|
|
487
|
+
else:
|
|
488
|
+
best_shift = 0.0
|
|
489
|
+
|
|
490
|
+
tqdm.write(f"Determined best shift for {well}: {best_shift:.2f}")
|
|
491
|
+
|
|
492
|
+
# Apply the consistent shift to all original core data for this well
|
|
493
|
+
shifted_core_data = core_data.copy()
|
|
494
|
+
shifted_core_data['DEPTH_CORRECTED'] = shifted_core_data['DEPTH'] + best_shift
|
|
495
|
+
shifted_core_data['DEPTH_SHIFT'] = best_shift
|
|
496
|
+
|
|
497
|
+
# Create summary for this well
|
|
498
|
+
summary = shifted_core_data[['CORE_ID', 'DEPTH', 'DEPTH_CORRECTED', 'DEPTH_SHIFT']].copy()
|
|
499
|
+
summary.rename(columns={'DEPTH': 'ORIGINAL_DEPTH'}, inplace=True)
|
|
500
|
+
summary['WELL_NAME'] = well
|
|
501
|
+
summary = summary[['WELL_NAME', 'CORE_ID', 'ORIGINAL_DEPTH', 'DEPTH_CORRECTED', 'DEPTH_SHIFT']]
|
|
502
|
+
shift_summaries.append(summary)
|
|
503
|
+
|
|
504
|
+
# Prepare shifted data for merging
|
|
505
|
+
final_shifted = shifted_core_data.rename(columns={
|
|
506
|
+
'CPORE': 'CPORE_SHIFTED',
|
|
507
|
+
'CPERM': 'CPERM_SHIFTED',
|
|
508
|
+
'CORE_ID': 'CORE_ID_SHIFTED'
|
|
487
509
|
})
|
|
488
510
|
|
|
489
|
-
#
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
df_corrected.loc[mask_ori, ['CORE_ID', 'CPORE', 'CPERM']] = df_corrected.loc[
|
|
521
|
-
mask_ori, ['CORE_ID_SHIFTED', 'CPORE_SHIFTED', 'CPERM_SHIFTED']].values
|
|
522
|
-
|
|
523
|
-
return_df = pd.concat([return_df, df_corrected])
|
|
524
|
-
|
|
525
|
-
# After the loop, combine all summaries into a single DataFrame
|
|
526
|
-
final_summary_df = pd.DataFrame()
|
|
527
|
-
if shift_summaries:
|
|
528
|
-
final_summary_df = pd.concat(shift_summaries, ignore_index=True)
|
|
511
|
+
# --- SOLUTION: Use index-based merging to avoid column conflicts ---
|
|
512
|
+
|
|
513
|
+
# Prepare the log data: keep only necessary columns and set DEPTH as index
|
|
514
|
+
log_df_to_merge = data.set_index('DEPTH')
|
|
515
|
+
|
|
516
|
+
# Prepare the shifted core data: keep shifted values and set corrected depth as index
|
|
517
|
+
core_df_to_merge = final_shifted[['DEPTH_CORRECTED', 'CPORE_SHIFTED', 'CPERM_SHIFTED', 'CORE_ID_SHIFTED']] \
|
|
518
|
+
.set_index('DEPTH_CORRECTED')
|
|
519
|
+
|
|
520
|
+
# Merge the two dataframes on their indices (which are the depths)
|
|
521
|
+
well_corrected_df = pd.merge(
|
|
522
|
+
log_df_to_merge,
|
|
523
|
+
core_df_to_merge,
|
|
524
|
+
left_index=True,
|
|
525
|
+
right_index=True,
|
|
526
|
+
how='outer'
|
|
527
|
+
).reset_index()
|
|
528
|
+
|
|
529
|
+
# The merged 'index' column is the unified depth column, so rename it
|
|
530
|
+
well_corrected_df.rename(columns={'index': 'DEPTH'}, inplace=True)
|
|
531
|
+
|
|
532
|
+
# Sort by the final unified depth
|
|
533
|
+
well_corrected_df.sort_values('DEPTH', inplace=True)
|
|
534
|
+
|
|
535
|
+
# Add well name back if lost during merge
|
|
536
|
+
well_corrected_df['WELL_NAME'] = well
|
|
537
|
+
all_wells_data.append(well_corrected_df)
|
|
538
|
+
|
|
539
|
+
# Combine all processed well data and summaries
|
|
540
|
+
return_df = pd.concat(all_wells_data, ignore_index=True)
|
|
541
|
+
final_summary_df = pd.concat(shift_summaries, ignore_index=True) if shift_summaries else pd.DataFrame()
|
|
529
542
|
|
|
530
543
|
return return_df, final_summary_df
|
|
@@ -14,16 +14,15 @@ class MultiMineral:
|
|
|
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
|
|
26
|
-
'GYPSUM', 'HALITE', 'PYRITE', 'FELDSPAR', 'COAL'
|
|
24
|
+
If None, uses default minerals: ['QUARTZ', 'CALCITE', 'DOLOMITE', 'SHALE'].
|
|
25
|
+
Available minerals are dynamically loaded from `Config.MINERALS_LOG_VALUE`.
|
|
27
26
|
fluid_properties: Dictionary containing fluid properties for oil, gas, and water.
|
|
28
27
|
If None, uses default properties:
|
|
29
28
|
{
|
|
@@ -34,10 +33,17 @@ class MultiMineral:
|
|
|
34
33
|
porosity_method: Method for calculating porosity ('neutron_density', 'density', 'sonic')
|
|
35
34
|
porosity_endpoints: Endpoints for porosity calculation (for neutron_density method)
|
|
36
35
|
"""
|
|
36
|
+
self.responses = Config.MINERALS_LOG_VALUE
|
|
37
|
+
available_minerals = list(self.responses.keys())
|
|
38
|
+
|
|
37
39
|
# Default minerals if none specified
|
|
38
40
|
if minerals is None:
|
|
39
41
|
minerals = ['QUARTZ', 'CALCITE', 'DOLOMITE', 'SHALE']
|
|
40
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.")
|
|
46
|
+
|
|
41
47
|
self.minerals = minerals
|
|
42
48
|
self.porosity_method = porosity_method
|
|
43
49
|
self.porosity_endpoints = porosity_endpoints or {}
|
|
@@ -49,25 +55,11 @@ class MultiMineral:
|
|
|
49
55
|
'GAS': {'density': 0.2, 'nphi': 0.0, 'pef': 0.0, 'dtc': 400.0},
|
|
50
56
|
'WATER': {'density': 1.0, 'nphi': 1.0, 'pef': 0.0, 'dtc': 190.0}
|
|
51
57
|
}
|
|
52
|
-
|
|
53
58
|
self.fluid_properties = fluid_properties
|
|
54
|
-
self.rho_fluid = self.fluid_properties['WATER']['density'] # Assume water for fluid density
|
|
55
59
|
self.fluids = ['OIL', 'GAS', 'WATER']
|
|
56
60
|
|
|
57
61
|
# Define bounds for each mineral type
|
|
58
|
-
mineral_bounds = {
|
|
59
|
-
'QUARTZ': (0, 1),
|
|
60
|
-
'CALCITE': (0, 1),
|
|
61
|
-
'DOLOMITE': (0, 1),
|
|
62
|
-
'SHALE': (0, 1),
|
|
63
|
-
'KAOLINITE': (0, 1),
|
|
64
|
-
'FELDSPAR': (0, 1),
|
|
65
|
-
'ANHYDRITE': (0, 1),
|
|
66
|
-
'GYPSUM': (0, 1),
|
|
67
|
-
'HALITE': (0, 1),
|
|
68
|
-
'PYRITE': (0, 1),
|
|
69
|
-
'COAL': (0, 1)
|
|
70
|
-
}
|
|
62
|
+
mineral_bounds = {mineral: (0, 1) for mineral in available_minerals}
|
|
71
63
|
|
|
72
64
|
# Define bounds for fluid volumes (0 to 1 for each fluid)
|
|
73
65
|
fluid_bounds = {
|
|
@@ -85,52 +77,46 @@ class MultiMineral:
|
|
|
85
77
|
|
|
86
78
|
# Constraint: sum of mineral volumes + fluid volumes must equal 1
|
|
87
79
|
self.constraints = [{"type": "eq", "fun": self._volume_constraint}]
|
|
88
|
-
|
|
89
|
-
# Mineral log responses from Config
|
|
90
|
-
self.responses = Config.MINERALS_LOG_VALUE
|
|
91
|
-
|
|
92
|
-
# Scaling factors for different log types to balance their contribution to the error
|
|
93
|
-
self.scaling_factors = {
|
|
94
|
-
'GR': 1.0,
|
|
95
|
-
'NPHI': 300.0,
|
|
96
|
-
'RHOB': 100.0,
|
|
97
|
-
'PEF': 30.0,
|
|
98
|
-
'DTC': 1.0
|
|
99
|
-
}
|
|
80
|
+
self.scaling_factors = {}
|
|
100
81
|
|
|
101
82
|
def _volume_constraint(self, volumes: np.ndarray) -> float:
|
|
102
83
|
"""Constraint function ensuring mineral volumes + fluid volumes sum to 1."""
|
|
103
84
|
return np.sum(volumes) - 1
|
|
104
85
|
|
|
105
|
-
def _calculate_porosity(self, nphi: float, rhob: float, dtc: Optional[float] = None
|
|
106
|
-
volumes: Optional[np.ndarray] = None) -> float:
|
|
86
|
+
def _calculate_porosity(self, nphi: float, rhob: float, dtc: Optional[float] = None) -> float:
|
|
107
87
|
"""Calculate porosity using the specified method."""
|
|
108
|
-
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':
|
|
109
108
|
# Use neutron-density crossplot porosity
|
|
110
|
-
|
|
109
|
+
dry_min1_point = self.porosity_endpoints.get('dry_min1_point', (-0.02, 2.65))
|
|
111
110
|
dry_clay_point = self.porosity_endpoints.get('dry_clay_point', (0.37, 2.41))
|
|
112
111
|
fluid_point = self.porosity_endpoints.get('fluid_point', (1.0, 1.0))
|
|
113
112
|
|
|
114
113
|
return neu_den_xplot_poro_pt(
|
|
115
114
|
nphi, rhob, model='ss',
|
|
116
|
-
dry_min1_point=
|
|
115
|
+
dry_min1_point=dry_min1_point,
|
|
117
116
|
dry_clay_point=dry_clay_point,
|
|
118
117
|
fluid_point=fluid_point,
|
|
119
118
|
)
|
|
120
119
|
|
|
121
|
-
elif self.porosity_method == 'density':
|
|
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
|
|
132
|
-
return density_porosity(rhob, rho_ma, self.rho_fluid)
|
|
133
|
-
|
|
134
120
|
elif self.porosity_method == 'sonic':
|
|
135
121
|
# Sonic porosity calculation (simplified)
|
|
136
122
|
if dtc is None:
|
|
@@ -142,14 +128,25 @@ class MultiMineral:
|
|
|
142
128
|
else:
|
|
143
129
|
raise ValueError(f"Unknown porosity method: {self.porosity_method}")
|
|
144
130
|
|
|
145
|
-
def _calculate_matrix_density(self,
|
|
131
|
+
def _calculate_matrix_density(self, mineral_volumes: np.ndarray) -> float:
|
|
146
132
|
"""Calculate matrix density from mineral volumes."""
|
|
147
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
|
+
|
|
148
138
|
for i, mineral in enumerate(self.minerals):
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
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
|
|
153
150
|
|
|
154
151
|
def _calculate_log_response(self, volumes: np.ndarray, log_type: str) -> float:
|
|
155
152
|
"""Calculate reconstructed log response for a given log type."""
|
|
@@ -158,9 +155,8 @@ class MultiMineral:
|
|
|
158
155
|
# Add mineral contributions
|
|
159
156
|
n_minerals = len(self.minerals)
|
|
160
157
|
for i, mineral in enumerate(self.minerals):
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
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]
|
|
164
160
|
|
|
165
161
|
# Add fluid contributions
|
|
166
162
|
for i, fluid in enumerate(self.fluids):
|
|
@@ -215,16 +211,18 @@ class MultiMineral:
|
|
|
215
211
|
"""
|
|
216
212
|
total_error = 0.0
|
|
217
213
|
|
|
218
|
-
# Porosity is the sum of fluid volumes
|
|
219
|
-
porosity = np.sum(volumes[len(self.minerals):])
|
|
220
|
-
|
|
221
214
|
for log_type, measured_value in log_values.items():
|
|
222
215
|
if measured_value is not None and not np.isnan(measured_value):
|
|
216
|
+
# Special handling for RHOB when using density porosity method
|
|
223
217
|
if self.porosity_method == 'density' and log_type == 'RHOB':
|
|
224
|
-
# For density porosity, RHOB is reconstructed from porosity and matrix density
|
|
225
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
|
|
226
223
|
rho_ma = self._calculate_matrix_density(mineral_vols)
|
|
227
|
-
|
|
224
|
+
rho_fluid = self._calculate_fluid_density(fluid_vols)
|
|
225
|
+
reconstructed_value = rho_ma * (1 - porosity) + rho_fluid * porosity
|
|
228
226
|
else:
|
|
229
227
|
reconstructed_value = self._calculate_log_response(volumes, log_type)
|
|
230
228
|
|
|
@@ -256,21 +254,14 @@ class MultiMineral:
|
|
|
256
254
|
rhob = log_values.get('RHOB', 2.65)
|
|
257
255
|
dtc = log_values.get('DTC', None)
|
|
258
256
|
|
|
259
|
-
# Initial guess: equal distribution among minerals and fluids
|
|
260
|
-
n_minerals = len(self.minerals)
|
|
261
|
-
n_fluids = len(self.fluids)
|
|
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
257
|
if nphi is not None and rhob is not None:
|
|
269
|
-
initial_porosity = self._calculate_porosity(nphi, rhob, dtc
|
|
258
|
+
initial_porosity = self._calculate_porosity(nphi, rhob, dtc)
|
|
270
259
|
initial_porosity = max(0.0, min(0.4, initial_porosity)) # Constrain to reasonable range
|
|
271
260
|
else:
|
|
272
|
-
initial_porosity = 0.
|
|
261
|
+
initial_porosity = 0.1 # Default porosity
|
|
273
262
|
|
|
263
|
+
n_minerals = len(self.minerals)
|
|
264
|
+
n_fluids = len(self.fluids)
|
|
274
265
|
# Distribute volume between minerals and fluids
|
|
275
266
|
mineral_volume = (1.0 - initial_porosity) / n_minerals
|
|
276
267
|
fluid_volume = initial_porosity / n_fluids
|
|
@@ -423,17 +414,7 @@ class MultiMineral:
|
|
|
423
414
|
|
|
424
415
|
# Add mineral volumes with appropriate column names
|
|
425
416
|
mineral_column_mapping = {
|
|
426
|
-
|
|
427
|
-
'CALCITE': 'VCALC',
|
|
428
|
-
'DOLOMITE': 'VDOLO',
|
|
429
|
-
'SHALE': 'VCLAY',
|
|
430
|
-
'KAOLINITE': 'VKAOL',
|
|
431
|
-
'FELDSPAR': 'VFELD',
|
|
432
|
-
'ANHYDRITE': 'VANHY',
|
|
433
|
-
'GYPSUM': 'VGYPS',
|
|
434
|
-
'HALITE': 'VHALI',
|
|
435
|
-
'PYRITE': 'VPYRI',
|
|
436
|
-
'COAL': 'VCOAL'
|
|
417
|
+
mineral: Config.MINERALS_NAME_MAPPING.get(mineral, f'V{mineral}') for mineral in self.minerals
|
|
437
418
|
}
|
|
438
419
|
|
|
439
420
|
for mineral in self.minerals:
|
|
@@ -96,9 +96,10 @@ class SandShale:
|
|
|
96
96
|
for i, point in enumerate(E):
|
|
97
97
|
var_pt = line_intersection((A, C), (D, point))
|
|
98
98
|
projlithofrac = length_a_b(var_pt, A)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
sand_frac = projlithofrac / rocklithofrac
|
|
100
|
+
sand_frac = 0 if var_pt[0] > C[0] else sand_frac
|
|
101
|
+
vsand = np.append(vsand, sand_frac)
|
|
102
|
+
vcld = np.append(vcld, 1 - sand_frac)
|
|
102
103
|
|
|
103
104
|
logger.debug(f"Lithology fraction calculation completed for {len(vsand)} points")
|
|
104
105
|
return vsand, vcld
|
|
@@ -3,9 +3,9 @@ import numpy as np
|
|
|
3
3
|
|
|
4
4
|
COLOR_DICT = {
|
|
5
5
|
'BADHOLE': 'rgba(0, 0, 0, .25)',
|
|
6
|
-
'BS': '
|
|
6
|
+
'BS': 'black',
|
|
7
7
|
'BVW': "#B7EDFF",
|
|
8
|
-
'CALI': '
|
|
8
|
+
'CALI': 'brown',
|
|
9
9
|
'COAL_FLAG': '#262626',
|
|
10
10
|
'CPERM': '#FF0000',
|
|
11
11
|
'CPORE': '#FF0000',
|
|
@@ -157,7 +157,7 @@ TRACE_DEFS = dict(
|
|
|
157
157
|
hide_xaxis=False,
|
|
158
158
|
style={
|
|
159
159
|
'line_dash': 'dot', 'line_width': 1, 'line_color': COLOR_DICT['CALI'], 'fill': 'tozerox',
|
|
160
|
-
'fillcolor':
|
|
160
|
+
'fillcolor': "#FF880020"
|
|
161
161
|
}
|
|
162
162
|
),
|
|
163
163
|
BS=dict(
|