quick-pp 0.2.67__tar.gz → 0.2.68__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.68}/PKG-INFO +1 -1
- {quick_pp-0.2.67 → quick_pp-0.2.68}/pyproject.toml +1 -1
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/__init__.py +1 -1
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/database/db_connector.py +2 -2
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/database/objects.py +8 -7
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/las_handler.py +134 -42
- {quick_pp-0.2.67 → quick_pp-0.2.68}/.gitignore +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/LICENSE +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/README.md +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/exceptions.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/fastapi_mlflow/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/fastapi_mlflow/_mlflow_types.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/fastapi_mlflow/applications.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/fastapi_mlflow/exceptions.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/fastapi_mlflow/predictors.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/main.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/mlflow_model_deployment.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/router.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/schemas/lithology_hc_correction.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/schemas/lithology_ssc.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/schemas/lithology_vsh_gr.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/schemas/permeability_choo.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/schemas/permeability_others.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/schemas/porosity.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/schemas/ressum.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/schemas/saturation_archie.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/schemas/saturation_b.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/schemas/saturation_qv.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/schemas/saturation_rw.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/schemas/saturation_temp_grad.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/schemas/saturation_waxman_smits.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/services/chat.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/services/las_handler.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/services/lithology.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/services/permeability.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/services/porosity.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/services/reservoir_summary.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/services/saturation.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/static/favicon.ico +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/static/logo.png +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/template/chat.html +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/api/template/home.html +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/cli.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/config.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/core_calibration.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/database/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/database/models.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/database/setup_postgresql_db.sql +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/database/setup_sqlite_db.sql +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/fluid_type.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/lithology/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/lithology/carbonate.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/lithology/multi_mineral.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/lithology/sand_shale.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/lithology/sand_silt_clay.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/lithology/thin_beds.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/machine_learning/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/machine_learning/config.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/machine_learning/feature_engineering.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/machine_learning/mock_data/mock_data.parquet +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/machine_learning/predict_pipeline.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/machine_learning/train_pipeline.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/machine_learning/utils.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/permeability.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/plotter/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/plotter/plotter.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/plotter/well_log.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/plotter/well_log_config.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/porosity.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/qaqc.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/ressum.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/rock_physics/__init__.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/rock_physics/geomechanics.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/rock_physics/geophysics.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/rock_physics/rpm.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/rock_type.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/quick_pp/saturation.py +0 -0
- {quick_pp-0.2.67 → quick_pp-0.2.68}/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.68
|
|
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.68' # Need to be updated manually when releasing a new version/ change in pyproject.toml
|
|
@@ -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)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|