quick-pp 0.2.67__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.67 → quick_pp-0.2.69}/PKG-INFO +1 -1
- {quick_pp-0.2.67 → quick_pp-0.2.69}/pyproject.toml +1 -1
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/__init__.py +1 -1
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/config.py +34 -6
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/database/db_connector.py +2 -2
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/database/objects.py +8 -7
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/las_handler.py +134 -42
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/lithology/multi_mineral.py +81 -70
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/plotter/well_log_config.py +63 -21
- {quick_pp-0.2.67 → quick_pp-0.2.69}/.gitignore +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/LICENSE +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/README.md +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/exceptions.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/fastapi_mlflow/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/fastapi_mlflow/_mlflow_types.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/fastapi_mlflow/applications.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/fastapi_mlflow/exceptions.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/fastapi_mlflow/predictors.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/main.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/mlflow_model_deployment.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/router.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/schemas/lithology_hc_correction.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/schemas/lithology_ssc.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/schemas/lithology_vsh_gr.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/schemas/permeability_choo.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/schemas/permeability_others.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/schemas/porosity.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/schemas/ressum.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/schemas/saturation_archie.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/schemas/saturation_b.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/schemas/saturation_qv.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/schemas/saturation_rw.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/schemas/saturation_temp_grad.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/schemas/saturation_waxman_smits.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/services/chat.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/services/las_handler.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/services/lithology.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/services/permeability.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/services/porosity.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/services/reservoir_summary.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/services/saturation.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/static/favicon.ico +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/static/logo.png +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/template/chat.html +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/api/template/home.html +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/cli.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/core_calibration.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/database/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/database/models.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/database/setup_postgresql_db.sql +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/database/setup_sqlite_db.sql +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/fluid_type.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/lithology/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/lithology/carbonate.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/lithology/sand_shale.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/lithology/sand_silt_clay.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/lithology/thin_beds.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/machine_learning/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/machine_learning/config.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/machine_learning/feature_engineering.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/machine_learning/mock_data/mock_data.parquet +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/machine_learning/predict_pipeline.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/machine_learning/train_pipeline.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/machine_learning/utils.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/permeability.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/plotter/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/plotter/plotter.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/plotter/well_log.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/porosity.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/qaqc.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/ressum.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/rock_physics/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/rock_physics/geomechanics.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/rock_physics/geophysics.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/rock_physics/rpm.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/rock_type.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.69}/quick_pp/saturation.py +0 -0
- {quick_pp-0.2.67 → 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(
|
|
@@ -86,9 +86,9 @@ class DBConnector:
|
|
|
86
86
|
script_dir = os.path.dirname(__file__)
|
|
87
87
|
db_type = "sqlite" if "sqlite" in DBConnector._engine.url.drivername else "postgresql"
|
|
88
88
|
if db_type == "sqlite":
|
|
89
|
-
sql_script = "
|
|
89
|
+
sql_script = "setup_sqlite_db.sql"
|
|
90
90
|
elif db_type == "postgresql":
|
|
91
|
-
sql_script = "
|
|
91
|
+
sql_script = "setup_postgresql_db.sql"
|
|
92
92
|
else:
|
|
93
93
|
raise ValueError(f"Unsupported database type: {db_type}")
|
|
94
94
|
|
|
@@ -94,7 +94,7 @@ class Project(object):
|
|
|
94
94
|
logger.warning(f"Well '{well_name}' already exists in project '{self.name}'. Skipping or updating.")
|
|
95
95
|
# Optionally, load and update the existing well
|
|
96
96
|
well_obj = Well(self.db_session, well_id=existing_well.well_id)
|
|
97
|
-
well_obj.update_data_from_las_parse(well_data,
|
|
97
|
+
well_obj.update_data_from_las_parse(well_data, header_data)
|
|
98
98
|
else:
|
|
99
99
|
well_obj = Well(
|
|
100
100
|
self.db_session,
|
|
@@ -104,7 +104,7 @@ class Project(object):
|
|
|
104
104
|
header_data=header_data_dict,
|
|
105
105
|
depth_uom=depth_uom
|
|
106
106
|
)
|
|
107
|
-
well_obj.update_data_from_las_parse(well_data,
|
|
107
|
+
well_obj.update_data_from_las_parse(well_data, header_data)
|
|
108
108
|
self.db_session.add(well_obj._orm_well)
|
|
109
109
|
self.db_session.flush()
|
|
110
110
|
|
|
@@ -120,7 +120,8 @@ class Project(object):
|
|
|
120
120
|
if orm_well:
|
|
121
121
|
well_obj = Well(self.db_session, well_id=orm_well.well_id)
|
|
122
122
|
well_obj.update_data(well_data)
|
|
123
|
-
|
|
123
|
+
if well_configs is not None:
|
|
124
|
+
well_obj.update_config(well_configs.get(well_name, {}))
|
|
124
125
|
well_obj.save() # Persist the updated data and config to the DB
|
|
125
126
|
else:
|
|
126
127
|
logger.warning(f"Well '{well_name}' not found in project '{self.name}'. Skipping update.")
|
|
@@ -306,14 +307,14 @@ class Well(object):
|
|
|
306
307
|
"""Loads a well from the database by ID."""
|
|
307
308
|
return cls(db_session=db_session, well_id=well_id)
|
|
308
309
|
|
|
309
|
-
def update_data_from_las_parse(self, parsed_data: pd.DataFrame, parsed_header:
|
|
310
|
+
def update_data_from_las_parse(self, parsed_data: pd.DataFrame, parsed_header: pd.DataFrame):
|
|
310
311
|
"""
|
|
311
312
|
Updates well's header and curve data from LAS parsing results.
|
|
312
313
|
`parsed_data` is expected to be a DataFrame where index is depth and columns are curve mnemonics.
|
|
313
314
|
`parsed_header` is a dictionary of header information.
|
|
314
315
|
"""
|
|
315
316
|
logger.info(f"Updating well '{self.name}' from LAS parse.")
|
|
316
|
-
self.header_data = parsed_header
|
|
317
|
+
self.header_data = parsed_header.to_dict()
|
|
317
318
|
|
|
318
319
|
# Get existing curve mnemonics for this well
|
|
319
320
|
existing_mnemonics = {c.mnemonic for c in self._orm_well.curves}
|
|
@@ -338,8 +339,8 @@ class Well(object):
|
|
|
338
339
|
orm_curve = ORMCurve(
|
|
339
340
|
well_id=self.well_id,
|
|
340
341
|
mnemonic=mnemonic,
|
|
341
|
-
unit=
|
|
342
|
-
description=
|
|
342
|
+
unit=las.get_unit_from_header(parsed_header, mnemonic),
|
|
343
|
+
description=las.get_descr_from_header(parsed_header, mnemonic),
|
|
343
344
|
data_type=data_type
|
|
344
345
|
)
|
|
345
346
|
self._orm_well.curves.append(orm_curve)
|
|
@@ -10,17 +10,22 @@ from quick_pp import logger
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def read_las_files(las_files, depth_uom=None):
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
"""Reads multiple LAS files and merges their data and headers.
|
|
14
|
+
|
|
15
|
+
This function iterates through a list of LAS file objects, reads each one,
|
|
16
|
+
and concatenates the curve data and header information into two separate
|
|
17
|
+
pandas DataFrames. It attempts to read with `welly` first and falls back
|
|
18
|
+
to a memory-mapped approach if `welly` fails.
|
|
18
19
|
|
|
19
20
|
Args:
|
|
20
|
-
las_files (list): list of
|
|
21
|
+
las_files (list): A list of file-like objects opened in binary mode.
|
|
22
|
+
depth_uom (str, optional): The unit of measurement for the depth index.
|
|
23
|
+
Used by `welly` during reading. Defaults to None.
|
|
21
24
|
|
|
22
25
|
Returns:
|
|
23
|
-
pd.DataFrame
|
|
26
|
+
tuple[pd.DataFrame, pd.DataFrame]:
|
|
27
|
+
- A DataFrame containing the merged curve data from all LAS files.
|
|
28
|
+
- A DataFrame containing the merged header information from all LAS files.
|
|
24
29
|
"""
|
|
25
30
|
merged_data = pd.DataFrame()
|
|
26
31
|
header_data = pd.DataFrame()
|
|
@@ -40,14 +45,25 @@ def read_las_files(las_files, depth_uom=None):
|
|
|
40
45
|
|
|
41
46
|
|
|
42
47
|
def read_las_file_mmap(file_object, required_sets=['PEP']): # noqa
|
|
43
|
-
"""
|
|
48
|
+
"""Reads a single LAS file using a memory-mapped approach, handling multiple data sets.
|
|
49
|
+
|
|
50
|
+
This function is designed to parse LAS files, especially those with multiple
|
|
51
|
+
data sets (e.g., different logging runs), which might not be handled correctly
|
|
52
|
+
by standard parsers. It uses memory-mapping for efficient file access and can
|
|
53
|
+
selectively extract required data sets.
|
|
44
54
|
|
|
45
55
|
Args:
|
|
46
|
-
file_object (
|
|
47
|
-
required_sets (list, optional):
|
|
56
|
+
file_object (file): A file-like object opened in binary mode.
|
|
57
|
+
required_sets (list, optional): A list of data set identifiers to extract.
|
|
58
|
+
If the LAS file contains multiple sets, only
|
|
59
|
+
those matching the identifiers in this list
|
|
60
|
+
will be processed. Defaults to ['PEP'].
|
|
48
61
|
|
|
49
62
|
Returns:
|
|
50
|
-
pd.
|
|
63
|
+
tuple[pd.DataFrame, pd.DataFrame, welly.well.Well]:
|
|
64
|
+
- A DataFrame containing the curve data.
|
|
65
|
+
- A DataFrame containing the header information.
|
|
66
|
+
- A `welly.well.Well` object representing the well.
|
|
51
67
|
"""
|
|
52
68
|
fileno = file_object.fileno() # identifier for files
|
|
53
69
|
parameter_line_numbers = []
|
|
@@ -139,6 +155,23 @@ def read_las_file_mmap(file_object, required_sets=['PEP']): # noqa
|
|
|
139
155
|
|
|
140
156
|
|
|
141
157
|
def read_las_file_welly(file_object, depth_uom=None):
|
|
158
|
+
"""Reads a LAS file using the welly library.
|
|
159
|
+
|
|
160
|
+
This function provides a straightforward way to read a LAS file into a
|
|
161
|
+
`welly` object, which is then processed to extract curve data and header
|
|
162
|
+
information into pandas DataFrames.
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
file_object (file): A file-like object, from which the `.name` attribute
|
|
166
|
+
(file path) is used by `welly`.
|
|
167
|
+
depth_uom (str, optional): The unit of measurement for the depth index.
|
|
168
|
+
Passed to `welly` for index creation. Defaults to None.
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
tuple[pd.DataFrame, pd.DataFrame]:
|
|
172
|
+
- A DataFrame containing the processed curve data.
|
|
173
|
+
- A DataFrame containing the header information.
|
|
174
|
+
"""
|
|
142
175
|
welly_dataset = welly.las.from_las(file_object.name)
|
|
143
176
|
welly_object = welly.well.Well.from_datasets(welly_dataset, index_units=depth_uom)
|
|
144
177
|
df, well_header = pre_process(welly_object)
|
|
@@ -146,18 +179,21 @@ def read_las_file_welly(file_object, depth_uom=None):
|
|
|
146
179
|
|
|
147
180
|
|
|
148
181
|
def pre_process(welly_object):
|
|
149
|
-
"""Pre-
|
|
182
|
+
"""Pre-processes a `welly` object to extract and clean data.
|
|
150
183
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
184
|
+
This function takes a `welly.well.Well` object and performs several
|
|
185
|
+
pre-processing steps:
|
|
186
|
+
1. Converts the depth index to a 'DEPTH' column.
|
|
187
|
+
2. Replaces LAS-defined NULL values with `np.nan`.
|
|
188
|
+
3. Inserts 'WELL_NAME' and 'UWI' columns at the beginning of the DataFrame.
|
|
155
189
|
|
|
156
190
|
Args:
|
|
157
|
-
welly_object (well
|
|
191
|
+
welly_object (welly.well.Well): The welly object to process.
|
|
158
192
|
|
|
159
193
|
Returns:
|
|
160
|
-
pd.
|
|
194
|
+
tuple[pd.DataFrame, pd.DataFrame]:
|
|
195
|
+
- A DataFrame containing the processed curve data.
|
|
196
|
+
- A DataFrame containing the header information.
|
|
161
197
|
"""
|
|
162
198
|
# Convert index 'DEPTH' as column
|
|
163
199
|
data_df = welly_object.las[0]
|
|
@@ -172,7 +208,7 @@ def pre_process(welly_object):
|
|
|
172
208
|
# Insert well name
|
|
173
209
|
well_name = get_wellname_from_header(header_df)
|
|
174
210
|
if 'WELL_NAME' not in data_df.columns:
|
|
175
|
-
data_df.insert(0, 'WELL_NAME', well_name
|
|
211
|
+
data_df.insert(0, 'WELL_NAME', well_name)
|
|
176
212
|
# Insert UWI if available
|
|
177
213
|
if 'UWI' in header_df['mnemonic'].values:
|
|
178
214
|
uwi = get_uwi_from_header(header_df)
|
|
@@ -182,26 +218,70 @@ def pre_process(welly_object):
|
|
|
182
218
|
|
|
183
219
|
|
|
184
220
|
def get_wellname_from_header(header_df):
|
|
221
|
+
"""Extracts the well name from the LAS header DataFrame.
|
|
222
|
+
|
|
223
|
+
Args:
|
|
224
|
+
header_df (pd.DataFrame): The LAS header data.
|
|
225
|
+
|
|
226
|
+
Returns:
|
|
227
|
+
str: The well name, with slashes and spaces replaced by hyphens.
|
|
228
|
+
"""
|
|
185
229
|
return header_df[
|
|
186
230
|
(header_df['mnemonic'] == 'WELL') | (header_df['descr'].str.upper() == 'WELL')
|
|
187
|
-
]['value'].values[0]
|
|
231
|
+
]['value'].values[0].replace("/", "-").replace(" ", "-")
|
|
188
232
|
|
|
189
233
|
|
|
190
234
|
def get_uwi_from_header(header_df):
|
|
235
|
+
"""Extracts the Unique Well Identifier (UWI) from the LAS header DataFrame.
|
|
236
|
+
|
|
237
|
+
If the UWI is not found, it falls back to using the well name.
|
|
238
|
+
|
|
239
|
+
Args:
|
|
240
|
+
header_df (pd.DataFrame): The LAS header data.
|
|
241
|
+
|
|
242
|
+
Returns:
|
|
243
|
+
str: The UWI or well name, with slashes and spaces replaced by hyphens.
|
|
244
|
+
"""
|
|
191
245
|
uwi = header_df[
|
|
192
246
|
(header_df['mnemonic'] == 'UWI') | (header_df['descr'].str.upper() == 'UNIQUE WELL ID')
|
|
193
|
-
]['value'].values[0]
|
|
247
|
+
]['value'].values[0].replace("/", "-").replace(" ", "-")
|
|
194
248
|
return uwi if uwi else get_wellname_from_header(header_df)
|
|
195
249
|
|
|
196
250
|
|
|
251
|
+
def get_unit_from_header(header_df, mnemonic):
|
|
252
|
+
"""Extracts the unit for a specific curve mnemonic from the LAS header.
|
|
253
|
+
|
|
254
|
+
Args:
|
|
255
|
+
header_df (pd.DataFrame): The LAS header data.
|
|
256
|
+
mnemonic (str): The curve mnemonic to look for.
|
|
257
|
+
|
|
258
|
+
Returns:
|
|
259
|
+
str or None: The unit of the curve, or None if not found.
|
|
260
|
+
"""
|
|
261
|
+
return header_df[header_df['mnemonic'] == mnemonic]['unit'].values[0] if any(
|
|
262
|
+
header_df['mnemonic'].str.contains(mnemonic)) else None
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def get_descr_from_header(header_df, mnemonic):
|
|
266
|
+
"""Extracts the description for a specific curve mnemonic from the LAS header.
|
|
267
|
+
|
|
268
|
+
Args:
|
|
269
|
+
header_df (pd.DataFrame): The LAS header data.
|
|
270
|
+
mnemonic (str): The curve mnemonic to look for.
|
|
271
|
+
|
|
272
|
+
Returns:
|
|
273
|
+
str or None: The description of the curve, or None if not found.
|
|
274
|
+
"""
|
|
275
|
+
return header_df[header_df['mnemonic'] == mnemonic]['descr'].values[0] if any(
|
|
276
|
+
header_df['mnemonic'].str.contains(mnemonic)) else None
|
|
277
|
+
|
|
278
|
+
|
|
197
279
|
def extract_dataset(section_dict):
|
|
198
|
-
"""
|
|
280
|
+
"""Extracts a single dataset from a dictionary of LAS file sections.
|
|
199
281
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
4. Using lasio.read and welly.well.from_lasio, create welly_object & well_df from file_object
|
|
204
|
-
5. Through function "pre_process", return df with null replaced by nan, addition of column with well and field name
|
|
282
|
+
This function is intended for LAS files that contain only one data set.
|
|
283
|
+
It reconstructs the LAS file content from the separated sections, reads it
|
|
284
|
+
using `lasio` and `welly`, and then pre-processes the result.
|
|
205
285
|
|
|
206
286
|
Args:
|
|
207
287
|
section_dict (dict): Dictionary containing the LAS file section values.
|
|
@@ -231,18 +311,21 @@ def extract_dataset(section_dict):
|
|
|
231
311
|
|
|
232
312
|
|
|
233
313
|
def concat_datasets(file_object, header_line_numbers, parameter_line_numbers, required_sets=['PEP']):
|
|
234
|
-
"""
|
|
314
|
+
"""Extracts and concatenates specified datasets from a multi-set LAS file.
|
|
235
315
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
316
|
+
This function iterates through the parameter sections identified in a LAS file.
|
|
317
|
+
For each section that matches the `required_sets`, it reconstructs a temporary
|
|
318
|
+
single-set LAS file in memory, reads it, and concatenates the resulting data.
|
|
239
319
|
|
|
240
320
|
Args:
|
|
241
|
-
file_object (
|
|
242
|
-
header_line_numbers (list
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
321
|
+
file_object (bytes): The full content of the LAS file as a bytes object.
|
|
322
|
+
header_line_numbers (list): A list of tuples defining the start and end
|
|
323
|
+
pointers for the main well header section.
|
|
324
|
+
parameter_line_numbers (list): A list of tuples, each containing metadata
|
|
325
|
+
about a `~Parameter` section, including its
|
|
326
|
+
set identifier and pointer location.
|
|
327
|
+
required_sets (list, optional): A list of data set identifiers to extract
|
|
328
|
+
and concatenate. Defaults to ['PEP'].
|
|
246
329
|
|
|
247
330
|
Returns:
|
|
248
331
|
pd.Dataframe, pd.Dataframe, welly_object: well_df, header_df and welly_object
|
|
@@ -275,13 +358,15 @@ def concat_datasets(file_object, header_line_numbers, parameter_line_numbers, re
|
|
|
275
358
|
|
|
276
359
|
|
|
277
360
|
def check_index_consistent(welly_object):
|
|
278
|
-
"""
|
|
361
|
+
"""Checks if the depth index of a welly object is consistent.
|
|
362
|
+
|
|
363
|
+
A consistent index means it is monotonically increasing with a constant step.
|
|
279
364
|
|
|
280
365
|
Args:
|
|
281
|
-
welly_object (
|
|
366
|
+
welly_object (welly.well.Well): The welly object to check.
|
|
282
367
|
|
|
283
368
|
Returns:
|
|
284
|
-
bool: True if index is consistent
|
|
369
|
+
bool: True if the index is consistent, False otherwise.
|
|
285
370
|
"""
|
|
286
371
|
try:
|
|
287
372
|
index_diff = np.diff(welly_object.las[0].index)
|
|
@@ -295,11 +380,18 @@ def check_index_consistent(welly_object):
|
|
|
295
380
|
|
|
296
381
|
|
|
297
382
|
def export_to_las(well_data, well_name, folder='', vars_units=None):
|
|
298
|
-
"""
|
|
383
|
+
"""Exports a DataFrame of well data to a LAS file.
|
|
384
|
+
|
|
385
|
+
The input DataFrame is expected to have a 'DEPTH' column, which will be
|
|
386
|
+
used as the index for the LAS file.
|
|
299
387
|
|
|
300
388
|
Args:
|
|
301
|
-
|
|
302
|
-
well_name (str): well
|
|
389
|
+
well_data (pd.DataFrame): The DataFrame containing the well log data.
|
|
390
|
+
well_name (str): The name of the well, used for the output filename.
|
|
391
|
+
folder (str, optional): The directory to save the LAS file in. Defaults to ''.
|
|
392
|
+
vars_units (dict, optional): A dictionary mapping curve mnemonics to their
|
|
393
|
+
units. If not provided, it will be inferred
|
|
394
|
+
from the configuration.
|
|
303
395
|
"""
|
|
304
396
|
from .config import Config
|
|
305
397
|
units = vars_units if vars_units else Config.vars_units(well_data)
|
|
@@ -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
|