quick-pp 0.2.54__tar.gz → 0.2.56__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.54 → quick_pp-0.2.56}/PKG-INFO +5 -2
- {quick_pp-0.2.54 → quick_pp-0.2.56}/README.md +3 -1
- {quick_pp-0.2.54 → quick_pp-0.2.56}/pyproject.toml +2 -1
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/__init__.py +1 -1
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/config.py +4 -4
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/core_calibration.py +105 -1
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/lithology/sand_shale.py +9 -5
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/lithology/sand_silt_clay.py +7 -3
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/plotter/well_log_config.py +9 -5
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/porosity.py +10 -17
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/qaqc.py +1 -1
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/ressum.py +10 -10
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/rock_type.py +2 -2
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/saturation.py +223 -23
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/utils.py +25 -3
- quick_pp-0.2.54/quick_pp/plotter/xplots.py +0 -170
- {quick_pp-0.2.54 → quick_pp-0.2.56}/.gitignore +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/LICENSE +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/__init__.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/exceptions.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/fastapi_mlflow/__init__.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/fastapi_mlflow/_mlflow_types.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/fastapi_mlflow/applications.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/fastapi_mlflow/exceptions.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/fastapi_mlflow/predictors.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/main.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/mlflow_model_deployment.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/router.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/schemas/lithology_hc_correction.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/schemas/lithology_ssc.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/schemas/lithology_vsh_gr.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/schemas/permeability_choo.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/schemas/permeability_others.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/schemas/porosity.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/schemas/ressum.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/schemas/saturation_archie.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/schemas/saturation_b.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/schemas/saturation_qv.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/schemas/saturation_rw.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/schemas/saturation_temp_grad.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/schemas/saturation_waxman_smits.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/services/chat.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/services/las_handler.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/services/lithology.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/services/permeability.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/services/porosity.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/services/reservoir_summary.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/services/saturation.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/static/favicon.ico +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/static/logo.png +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/template/chat.html +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/api/template/home.html +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/cli.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/fluid_type.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/las_handler.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/lithology/__init__.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/lithology/carbonate.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/lithology/multi_mineral.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/lithology/thin_beds.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/machine_learning/__init__.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/machine_learning/config.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/machine_learning/feature_engineering.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/machine_learning/mock_data/mock_data.parquet +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/machine_learning/predict_pipeline.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/machine_learning/train_pipeline.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/machine_learning/utils.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/objects.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/permeability.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/plotter/__init__.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/plotter/plotter.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/plotter/well_log.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/rock_physics/__init__.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/rock_physics/geomechanics.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/rock_physics/geophysics.py +0 -0
- {quick_pp-0.2.54 → quick_pp-0.2.56}/quick_pp/rock_physics/rpm.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.56
|
|
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>
|
|
@@ -14,6 +14,7 @@ Classifier: Natural Language :: English
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
15
|
Requires-Python: >=3.11
|
|
16
16
|
Requires-Dist: click>=7.0
|
|
17
|
+
Requires-Dist: dtw-python
|
|
17
18
|
Requires-Dist: fastapi
|
|
18
19
|
Requires-Dist: loguru
|
|
19
20
|
Requires-Dist: matplotlib==3.8.0
|
|
@@ -68,13 +69,15 @@ For development or to use the `qpp_assistant`, you'll need to clone the reposito
|
|
|
68
69
|
|
|
69
70
|
### Jupyter Notebook Examples
|
|
70
71
|
|
|
72
|
+
> More structured analysis/ examples are done in https://github.com/imranfadhil/pp_portfolio
|
|
73
|
+
|
|
71
74
|
The included notebooks demonstrate the core functionalities:
|
|
72
75
|
|
|
73
76
|
- `01_data_handler`: Create a MOCK `qppp` project file.
|
|
74
77
|
- `02_EDA`: Perform a quick exploratory data analysis.
|
|
75
78
|
- `03_*`: Carry out petrophysical interpretation of the MOCK wells.
|
|
76
79
|
|
|
77
|
-
|
|
80
|
+
**Note:** For the API notebook, you need to run `python main.py app` before executing the cells.
|
|
78
81
|
|
|
79
82
|
### `qpp_assistant` Setup
|
|
80
83
|
|
|
@@ -35,13 +35,15 @@ For development or to use the `qpp_assistant`, you'll need to clone the reposito
|
|
|
35
35
|
|
|
36
36
|
### Jupyter Notebook Examples
|
|
37
37
|
|
|
38
|
+
> More structured analysis/ examples are done in https://github.com/imranfadhil/pp_portfolio
|
|
39
|
+
|
|
38
40
|
The included notebooks demonstrate the core functionalities:
|
|
39
41
|
|
|
40
42
|
- `01_data_handler`: Create a MOCK `qppp` project file.
|
|
41
43
|
- `02_EDA`: Perform a quick exploratory data analysis.
|
|
42
44
|
- `03_*`: Carry out petrophysical interpretation of the MOCK wells.
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
**Note:** For the API notebook, you need to run `python main.py app` before executing the cells.
|
|
45
47
|
|
|
46
48
|
### `qpp_assistant` Setup
|
|
47
49
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "quick-pp"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.56"
|
|
8
8
|
description = "Python package to assist in providing quick-look/ preliminary petrophysical estimation."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -29,6 +29,7 @@ classifiers = [
|
|
|
29
29
|
]
|
|
30
30
|
dependencies = [
|
|
31
31
|
"Click>=7.0",
|
|
32
|
+
"dtw-python",
|
|
32
33
|
"fastapi",
|
|
33
34
|
"loguru",
|
|
34
35
|
"matplotlib==3.8.0",
|
|
@@ -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.56' # Need to be updated manually when releasing a new version/ change in pyproject.toml
|
|
@@ -9,11 +9,11 @@ class Config(object):
|
|
|
9
9
|
VARS = dict(
|
|
10
10
|
GR=dict(name="Gamma Ray", unit="GAPI", min=0, max=200),
|
|
11
11
|
RT=dict(name="True Resistivity", unit="ohm.m", min=0, max=2000),
|
|
12
|
-
NPHI=dict(name="Neutron Porosity", unit="v/v", min=-.05, max=0
|
|
13
|
-
RHOB=dict(name="Bulk Density", unit="g/cc", min=1.
|
|
12
|
+
NPHI=dict(name="Neutron Porosity", unit="v/v", min=-.05, max=1.0),
|
|
13
|
+
RHOB=dict(name="Bulk Density", unit="g/cc", min=1.0, max=3.0),
|
|
14
14
|
PEF=dict(name="Peak Frequency", unit="Hz", min=0, max=10),
|
|
15
|
-
DTC=dict(name="DTC", unit="us/ft", min=
|
|
16
|
-
DTS=dict(name="DTS", unit="us/ft", min=
|
|
15
|
+
DTC=dict(name="DTC", unit="us/ft", min=20, max=260),
|
|
16
|
+
DTS=dict(name="DTS", unit="us/ft", min=20, max=260),
|
|
17
17
|
VSAND=dict(name="Sand Volume", unit="v/v", min=0, max=1),
|
|
18
18
|
VSILT=dict(name="Silt Volume", unit="v/v", min=0, max=1),
|
|
19
19
|
VCLAY=dict(name="Clay Volume", unit="v/v", min=0, max=1),
|
|
@@ -2,6 +2,9 @@ from scipy.optimize import curve_fit
|
|
|
2
2
|
import matplotlib.pyplot as plt
|
|
3
3
|
import numpy as np
|
|
4
4
|
import plotly.graph_objects as go
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
from dtw import dtw
|
|
7
|
+
import pandas as pd
|
|
5
8
|
|
|
6
9
|
from quick_pp.utils import power_law_func, inv_power_law_func
|
|
7
10
|
from quick_pp import logger
|
|
@@ -26,6 +29,7 @@ def poroperm_xplot(poro, perm, a=None, b=None, core_group=None, label='', log_lo
|
|
|
26
29
|
perm (float): Core permeability (mD).
|
|
27
30
|
a (float, optional): a constant in perm=a*poro^b. Defaults to None.
|
|
28
31
|
b (float, optional): b constant in perm=a*poro^b. Defaults to None.
|
|
32
|
+
core_group (array-like, optional): Grouping for core samples to be used for coloring. Defaults to None.
|
|
29
33
|
label (str, optional): Label for the data group. Defaults to ''.
|
|
30
34
|
log_log (bool, optional): Whether to plot log-log or not. Defaults to False.
|
|
31
35
|
"""
|
|
@@ -42,7 +46,7 @@ def poroperm_xplot(poro, perm, a=None, b=None, core_group=None, label='', log_lo
|
|
|
42
46
|
plt.xlabel('CPORE (frac)')
|
|
43
47
|
plt.xlim(0.001, 0.5)
|
|
44
48
|
plt.ylabel('CPERM (mD)')
|
|
45
|
-
plt.ylim(.001,
|
|
49
|
+
plt.ylim(.001, 1e5)
|
|
46
50
|
plt.yscale('log')
|
|
47
51
|
if log_log:
|
|
48
52
|
plt.xscale('log')
|
|
@@ -392,3 +396,103 @@ def sw_shf_choo(perm, phit, phie, depth, fwl, ift, theta, gw, ghc, b0=0.4):
|
|
|
392
396
|
(0.2166 * (pc / (ift * abs(np.cos(np.radians(theta))))) * (
|
|
393
397
|
perm / phit)**(0.5))**(b0 * np.log10(1 + swb**-1) / 3))
|
|
394
398
|
return shf
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
def autocorrelate_core_depth(df):
|
|
402
|
+
"""Automatically shift core depths to match log depths using Dynamic Time Warping (DTW).
|
|
403
|
+
|
|
404
|
+
This function aligns core porosity (CPORE) with log porosity (PHIT) to correct for
|
|
405
|
+
depth discrepancies between core and wireline log measurements. It processes the data
|
|
406
|
+
on a per-well basis.
|
|
407
|
+
|
|
408
|
+
Args:
|
|
409
|
+
df (pd.DataFrame): DataFrame containing well log and core data. Must include
|
|
410
|
+
'WELL_NAME', 'DEPTH', 'PHIT', 'CPORE', 'CPERM', and 'CORE_ID'.
|
|
411
|
+
|
|
412
|
+
Returns:
|
|
413
|
+
tuple[pd.DataFrame, pd.DataFrame]:
|
|
414
|
+
- A DataFrame with the original data merged with the depth-corrected core
|
|
415
|
+
data. New columns include 'DEPTH_CORRECTED', 'CORE_ID_SHIFTED',
|
|
416
|
+
'CPORE_SHIFTED', and 'CPERM_SHIFTED'.
|
|
417
|
+
- A summary DataFrame detailing the depth shifts for each core sample,
|
|
418
|
+
including 'WELL_NAME', 'CORE_ID', 'ORIGINAL_DEPTH', 'DEPTH_CORRECTED',
|
|
419
|
+
and 'DEPTH_SHIFT'.
|
|
420
|
+
"""
|
|
421
|
+
required_cols = ['WELL_NAME', 'DEPTH', 'PHIT', 'CPORE', 'CPERM', 'CORE_ID']
|
|
422
|
+
for col in required_cols:
|
|
423
|
+
if col not in df.columns:
|
|
424
|
+
raise AssertionError(f"Missing required column: {col}")
|
|
425
|
+
|
|
426
|
+
shift_summaries = []
|
|
427
|
+
return_df = pd.DataFrame()
|
|
428
|
+
for well, data in tqdm(df.groupby('WELL_NAME'), desc='Correlating core depths'):
|
|
429
|
+
core_data = data[['DEPTH', 'CORE_ID', 'CPORE', 'CPERM']].dropna().sort_values('DEPTH').reset_index(drop=True)
|
|
430
|
+
|
|
431
|
+
if core_data.empty:
|
|
432
|
+
return_df = pd.concat([return_df, data])
|
|
433
|
+
continue
|
|
434
|
+
|
|
435
|
+
log_data = data[['DEPTH', 'PHIT']].dropna().sort_values('DEPTH').reset_index(drop=True)
|
|
436
|
+
tqdm.write(f'Processing {well}: {len(core_data)} core data and {len(log_data)} log data')
|
|
437
|
+
|
|
438
|
+
# Create a window of log data around core points to speed up DTW
|
|
439
|
+
core_indices_in_log = np.searchsorted(log_data.DEPTH, core_data.DEPTH, side='left')
|
|
440
|
+
window = 1
|
|
441
|
+
window_indices = core_indices_in_log[:, None] + np.arange(-window, window + 1)
|
|
442
|
+
window_indices = np.clip(window_indices, 0, len(log_data) - 1)
|
|
443
|
+
unique_indices = np.unique(window_indices.flatten())
|
|
444
|
+
log_data_subset = log_data.iloc[unique_indices].reset_index(drop=True)
|
|
445
|
+
|
|
446
|
+
# Extract the numpy arrays for the DTW algorithm
|
|
447
|
+
phit_vals = log_data_subset['PHIT'].values
|
|
448
|
+
cpore_vals = core_data['CPORE'].values
|
|
449
|
+
|
|
450
|
+
alignment = dtw(cpore_vals, phit_vals,
|
|
451
|
+
distance_only=False,
|
|
452
|
+
keep_internals=True,
|
|
453
|
+
step_pattern="symmetric2")
|
|
454
|
+
|
|
455
|
+
# The alignment object contains the mapping between indices
|
|
456
|
+
core_indices = alignment.index1 # Indices for the `core_data` DataFrame
|
|
457
|
+
log_indices = alignment.index2 # Indices for the `log_data_subset` DataFrame
|
|
458
|
+
|
|
459
|
+
# Create a detailed map from the alignment
|
|
460
|
+
correction_map_df = pd.DataFrame({
|
|
461
|
+
'ORIGINAL_DEPTH': core_data.loc[core_indices, 'DEPTH'].values,
|
|
462
|
+
'CORE_ID_SHIFTED': core_data.loc[core_indices, 'CORE_ID'].values,
|
|
463
|
+
'CPORE_SHIFTED': core_data.loc[core_indices, 'CPORE'].values,
|
|
464
|
+
'CPERM_SHIFTED': core_data.loc[core_indices, 'CPERM'].values,
|
|
465
|
+
'MATCHED_PHIT': log_data_subset.loc[log_indices, 'PHIT'].values,
|
|
466
|
+
'DEPTH_CORRECTED': log_data_subset.loc[log_indices, 'DEPTH'].values
|
|
467
|
+
})
|
|
468
|
+
|
|
469
|
+
# Find the best match for each original core depth by minimizing porosity difference
|
|
470
|
+
correction_map_df['PORO_DIFF'] = (correction_map_df['CPORE_SHIFTED'] - correction_map_df['MATCHED_PHIT']).abs()
|
|
471
|
+
correction_map_df['DEPTH_SHIFT'] = round(
|
|
472
|
+
correction_map_df.DEPTH_CORRECTED - correction_map_df.ORIGINAL_DEPTH, 3)
|
|
473
|
+
best_matches = correction_map_df.sort_values('PORO_DIFF').drop_duplicates('ORIGINAL_DEPTH')
|
|
474
|
+
|
|
475
|
+
if not best_matches.empty:
|
|
476
|
+
summary = best_matches[['CORE_ID_SHIFTED', 'ORIGINAL_DEPTH', 'DEPTH_CORRECTED', 'DEPTH_SHIFT']].copy()
|
|
477
|
+
summary.rename(columns={'CORE_ID_SHIFTED': 'CORE_ID'}, inplace=True)
|
|
478
|
+
summary['WELL_NAME'] = well
|
|
479
|
+
# Reorder columns for clarity
|
|
480
|
+
summary = summary[['WELL_NAME', 'CORE_ID', 'ORIGINAL_DEPTH', 'DEPTH_CORRECTED', 'DEPTH_SHIFT']]
|
|
481
|
+
shift_summaries.append(summary)
|
|
482
|
+
|
|
483
|
+
# Merge the corrected core data back into the original well data
|
|
484
|
+
df_corrected = pd.merge(
|
|
485
|
+
data,
|
|
486
|
+
best_matches[['DEPTH_CORRECTED', 'CORE_ID_SHIFTED', 'CPORE_SHIFTED', 'CPERM_SHIFTED']],
|
|
487
|
+
left_on='DEPTH',
|
|
488
|
+
right_on='DEPTH_CORRECTED',
|
|
489
|
+
how='left'
|
|
490
|
+
)
|
|
491
|
+
return_df = pd.concat([return_df, df_corrected])
|
|
492
|
+
|
|
493
|
+
final_summary_df = pd.DataFrame()
|
|
494
|
+
# After the loop, combine all summaries into a single DataFrame
|
|
495
|
+
if shift_summaries:
|
|
496
|
+
final_summary_df = pd.concat(shift_summaries, ignore_index=True)
|
|
497
|
+
|
|
498
|
+
return return_df, final_summary_df
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
from typing import Optional
|
|
3
3
|
|
|
4
|
-
from quick_pp.utils import min_max_line, length_a_b, line_intersection
|
|
4
|
+
from quick_pp.utils import min_max_line, length_a_b, line_intersection, remove_outliers
|
|
5
5
|
from quick_pp.config import Config
|
|
6
6
|
from quick_pp import logger
|
|
7
7
|
|
|
@@ -45,9 +45,13 @@ class SandShale:
|
|
|
45
45
|
D = self.fluid_point
|
|
46
46
|
|
|
47
47
|
# Redefine wetclay point
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if not all(self.wet_clay_point):
|
|
48
|
+
nphi_max_line = None
|
|
49
|
+
rhob_max_line = None
|
|
50
|
+
if not all(self.wet_clay_point):
|
|
51
|
+
rhob_clean = remove_outliers(rhob)
|
|
52
|
+
nphi_clean = remove_outliers(nphi)
|
|
53
|
+
_, rhob_max_line = min_max_line(rhob_clean, 0.05)
|
|
54
|
+
_, nphi_max_line = min_max_line(nphi_clean, 0.05)
|
|
51
55
|
wetclay_RHOB = np.min(rhob_max_line)
|
|
52
56
|
wetclay_NPHI = np.max(nphi_max_line)
|
|
53
57
|
self.wet_clay_point = (wetclay_NPHI, wetclay_RHOB)
|
|
@@ -67,7 +71,7 @@ class SandShale:
|
|
|
67
71
|
f"vcld: {vcld.mean():.3f}"
|
|
68
72
|
)
|
|
69
73
|
|
|
70
|
-
return vsand, vcld
|
|
74
|
+
return vsand, vcld, (nphi_max_line, rhob_max_line)
|
|
71
75
|
|
|
72
76
|
def lithology_fraction(self, nphi, rhob):
|
|
73
77
|
"""Estimate sand and shale based on neutron density cross plot.
|
|
@@ -2,7 +2,7 @@ import numpy as np
|
|
|
2
2
|
import math
|
|
3
3
|
from typing import Optional
|
|
4
4
|
|
|
5
|
-
from quick_pp.utils import min_max_line, length_a_b, line_intersection
|
|
5
|
+
from quick_pp.utils import min_max_line, length_a_b, line_intersection, remove_outliers
|
|
6
6
|
from quick_pp.config import Config
|
|
7
7
|
from quick_pp import logger
|
|
8
8
|
|
|
@@ -54,9 +54,13 @@ class SandSiltClay:
|
|
|
54
54
|
D = self.fluid_point
|
|
55
55
|
|
|
56
56
|
# Redefine wetclay point
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
nphi_max_line = None
|
|
58
|
+
rhob_max_line = None
|
|
59
59
|
if not all(self.wet_clay_point):
|
|
60
|
+
rhob_clean = remove_outliers(rhob)
|
|
61
|
+
nphi_clean = remove_outliers(nphi)
|
|
62
|
+
_, rhob_max_line = min_max_line(rhob_clean, 0.1)
|
|
63
|
+
_, nphi_max_line = min_max_line(nphi_clean, 0.1)
|
|
60
64
|
wetclay_RHOB = np.nanmin(rhob_max_line)
|
|
61
65
|
wetclay_NPHI = np.nanmax(nphi_max_line)
|
|
62
66
|
self.wet_clay_point = (wetclay_NPHI, wetclay_RHOB)
|
|
@@ -312,7 +312,11 @@ TRACE_DEFS = dict(
|
|
|
312
312
|
track=8,
|
|
313
313
|
secondary_y=False,
|
|
314
314
|
hide_xaxis=False,
|
|
315
|
-
style={
|
|
315
|
+
style={
|
|
316
|
+
'line_width': 0, 'fill': 'tozerox', 'fillpattern_bgcolor': "#4D4DB8",
|
|
317
|
+
'fillpattern_fgcolor': '#000000', 'fillpattern_fillmode': 'replace', 'fillpattern_shape': '|',
|
|
318
|
+
'fillpattern_size': 3, 'fillpattern_solidity': 0.3
|
|
319
|
+
}
|
|
316
320
|
),
|
|
317
321
|
)
|
|
318
322
|
|
|
@@ -454,21 +458,21 @@ XAXIS_DEFS = dict(
|
|
|
454
458
|
dtick=0.1, range=[0, 0.5], type='linear', zeroline=False
|
|
455
459
|
),
|
|
456
460
|
COAL_FLAG=dict(
|
|
457
|
-
range=[.1, .2], type='linear', showgrid=False, zeroline=False,
|
|
461
|
+
range=[.1, .2], type='linear', showgrid=False, zeroline=False, tickfont={'size': 1}
|
|
458
462
|
),
|
|
459
463
|
TIGHT_FLAG=dict(
|
|
460
|
-
range=[.1, .2], type='linear', showgrid=False, zeroline=False, overlaying='x8'
|
|
464
|
+
range=[.1, .2], type='linear', showgrid=False, zeroline=False, tickfont={'size': 1}, overlaying='x8'
|
|
461
465
|
),
|
|
462
466
|
DTC=dict(
|
|
463
467
|
title={'text': 'DTC (us/ft)', 'font': {'color': COLOR_DICT['DTC'], 'size': font_size}},
|
|
464
468
|
tickfont={'color': COLOR_DICT['DTC'], 'size': font_size},
|
|
465
469
|
side='top', anchor='free', position=.85, title_standoff=.1,
|
|
466
|
-
dtick=
|
|
470
|
+
dtick=20, range=[140, 40], tickangle=-90, type='linear', zeroline=False
|
|
467
471
|
),
|
|
468
472
|
DTS=dict(
|
|
469
473
|
title={'text': 'DTS (us/ft)', 'font': {'color': COLOR_DICT['DTS'], 'size': font_size}},
|
|
470
474
|
tickfont={'color': COLOR_DICT['DTS'], 'size': font_size},
|
|
471
475
|
side='top', anchor='free', position=.89, title_standoff=.1, overlaying='x9',
|
|
472
|
-
dtick=40, range=[
|
|
476
|
+
dtick=40, range=[240, 40], tickangle=-90, type='linear', zeroline=False
|
|
473
477
|
)
|
|
474
478
|
)
|
|
@@ -48,7 +48,7 @@ def effective_porosity(phit, phi_shale, vshale):
|
|
|
48
48
|
return phie
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
def
|
|
51
|
+
def estimate_shale_porosity_trend(rho_clw: np.ndarray, rho_dry_clay: float = 2.72, rho_fluid: float = 1.0):
|
|
52
52
|
"""Calculate clay porosity given bulk density of wet clay line.
|
|
53
53
|
|
|
54
54
|
Args:
|
|
@@ -65,27 +65,20 @@ def clay_porosity(rho_clw: np.ndarray, rho_dry_clay: float = 2.72, rho_fluid: fl
|
|
|
65
65
|
return phi_clay
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
def
|
|
68
|
+
def estimate_shale_porosity(nphi, phit):
|
|
69
69
|
"""
|
|
70
|
-
Computes shale porosity from
|
|
70
|
+
Computes shale porosity from neutron porosity and total porosity.
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Shale volume [fraction].
|
|
76
|
-
phi_vsh : float
|
|
77
|
-
Total porosity of shale [fraction].
|
|
72
|
+
Args:
|
|
73
|
+
nphi (float): Neutron porosity (hydrocarbon corrected) [fraction].
|
|
74
|
+
phit (float): Total porosity [fraction].
|
|
78
75
|
|
|
79
|
-
Returns
|
|
80
|
-
|
|
81
|
-
porosity : float
|
|
82
|
-
Shale porosity [fraction].
|
|
76
|
+
Returns:
|
|
77
|
+
float: Shale porosity [fraction].
|
|
83
78
|
|
|
84
79
|
"""
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
logger.debug(f"Shale porosity range: {phi_sh.min():.3f} - {phi_sh.max():.3f}")
|
|
88
|
-
return phi_sh
|
|
80
|
+
phit_sh = nphi - phit
|
|
81
|
+
return np.where(phit_sh > 0, phit_sh, phit).clip(1e-2, 1.0)
|
|
89
82
|
|
|
90
83
|
|
|
91
84
|
def rho_matrix(vsand=0, vsilt=0, vclay=0, vcalc=0, vdolo=0, vheavy=0,
|
|
@@ -33,7 +33,7 @@ def calc_reservoir_summary(depth, vshale, phit, swt, perm, zones,
|
|
|
33
33
|
|
|
34
34
|
df = pd.DataFrame({'depth': depth, 'vshale': vshale, 'phit': phit, 'swt': swt, 'perm': perm, 'zones': zones})
|
|
35
35
|
step = df['depth'].diff().mean()
|
|
36
|
-
df['
|
|
36
|
+
df['bvhc'] = df['phit'] * (1 - df['swt'])
|
|
37
37
|
df['rock_flag'], df['reservoir_flag'], df['pay_flag'] = flag_interval(df['vshale'], df['phit'], df['swt'], cutoffs)
|
|
38
38
|
df['all_flag'] = 1
|
|
39
39
|
|
|
@@ -55,23 +55,17 @@ def calc_reservoir_summary(depth, vshale, phit, swt, perm, zones,
|
|
|
55
55
|
"vshale": lambda x: np.nanmean(x),
|
|
56
56
|
"phit": lambda x: np.nanmean(x),
|
|
57
57
|
"swt": lambda x: np.nanmean(x),
|
|
58
|
-
"
|
|
58
|
+
"bvhc": lambda x: np.nanmean(x)
|
|
59
59
|
}).reset_index()
|
|
60
60
|
avg_df['perm_am'] = flag_df.groupby('zones')['perm'].agg('mean').reset_index(drop=True)
|
|
61
61
|
avg_df['perm_gm'] = flag_df.groupby('zones')['perm'].agg(gmean, nan_policy='omit').reset_index(drop=True)
|
|
62
62
|
avg_df['perm_hm'] = flag_df.groupby('zones')['perm'].agg(hmean, nan_policy='omit').reset_index(drop=True)
|
|
63
63
|
avg_df = avg_df.rename(columns={
|
|
64
|
-
"vshale": "av_vshale", "phit": "av_phit", "swt": "av_swt", "
|
|
64
|
+
"vshale": "av_vshale", "phit": "av_phit", "swt": "av_swt", "bvhc": "av_bvhc",
|
|
65
65
|
"perm_gm": "av_perm_gm", "perm_am": "av_perm_am", "perm_hm": "av_perm_hm"
|
|
66
66
|
})
|
|
67
67
|
temp_df = temp_df.merge(avg_df, on=["zones"], how="left", validate="1:1")
|
|
68
68
|
|
|
69
|
-
# Calculate gross thickness
|
|
70
|
-
gross = df.groupby(["zones"])[["depth"]].agg(lambda x: np.nanmax(x) - np.nanmin(x)).reset_index().rename(
|
|
71
|
-
columns={"depth": "gross"})
|
|
72
|
-
temp_df = temp_df.merge(gross[["zones", 'gross']], on=["zones"], how="left", validate="1:1")
|
|
73
|
-
temp_df['ntg'] = temp_df['net'] / temp_df['gross']
|
|
74
|
-
|
|
75
69
|
# Set the maximum depth as bottom depth
|
|
76
70
|
bottom = df.groupby(["zones"])[["depth"]].agg(lambda x: np.nanmax(x)).reset_index().rename(
|
|
77
71
|
columns={"depth": "bottom"})
|
|
@@ -83,6 +77,12 @@ def calc_reservoir_summary(depth, vshale, phit, swt, perm, zones,
|
|
|
83
77
|
temp_df = temp_df.merge(top[["zones", 'top']], on=["zones"], how="left", validate="1:1")
|
|
84
78
|
temp_df['flag'] = flag
|
|
85
79
|
|
|
80
|
+
# Calculate gross thickness
|
|
81
|
+
temp_df['gross'] = temp_df['bottom'] - temp_df['top']
|
|
82
|
+
|
|
83
|
+
# Calculate net thickness
|
|
84
|
+
temp_df['ntg'] = temp_df['net'] / temp_df['gross']
|
|
85
|
+
|
|
86
86
|
# Concat to ressum_df
|
|
87
87
|
ressum_df = pd.concat([ressum_df, temp_df], ignore_index=True)
|
|
88
88
|
|
|
@@ -91,7 +91,7 @@ def calc_reservoir_summary(depth, vshale, phit, swt, perm, zones,
|
|
|
91
91
|
|
|
92
92
|
# Sort the columns
|
|
93
93
|
cols = ['zones', 'flag', 'top', 'bottom', 'gross', 'net', 'ntg',
|
|
94
|
-
'av_vshale', 'av_phit', 'av_swt', '
|
|
94
|
+
'av_vshale', 'av_phit', 'av_swt', 'av_bvhc', 'av_perm_am', 'av_perm_gm', 'av_perm_hm']
|
|
95
95
|
|
|
96
96
|
logger.debug(f"Reservoir summary calculation completed with {len(ressum_df)} summary rows")
|
|
97
97
|
return ressum_df[cols]
|
|
@@ -182,7 +182,7 @@ def plot_rfn(cpore, cperm, rock_type=None, title='Lucia RFN'):
|
|
|
182
182
|
plt.xlabel('Porosity (frac)')
|
|
183
183
|
plt.xlim(-.05, .5)
|
|
184
184
|
plt.ylabel('Permeability (mD)')
|
|
185
|
-
plt.ylim(1e-3,
|
|
185
|
+
plt.ylim(1e-3, 1e5)
|
|
186
186
|
plt.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
|
|
187
187
|
|
|
188
188
|
plt.yscale('log')
|
|
@@ -218,7 +218,7 @@ def plot_winland(cpore, cperm, cut_offs=None, rock_type=None, title='Winland R35
|
|
|
218
218
|
plt.xlabel('Porosity (frac)')
|
|
219
219
|
plt.xlim(-.05, .5)
|
|
220
220
|
plt.ylabel('Permeability (mD)')
|
|
221
|
-
plt.ylim(1e-3,
|
|
221
|
+
plt.ylim(1e-3, 1e5)
|
|
222
222
|
plt.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
|
|
223
223
|
|
|
224
224
|
plt.yscale('log')
|
|
@@ -4,7 +4,7 @@ import matplotlib.pyplot as plt
|
|
|
4
4
|
import matplotlib.ticker as ticker
|
|
5
5
|
from tqdm import tqdm
|
|
6
6
|
|
|
7
|
-
from quick_pp.utils import min_max_line
|
|
7
|
+
from quick_pp.utils import min_max_line, remove_outliers
|
|
8
8
|
from quick_pp import logger
|
|
9
9
|
|
|
10
10
|
plt.style.use('seaborn-v0_8-paper')
|
|
@@ -82,6 +82,43 @@ def waxman_smits_saturation(rt, rw, phit, Qv=None, B=None, m=2, n=2):
|
|
|
82
82
|
return swt
|
|
83
83
|
|
|
84
84
|
|
|
85
|
+
def normalized_waxman_smits_saturation(rt, rw, phit, vshale, phit_shale, rt_shale, m=2, n=2):
|
|
86
|
+
"""Estimate water saturation based on Waxman-Smits model for dispersed clay mineral.
|
|
87
|
+
Based on Ausburn, Brian E., and Robert Freedman. "The Waxman-smits Equation For Shaly Sands:
|
|
88
|
+
i. Simple Methods Of Solution
|
|
89
|
+
ii. Error Analysis." The Log Analyst 26 (1985)
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
rt (float): True resistivity or deep resistivity log.
|
|
93
|
+
rw (float): Formation water resistivity.
|
|
94
|
+
phit (float): Total porosity.
|
|
95
|
+
|
|
96
|
+
m (float): Saturation factor.
|
|
97
|
+
n (float): Cementartion factor.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
float: Water saturation.
|
|
101
|
+
"""
|
|
102
|
+
logger.debug("Calculating Normalized Waxman-Smits saturation")
|
|
103
|
+
Qvn = estimate_qvn(vclay=vshale, phit=phit, phit_clay=phit_shale)
|
|
104
|
+
B = (phit_shale**-m / rt_shale) - (1 / rw)
|
|
105
|
+
|
|
106
|
+
# Initial guess
|
|
107
|
+
swt = 1
|
|
108
|
+
swt_i = 0
|
|
109
|
+
logger.debug("Starting iterative solution for Waxman-Smits")
|
|
110
|
+
|
|
111
|
+
# Use tqdm for progress bar during iterations
|
|
112
|
+
for i in tqdm(range(50), desc="Normalized Waxman-Smits iteration"):
|
|
113
|
+
fx = swt**n / rw + Qvn * B * swt**(n - 1) - (phit**-m / rt) # Juhasz, 1981
|
|
114
|
+
delta_sat = abs(swt - swt_i) / 2
|
|
115
|
+
swt_i = swt
|
|
116
|
+
swt = np.where(fx < 0, swt + delta_sat, swt - delta_sat)
|
|
117
|
+
|
|
118
|
+
logger.debug(f"Normalized Waxman-Smits saturation range: {min(swt)} - {max(swt)}")
|
|
119
|
+
return swt
|
|
120
|
+
|
|
121
|
+
|
|
85
122
|
def dual_water_saturation(rt, rw, phit, a, m, n, swb, rwb):
|
|
86
123
|
"""Estimate water saturation based on dual water model, an extension from Waxman-Smits by Clavier, Coates and
|
|
87
124
|
Dumanoir (1977).
|
|
@@ -117,20 +154,6 @@ def dual_water_saturation(rt, rw, phit, a, m, n, swb, rwb):
|
|
|
117
154
|
return swt
|
|
118
155
|
|
|
119
156
|
|
|
120
|
-
def estimate_swb(phit, vsh, nphi_sh):
|
|
121
|
-
"""Estimate bound water saturation based on dual water model.
|
|
122
|
-
Args:
|
|
123
|
-
phit (float): Total porosity in fraction.
|
|
124
|
-
vsh (float): Volume of shale in fraction.
|
|
125
|
-
nphi_sh (float): Neutron porosity reading in a nearby 100% shale interval in fraction.
|
|
126
|
-
|
|
127
|
-
Returns:
|
|
128
|
-
float: Bound water saturation.
|
|
129
|
-
"""
|
|
130
|
-
swb = vsh * nphi_sh / phit
|
|
131
|
-
return swb
|
|
132
|
-
|
|
133
|
-
|
|
134
157
|
def indonesian_saturation(rt, rw, phie, vsh, rsh, a, m, n):
|
|
135
158
|
"""Estimate water saturation based on Indonesian model which may work well with fresh formation water.
|
|
136
159
|
Based on Poupon-Leveaux 1971.
|
|
@@ -199,6 +222,20 @@ def connectivity_saturation(rt, rw, phit, mu=2, chi_w=0):
|
|
|
199
222
|
return sw
|
|
200
223
|
|
|
201
224
|
|
|
225
|
+
def estimate_swb(phit, vsh, nphi_sh):
|
|
226
|
+
"""Estimate bound water saturation based on dual water model.
|
|
227
|
+
Args:
|
|
228
|
+
phit (float): Total porosity in fraction.
|
|
229
|
+
vsh (float): Volume of shale in fraction.
|
|
230
|
+
nphi_sh (float): Neutron porosity reading in a nearby 100% shale interval in fraction.
|
|
231
|
+
|
|
232
|
+
Returns:
|
|
233
|
+
float: Bound water saturation.
|
|
234
|
+
"""
|
|
235
|
+
swb = vsh * nphi_sh / phit
|
|
236
|
+
return swb
|
|
237
|
+
|
|
238
|
+
|
|
202
239
|
def estimate_chi_w(s_cw, phit, sigma_cw, sigma_w, mu=2):
|
|
203
240
|
"""Estimate water connectivity correction index based on connectivity model Montaron 2009
|
|
204
241
|
Args:
|
|
@@ -218,13 +255,6 @@ def estimate_chi_w(s_cw, phit, sigma_cw, sigma_w, mu=2):
|
|
|
218
255
|
return chi_w
|
|
219
256
|
|
|
220
257
|
|
|
221
|
-
def modified_simandoux_saturation():
|
|
222
|
-
""" TODO: Estimate water saturation based on modified Simandoux's model.
|
|
223
|
-
"""
|
|
224
|
-
logger.warning("Modified Simandoux saturation not implemented yet")
|
|
225
|
-
pass
|
|
226
|
-
|
|
227
|
-
|
|
228
258
|
def estimate_temperature_gradient(tvd, unit='metric'):
|
|
229
259
|
"""Estimate formation temperature based on gradient of 25 degC/km or 15 degF/1000ft.
|
|
230
260
|
|
|
@@ -246,7 +276,7 @@ def estimate_b_waxman_smits(T, rw):
|
|
|
246
276
|
|
|
247
277
|
Args:
|
|
248
278
|
T (float): Temperature in degC.
|
|
249
|
-
rw (float):
|
|
279
|
+
rw (float): Formation water resistivity in ohm.m.
|
|
250
280
|
|
|
251
281
|
Returns:
|
|
252
282
|
float: B parameter.
|
|
@@ -361,6 +391,31 @@ def estimate_rw_from_shale_trend(rt, phit, vshale, depth, m=1.3):
|
|
|
361
391
|
return rw
|
|
362
392
|
|
|
363
393
|
|
|
394
|
+
def estimate_rt_shale(rt, vshale):
|
|
395
|
+
"""Estimate resistivity of shale.
|
|
396
|
+
|
|
397
|
+
Args:
|
|
398
|
+
rt (float): True resistivity.
|
|
399
|
+
vshale (float): Volume of shale.
|
|
400
|
+
|
|
401
|
+
Returns:
|
|
402
|
+
float: Resistivity of shale.
|
|
403
|
+
"""
|
|
404
|
+
# Identify shale intervals
|
|
405
|
+
vshale = remove_outliers(vshale)
|
|
406
|
+
|
|
407
|
+
vsh_threshold = np.nanquantile(vshale, 0.5)
|
|
408
|
+
shale_mask = vshale >= vsh_threshold
|
|
409
|
+
|
|
410
|
+
# Create a series with phit values only at shale intervals
|
|
411
|
+
rt_shale = rt.where(shale_mask).rolling(31, center=True, min_periods=1).mean()
|
|
412
|
+
|
|
413
|
+
# Forward-fill and then back-fill to propagate shale porosity
|
|
414
|
+
rt_shale = rt_shale.ffill().bfill()
|
|
415
|
+
logger.debug(f"Shale porosity range: {rt_shale.min():.3f} - {rt_shale.max():.3f}")
|
|
416
|
+
return rt_shale
|
|
417
|
+
|
|
418
|
+
|
|
364
419
|
def estimate_qv(vcld, phit, rho_clay=2.65, cec_clay=.062):
|
|
365
420
|
"""Estimate Qv, cation exchange capacity per unit total pore volume (meq/cm3).
|
|
366
421
|
|
|
@@ -379,6 +434,36 @@ def estimate_qv(vcld, phit, rho_clay=2.65, cec_clay=.062):
|
|
|
379
434
|
return qv
|
|
380
435
|
|
|
381
436
|
|
|
437
|
+
def estimate_qvn(vclay, phit, phit_clay):
|
|
438
|
+
"""Estimate normalized Qv
|
|
439
|
+
|
|
440
|
+
Args:
|
|
441
|
+
vclay (float): Volume of clay in fraction
|
|
442
|
+
phit (float): Total porosity in fraction
|
|
443
|
+
phit_clay (float): Total porosity of clay in fraction
|
|
444
|
+
|
|
445
|
+
Returns:
|
|
446
|
+
float: Normalized Qv.
|
|
447
|
+
"""
|
|
448
|
+
return vclay * phit_clay / phit
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
def estimate_qv_ward(rt, phit, B, rw, m):
|
|
452
|
+
"""Estimate Qv based on B. Ward (SIPM), 1973
|
|
453
|
+
|
|
454
|
+
Args:
|
|
455
|
+
rt (float): True resistivity in ohm.m from a water-bearing zone.
|
|
456
|
+
phit (float): Total porosity in fraction.
|
|
457
|
+
B (float): Conductance parameter for Waxman-Smits.
|
|
458
|
+
rw (float): Formation water resistivity in ohm.m.
|
|
459
|
+
m (float): Cementation exponent.
|
|
460
|
+
|
|
461
|
+
Returns:
|
|
462
|
+
float: Qv in meq/cm3.
|
|
463
|
+
"""
|
|
464
|
+
return 1 / B * ((1 / (rt * phit**m)) - (1 / rw))
|
|
465
|
+
|
|
466
|
+
|
|
382
467
|
def estimate_qv_hill(vclb, phit, water_salinity=10000):
|
|
383
468
|
"""Estimating Qv based on Hill et. al, 1979.
|
|
384
469
|
|
|
@@ -413,6 +498,20 @@ def estimate_qv_lavers(phit, a=3.05e-4, b=3.49):
|
|
|
413
498
|
return qv
|
|
414
499
|
|
|
415
500
|
|
|
501
|
+
def estimate_bqv(phit, max_phit_clean_sand, C):
|
|
502
|
+
"""Estimate BQv (Bulk volume of clay bound water) based on Juhasz/ Rackley method.
|
|
503
|
+
|
|
504
|
+
Args:
|
|
505
|
+
phit (float): Total porosity.
|
|
506
|
+
max_phit_clean_sand (float): Maximum porosity of clean sand.
|
|
507
|
+
C (float): Constant depending on clay type.
|
|
508
|
+
|
|
509
|
+
Returns:
|
|
510
|
+
float: Bulk volume of clay bound water.
|
|
511
|
+
"""
|
|
512
|
+
return (max_phit_clean_sand - phit) / (C * phit)
|
|
513
|
+
|
|
514
|
+
|
|
416
515
|
def estimate_m_archie(rt, rw, phit):
|
|
417
516
|
"""Estimate apparent m (saturation factor) based on Archie's equation in water bearing zone.
|
|
418
517
|
|
|
@@ -449,6 +548,58 @@ def estimate_m_indonesian(rt, rw, phie, vsh, rsh):
|
|
|
449
548
|
return m
|
|
450
549
|
|
|
451
550
|
|
|
551
|
+
def qv_phit_xplot(phit, qv):
|
|
552
|
+
"""Generate BQV plot (Cwa vs 1/PHIT) and fit a best straight line."""
|
|
553
|
+
fig, ax = plt.subplots()
|
|
554
|
+
ax.set_title("Qv vs 1/PHIT")
|
|
555
|
+
|
|
556
|
+
# Prepare data for plotting and fitting
|
|
557
|
+
x = 1 / phit
|
|
558
|
+
y = qv
|
|
559
|
+
|
|
560
|
+
# Remove non-finite values for a clean fit
|
|
561
|
+
mask = np.isfinite(x) & np.isfinite(y)
|
|
562
|
+
ax.scatter(x[mask], y[mask], marker='.')
|
|
563
|
+
|
|
564
|
+
# Fit a straight line using np.polyfit
|
|
565
|
+
m, c = np.polyfit(x[mask], y[mask], 1)
|
|
566
|
+
ax.plot(x[mask], m * x[mask] + c, color='r', linestyle='--', label=f'y = {m:.2f}x + {c:.2f}')
|
|
567
|
+
|
|
568
|
+
ax.set_xlabel('1 / PHIT (frac)')
|
|
569
|
+
ax.set_ylabel('Qv (meq/cc)')
|
|
570
|
+
ax.legend()
|
|
571
|
+
ax.minorticks_on()
|
|
572
|
+
ax.grid(True, which='major', linestyle='--', linewidth='0.5', color='gray')
|
|
573
|
+
ax.grid(True, which='minor', linestyle=':', linewidth='0.3', color='gray')
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
def cwa_qvn_xplot(rt, phit, qvn, m=2.0, rw=.2, B=None, C=None, slope=250):
|
|
577
|
+
"""Generate Cwa vs Qvn plot."""
|
|
578
|
+
x = qvn
|
|
579
|
+
y = 1 / (rt * phit**m)
|
|
580
|
+
if len(x) != len(y):
|
|
581
|
+
logger.warning(f"Length mismatch between Qvn ({len(x)}) and Cwa ({len(y)}). Plot may be incorrect.")
|
|
582
|
+
|
|
583
|
+
fig, ax = plt.subplots()
|
|
584
|
+
ax.set_title("Cwa vs Qvn")
|
|
585
|
+
ax.scatter(x, y, marker='.')
|
|
586
|
+
|
|
587
|
+
# Add straight line
|
|
588
|
+
x_line = np.linspace(0, 1.0, len(x))
|
|
589
|
+
y_line = 1 / rw + x_line * slope
|
|
590
|
+
ax.plot(x_line, y_line, 'r--', label=f'm= {m} \nrw= {rw} \nslope= {slope}')
|
|
591
|
+
|
|
592
|
+
ax.set_xlabel('Qvn (meq/cc)')
|
|
593
|
+
ax.set_ylabel('Cwa (1 / ohm.m)')
|
|
594
|
+
ax.set_xlim(0, 1.0)
|
|
595
|
+
ax.set_ylim(0, 100)
|
|
596
|
+
ax.minorticks_on()
|
|
597
|
+
ax.grid(True)
|
|
598
|
+
fig.tight_layout()
|
|
599
|
+
ax.legend()
|
|
600
|
+
return fig
|
|
601
|
+
|
|
602
|
+
|
|
452
603
|
def swirr_xplot(swt, phit, c=.0125, label='', log_log=False, title=''):
|
|
453
604
|
"""Plot SWT vs PHIT for sand intervales only and estimate Swirr from cross plot.
|
|
454
605
|
Based on Buckles, 1965.
|
|
@@ -476,10 +627,56 @@ def swirr_xplot(swt, phit, c=.0125, label='', log_log=False, title=''):
|
|
|
476
627
|
if log_log:
|
|
477
628
|
ax.set_xscale('log')
|
|
478
629
|
ax.set_yscale('log')
|
|
630
|
+
ax.minorticks_on()
|
|
631
|
+
ax.grid(True, which='major', linestyle='--', linewidth='0.5', color='gray')
|
|
632
|
+
ax.grid(True, which='minor', linestyle=':', linewidth='0.3', color='gray')
|
|
479
633
|
fig.tight_layout()
|
|
480
634
|
logger.debug("Swirr crossplot created")
|
|
481
635
|
|
|
482
636
|
|
|
637
|
+
def rt_phit_xplot(rt, phit, m=2, rw=.01):
|
|
638
|
+
"""Generate RT vs PHIT plot.
|
|
639
|
+
|
|
640
|
+
This plot is useful for visualizing the relationship between true resistivity
|
|
641
|
+
and total porosity, often used for identifying water-bearing zones and estimating
|
|
642
|
+
formation water resistivity (Rw) and cementation exponent (m).
|
|
643
|
+
|
|
644
|
+
Args:
|
|
645
|
+
rt (float): True resistivity or deep resistivity log (ohm.m).
|
|
646
|
+
phit (float): Total porosity (fraction).
|
|
647
|
+
m (float, optional): Cementation exponent for the iso-line. Defaults to 2.
|
|
648
|
+
rw (float, optional): Formation water resistivity for the iso-line (ohm.m). Defaults to 0.01.
|
|
649
|
+
|
|
650
|
+
Returns:
|
|
651
|
+
matplotlib.figure.Figure: The RT vs PHIT plot.
|
|
652
|
+
"""
|
|
653
|
+
fig, ax = plt.subplots()
|
|
654
|
+
ax.set_title("RT vs PHIT")
|
|
655
|
+
ax.scatter(phit, rt, marker='.')
|
|
656
|
+
|
|
657
|
+
# Add iso-lines
|
|
658
|
+
phit_i = np.arange(0, 1, 1 / len(phit))
|
|
659
|
+
rt_i = phit_i**-m * rw
|
|
660
|
+
ax.plot(phit_i, rt_i, 'r--', alpha=0.5, label=f'm= {m} \nrw= {rw}')
|
|
661
|
+
|
|
662
|
+
ax.set_ylabel('RT (ohm.m)')
|
|
663
|
+
ax.set_xlabel('PHIT (frac)')
|
|
664
|
+
ax.loglog()
|
|
665
|
+
ax.set_xlim(1e-2, 1)
|
|
666
|
+
ax.set_ylim(1e-2, 1e2)
|
|
667
|
+
|
|
668
|
+
ax.minorticks_on()
|
|
669
|
+
ax.grid(True, which='major', linestyle='--', linewidth='0.5', color='gray')
|
|
670
|
+
ax.grid(True, which='minor', linestyle=':', linewidth='0.3', color='gray')
|
|
671
|
+
ax.xaxis.set_major_formatter(ticker.FuncFormatter(
|
|
672
|
+
lambda x, pos: ('{{:.{:1d}f}}'.format(int(np.maximum(-np.log10(x), 0)))).format(x)))
|
|
673
|
+
ax.yaxis.set_major_formatter(ticker.FuncFormatter(
|
|
674
|
+
lambda x, pos: ('{{:.{:1d}f}}'.format(int(np.maximum(-np.log10(x), 0)))).format(x)))
|
|
675
|
+
ax.legend()
|
|
676
|
+
fig.tight_layout()
|
|
677
|
+
return fig
|
|
678
|
+
|
|
679
|
+
|
|
483
680
|
def pickett_plot(rt, phit, m=-2, min_rw=0.1, shift=.2, title='Pickett Plot'):
|
|
484
681
|
"""Generate Pickett plot which is used to plot phit and rt at water bearing interval to determine;
|
|
485
682
|
m = The slope of best-fit line crossing the cleanest sand.
|
|
@@ -519,6 +716,9 @@ def pickett_plot(rt, phit, m=-2, min_rw=0.1, shift=.2, title='Pickett Plot'):
|
|
|
519
716
|
ax.set_xlabel('RT (ohm.m)')
|
|
520
717
|
|
|
521
718
|
ax.legend()
|
|
719
|
+
ax.minorticks_on()
|
|
720
|
+
ax.grid(True, which='major', linestyle='--', linewidth='0.5', color='gray')
|
|
721
|
+
ax.grid(True, which='minor', linestyle=':', linewidth='0.3', color='gray')
|
|
522
722
|
fig.tight_layout()
|
|
523
723
|
logger.debug("Pickett plot created")
|
|
524
724
|
|
|
@@ -413,11 +413,14 @@ def remove_straights(log, window: int = 30, threshold: float = 0.001):
|
|
|
413
413
|
|
|
414
414
|
|
|
415
415
|
def get_tvd(df, well_coords):
|
|
416
|
-
"""
|
|
416
|
+
"""Calculate true vertical depth (TVD) given well survey data.
|
|
417
417
|
|
|
418
418
|
Args:
|
|
419
|
-
df (
|
|
420
|
-
well_coords (
|
|
419
|
+
df (pd.DataFrame): Dataframe with DEPTH column.
|
|
420
|
+
well_coords (pd.DataFrame): Dataframe with md, incl and azim columns.
|
|
421
|
+
|
|
422
|
+
Returns:
|
|
423
|
+
np.array: TVD values.
|
|
421
424
|
"""
|
|
422
425
|
import wellpathpy as wpp
|
|
423
426
|
|
|
@@ -425,3 +428,22 @@ def get_tvd(df, well_coords):
|
|
|
425
428
|
# Resample the survey at the exact MD points from the log data
|
|
426
429
|
tvd = dev_survey.minimum_curvature().resample(df['DEPTH'].values).depth
|
|
427
430
|
return tvd
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
def remove_outliers(curve):
|
|
434
|
+
"""Removes outliers from a curve using the IQR method and forward fills the NaNs.
|
|
435
|
+
|
|
436
|
+
Args:
|
|
437
|
+
curve (np.array): The input curve data.
|
|
438
|
+
|
|
439
|
+
Returns:
|
|
440
|
+
np.array: The curve with outliers replaced by NaN and then forward filled.
|
|
441
|
+
"""
|
|
442
|
+
q1, q3 = np.nanquantile(curve, [0.25, 0.75])
|
|
443
|
+
iqr = q3 - q1
|
|
444
|
+
upper_bound = q3 + 1.5 * iqr
|
|
445
|
+
lower_bound = q1 - 1.5 * iqr
|
|
446
|
+
|
|
447
|
+
# Replace outliers with NaN and then forward fill
|
|
448
|
+
curve_series = pd.Series(curve)
|
|
449
|
+
return curve_series.where((curve_series >= lower_bound) & (curve_series <= upper_bound))
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
import matplotlib.pyplot as plt
|
|
3
|
-
from matplotlib.figure import Figure
|
|
4
|
-
|
|
5
|
-
def neutron_density_plot(nphi, rhob, color=None, labels=None, title=None, figsize=(8,8)):
|
|
6
|
-
"""Create a neutron-density crossplot with lithology overlay lines.
|
|
7
|
-
|
|
8
|
-
Args:
|
|
9
|
-
nphi (array-like): Neutron porosity values (v/v)
|
|
10
|
-
rhob (array-like): Bulk density values (g/cc)
|
|
11
|
-
color (array-like, optional): Color values for points
|
|
12
|
-
labels (list, optional): Labels for legend
|
|
13
|
-
title (str, optional): Plot title
|
|
14
|
-
figsize (tuple, optional): Figure size. Defaults to (8,8)
|
|
15
|
-
|
|
16
|
-
Returns:
|
|
17
|
-
matplotlib.figure.Figure: The created figure
|
|
18
|
-
"""
|
|
19
|
-
fig = Figure(figsize=figsize)
|
|
20
|
-
ax = fig.add_subplot(111)
|
|
21
|
-
|
|
22
|
-
# Plot data points
|
|
23
|
-
if color is not None:
|
|
24
|
-
scatter = ax.scatter(nphi, rhob, c=color, alpha=0.6)
|
|
25
|
-
if labels is not None:
|
|
26
|
-
fig.colorbar(scatter, label=labels)
|
|
27
|
-
else:
|
|
28
|
-
ax.scatter(nphi, rhob, alpha=0.6)
|
|
29
|
-
|
|
30
|
-
# Add lithology lines
|
|
31
|
-
# Sandstone line
|
|
32
|
-
nphi_sand = np.array([0, 0.45])
|
|
33
|
-
rhob_sand = np.array([2.65, 1.9])
|
|
34
|
-
ax.plot(nphi_sand, rhob_sand, 'r--', label='Sandstone')
|
|
35
|
-
|
|
36
|
-
# Limestone line
|
|
37
|
-
nphi_ls = np.array([0, 0.45])
|
|
38
|
-
rhob_ls = np.array([2.71, 2.0])
|
|
39
|
-
ax.plot(nphi_ls, rhob_ls, 'b--', label='Limestone')
|
|
40
|
-
|
|
41
|
-
# Dolomite line
|
|
42
|
-
nphi_dol = np.array([0, 0.45])
|
|
43
|
-
rhob_dol = np.array([2.85, 2.2])
|
|
44
|
-
ax.plot(nphi_dol, rhob_dol, 'g--', label='Dolomite')
|
|
45
|
-
|
|
46
|
-
# Customize plot
|
|
47
|
-
ax.set_xlabel('Neutron Porosity (v/v)')
|
|
48
|
-
ax.set_ylabel('Bulk Density (g/cc)')
|
|
49
|
-
ax.set_xlim(-0.05, 0.45)
|
|
50
|
-
ax.set_ylim(3.0, 1.8)
|
|
51
|
-
ax.grid(True)
|
|
52
|
-
ax.legend()
|
|
53
|
-
|
|
54
|
-
if title:
|
|
55
|
-
ax.set_title(title)
|
|
56
|
-
|
|
57
|
-
return fig
|
|
58
|
-
|
|
59
|
-
def density_pe_plot(rhob, pef, color=None, labels=None, title=None, figsize=(8,8)):
|
|
60
|
-
"""Create a density-photoelectric factor crossplot with lithology overlay.
|
|
61
|
-
|
|
62
|
-
Args:
|
|
63
|
-
rhob (array-like): Bulk density values (g/cc)
|
|
64
|
-
pef (array-like): Photoelectric factor values (barns/e-)
|
|
65
|
-
color (array-like, optional): Color values for points
|
|
66
|
-
labels (list, optional): Labels for legend
|
|
67
|
-
title (str, optional): Plot title
|
|
68
|
-
figsize (tuple, optional): Figure size. Defaults to (8,8)
|
|
69
|
-
|
|
70
|
-
Returns:
|
|
71
|
-
matplotlib.figure.Figure: The created figure
|
|
72
|
-
"""
|
|
73
|
-
fig = Figure(figsize=figsize)
|
|
74
|
-
ax = fig.add_subplot(111)
|
|
75
|
-
|
|
76
|
-
# Plot data points
|
|
77
|
-
if color is not None:
|
|
78
|
-
scatter = ax.scatter(rhob, pef, c=color, alpha=0.6)
|
|
79
|
-
if labels is not None:
|
|
80
|
-
fig.colorbar(scatter, label=labels)
|
|
81
|
-
else:
|
|
82
|
-
ax.scatter(rhob, pef, alpha=0.6)
|
|
83
|
-
|
|
84
|
-
# Add lithology points
|
|
85
|
-
minerals = {
|
|
86
|
-
'Quartz': (2.65, 1.81),
|
|
87
|
-
'Calcite': (2.71, 5.08),
|
|
88
|
-
'Dolomite': (2.85, 3.14),
|
|
89
|
-
'Anhydrite': (2.98, 5.05),
|
|
90
|
-
'Halite': (2.03, 4.65),
|
|
91
|
-
'Gypsum': (2.35, 4.0)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
for mineral, (dens, pe) in minerals.items():
|
|
95
|
-
ax.plot(dens, pe, 'r*', markersize=10, label=mineral)
|
|
96
|
-
|
|
97
|
-
# Customize plot
|
|
98
|
-
ax.set_xlabel('Bulk Density (g/cc)')
|
|
99
|
-
ax.set_ylabel('Photoelectric Factor (barns/e-)')
|
|
100
|
-
ax.set_xlim(2.0, 3.0)
|
|
101
|
-
ax.set_ylim(0, 6)
|
|
102
|
-
ax.grid(True)
|
|
103
|
-
ax.legend()
|
|
104
|
-
|
|
105
|
-
if title:
|
|
106
|
-
ax.set_title(title)
|
|
107
|
-
|
|
108
|
-
return fig
|
|
109
|
-
|
|
110
|
-
def m_n_plot(rhob, nphi, dtc, color=None, labels=None, title=None, figsize=(8,8)):
|
|
111
|
-
"""Create an M-N crossplot for lithology identification.
|
|
112
|
-
|
|
113
|
-
Args:
|
|
114
|
-
rhob (array-like): Bulk density values (g/cc)
|
|
115
|
-
nphi (array-like): Neutron porosity values (v/v)
|
|
116
|
-
dtc (array-like): Sonic transit time values (us/ft)
|
|
117
|
-
color (array-like, optional): Color values for points
|
|
118
|
-
labels (list, optional): Labels for legend
|
|
119
|
-
title (str, optional): Plot title
|
|
120
|
-
figsize (tuple, optional): Figure size. Defaults to (8,8)
|
|
121
|
-
|
|
122
|
-
Returns:
|
|
123
|
-
matplotlib.figure.Figure: The created figure
|
|
124
|
-
"""
|
|
125
|
-
# Calculate M and N values
|
|
126
|
-
# M = (dtf - dtc)/(rhob - rhof) * 0.01
|
|
127
|
-
# N = (nphi - phif)/(rhob - rhof)
|
|
128
|
-
|
|
129
|
-
dtf = 189 # fluid transit time (us/ft)
|
|
130
|
-
rhof = 1.0 # fluid density (g/cc)
|
|
131
|
-
phif = 1.0 # fluid porosity (v/v)
|
|
132
|
-
|
|
133
|
-
M = (dtf - dtc)/(rhob - rhof) * 0.01
|
|
134
|
-
N = (nphi - phif)/(rhob - rhof)
|
|
135
|
-
|
|
136
|
-
fig = Figure(figsize=figsize)
|
|
137
|
-
ax = fig.add_subplot(111)
|
|
138
|
-
|
|
139
|
-
# Plot data points
|
|
140
|
-
if color is not None:
|
|
141
|
-
scatter = ax.scatter(M, N, c=color, alpha=0.6)
|
|
142
|
-
if labels is not None:
|
|
143
|
-
fig.colorbar(scatter, label=labels)
|
|
144
|
-
else:
|
|
145
|
-
ax.scatter(M, N, alpha=0.6)
|
|
146
|
-
|
|
147
|
-
# Add mineral points
|
|
148
|
-
minerals = {
|
|
149
|
-
'Quartz': (0.80, -0.02),
|
|
150
|
-
'Calcite': (0.85, 0.03),
|
|
151
|
-
'Dolomite': (0.70, -0.01),
|
|
152
|
-
'Anhydrite': (0.65, -0.05),
|
|
153
|
-
'Gypsum': (0.75, 0.00)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
for mineral, (m, n) in minerals.items():
|
|
157
|
-
ax.plot(m, n, 'r*', markersize=10, label=mineral)
|
|
158
|
-
|
|
159
|
-
# Customize plot
|
|
160
|
-
ax.set_xlabel('M = (dtf - dtc)/(rhob - rhof) * 0.01')
|
|
161
|
-
ax.set_ylabel('N = (nphi - phif)/(rhob - rhof)')
|
|
162
|
-
ax.set_xlim(0.4, 1.0)
|
|
163
|
-
ax.set_ylim(-0.15, 0.15)
|
|
164
|
-
ax.grid(True)
|
|
165
|
-
ax.legend()
|
|
166
|
-
|
|
167
|
-
if title:
|
|
168
|
-
ax.set_title(title)
|
|
169
|
-
|
|
170
|
-
return fig
|
|
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
|