quick-pp 0.2.51__tar.gz → 0.2.53__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.
Files changed (77) hide show
  1. quick_pp-0.2.53/PKG-INFO +145 -0
  2. quick_pp-0.2.53/README.md +112 -0
  3. {quick_pp-0.2.51 → quick_pp-0.2.53}/pyproject.toml +1 -1
  4. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/__init__.py +1 -1
  5. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/machine_learning/feature_engineering.py +38 -0
  6. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/machine_learning/predict_pipeline.py +1 -1
  7. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/plotter/plotter.py +8 -24
  8. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/plotter/well_log.py +81 -0
  9. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/plotter/well_log_config.py +14 -5
  10. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/rock_physics/geophysics.py +4 -6
  11. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/rock_physics/rpm.py +70 -17
  12. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/rock_type.py +34 -1
  13. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/saturation.py +2 -1
  14. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/utils.py +17 -2
  15. quick_pp-0.2.51/PKG-INFO +0 -119
  16. quick_pp-0.2.51/README.md +0 -86
  17. {quick_pp-0.2.51 → quick_pp-0.2.53}/.gitignore +0 -0
  18. {quick_pp-0.2.51 → quick_pp-0.2.53}/LICENSE +0 -0
  19. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/__init__.py +0 -0
  20. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/exceptions.py +0 -0
  21. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/fastapi_mlflow/__init__.py +0 -0
  22. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/fastapi_mlflow/_mlflow_types.py +0 -0
  23. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/fastapi_mlflow/applications.py +0 -0
  24. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/fastapi_mlflow/exceptions.py +0 -0
  25. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/fastapi_mlflow/predictors.py +0 -0
  26. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/main.py +0 -0
  27. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/mlflow_model_deployment.py +0 -0
  28. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/router.py +0 -0
  29. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/schemas/lithology_hc_correction.py +0 -0
  30. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/schemas/lithology_ssc.py +0 -0
  31. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/schemas/lithology_vsh_gr.py +0 -0
  32. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/schemas/permeability_choo.py +0 -0
  33. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/schemas/permeability_others.py +0 -0
  34. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/schemas/porosity.py +0 -0
  35. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/schemas/ressum.py +0 -0
  36. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/schemas/saturation_archie.py +0 -0
  37. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/schemas/saturation_b.py +0 -0
  38. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/schemas/saturation_qv.py +0 -0
  39. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/schemas/saturation_rw.py +0 -0
  40. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/schemas/saturation_temp_grad.py +0 -0
  41. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/schemas/saturation_waxman_smits.py +0 -0
  42. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/services/chat.py +0 -0
  43. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/services/las_handler.py +0 -0
  44. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/services/lithology.py +0 -0
  45. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/services/permeability.py +0 -0
  46. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/services/porosity.py +0 -0
  47. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/services/reservoir_summary.py +0 -0
  48. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/services/saturation.py +0 -0
  49. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/static/favicon.ico +0 -0
  50. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/static/logo.png +0 -0
  51. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/template/chat.html +0 -0
  52. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/api/template/home.html +0 -0
  53. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/cli.py +0 -0
  54. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/config.py +0 -0
  55. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/core_calibration.py +0 -0
  56. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/fluid_type.py +0 -0
  57. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/las_handler.py +0 -0
  58. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/lithology/__init__.py +0 -0
  59. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/lithology/carbonate.py +0 -0
  60. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/lithology/multi_mineral.py +0 -0
  61. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/lithology/sand_shale.py +0 -0
  62. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/lithology/sand_silt_clay.py +0 -0
  63. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/lithology/thin_beds.py +0 -0
  64. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/machine_learning/__init__.py +0 -0
  65. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/machine_learning/config.py +0 -0
  66. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/machine_learning/mock_data/mock_data.parquet +0 -0
  67. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/machine_learning/train_pipeline.py +0 -0
  68. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/machine_learning/utils.py +0 -0
  69. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/objects.py +0 -0
  70. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/permeability.py +0 -0
  71. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/plotter/__init__.py +0 -0
  72. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/plotter/xplots.py +0 -0
  73. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/porosity.py +0 -0
  74. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/qaqc.py +0 -0
  75. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/ressum.py +0 -0
  76. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/rock_physics/__init__.py +0 -0
  77. {quick_pp-0.2.51 → quick_pp-0.2.53}/quick_pp/rock_physics/geomechanics.py +0 -0
@@ -0,0 +1,145 @@
1
+ Metadata-Version: 2.4
2
+ Name: quick-pp
3
+ Version: 0.2.53
4
+ Summary: Python package to assist in providing quick-look/ preliminary petrophysical estimation.
5
+ Project-URL: Homepage, https://github.com/imranfadhil/quick_pp
6
+ Author-email: Imran Fadhil <imranfadhil@gmail.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Keywords: analysis,geoscience,log,petrophysics,quick_pp,well
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Natural Language :: English
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Requires-Python: >=3.11
16
+ Requires-Dist: click>=7.0
17
+ Requires-Dist: fastapi
18
+ Requires-Dist: loguru
19
+ Requires-Dist: matplotlib==3.8.0
20
+ Requires-Dist: mlflow
21
+ Requires-Dist: orjson
22
+ Requires-Dist: pandas
23
+ Requires-Dist: psycopg2-binary
24
+ Requires-Dist: ptitprince
25
+ Requires-Dist: python-multipart
26
+ Requires-Dist: ruptures
27
+ Requires-Dist: salib==1.5.1
28
+ Requires-Dist: scikit-learn
29
+ Requires-Dist: setuptools<81
30
+ Requires-Dist: statsmodels
31
+ Requires-Dist: welly
32
+ Description-Content-Type: text/markdown
33
+
34
+ # quick_pp
35
+
36
+ A Python package for quick-look preliminary petrophysical estimations.
37
+
38
+ ![quick_pp demo](docs/static/quick_pp_demo.gif)
39
+
40
+ ## Installation
41
+
42
+ You can install `quick_pp` directly from PyPI:
43
+
44
+ ```bash
45
+ pip install quick_pp
46
+ ```
47
+
48
+ For development or to use the `qpp_assistant`, you'll need to clone the repository and install dependencies:
49
+
50
+ 1. **Clone the repository:**
51
+ ```bash
52
+ git clone https://github.com/imranfadhil/quick_pp.git
53
+ cd quick_pp
54
+ ```
55
+
56
+ 2. **Create and activate a virtual environment** (tested with Python 3.11):
57
+ ```bash
58
+ uv venv --python 3.11
59
+ source .venv/bin/activate # On Windows, use: .venv\Scripts\activate
60
+ ```
61
+
62
+ 3. **Install the required packages:**
63
+ ```bash
64
+ uv pip install -r requirements.txt
65
+ ```
66
+
67
+ ## Quick Start
68
+
69
+ ### Jupyter Notebook Examples
70
+
71
+ The included notebooks demonstrate the core functionalities:
72
+
73
+ - `01_data_handler`: Create a MOCK `qppp` project file.
74
+ - `02_EDA`: Perform a quick exploratory data analysis.
75
+ - `03_*`: Carry out petrophysical interpretation of the MOCK wells.
76
+
77
+ > **Note:** For the API notebook, you need to run `python main.py app` before executing the cells.
78
+
79
+ ### `qpp_assistant` Setup
80
+
81
+ To use the `qpp_assistant`, follow these steps after the development installation:
82
+
83
+ 1. Specify the required credentials in a `.env` file (you can use `.env copy` as a template).
84
+ 2. Run Docker Compose: `docker-compose up -d`.
85
+ 3. Build your flow in Langflow at `http://localhost:7860`.
86
+ 4. Run the main application: `python main.py app`.
87
+ 5. Test your flow in the qpp Assistant at `http://localhost:8888/qpp_assistant`.
88
+
89
+ ## CLI
90
+
91
+ ### Train a Machine Learning Model
92
+
93
+ **Requirements:**
94
+ - The input data must be a Parquet file located at `/data/input/<data_hash>___.parquet`.
95
+ - The Parquet file must contain the input and target features as specified in `MODELLING_CONFIG` in `config.py`.
96
+
97
+ **Command:**
98
+
99
+ > quick_pp train <model_config> <data_hash>
100
+
101
+ quick_pp train mock mock
102
+
103
+ ### Run the MLflow Server
104
+
105
+ **Command:**
106
+ ```bash
107
+ quick_pp mlflow-server
108
+ ```
109
+ You can access the MLflow UI at `http://localhost:5015`.
110
+
111
+ ### Run Predictions
112
+
113
+ > **Note:** Trained models must be registered in MLflow before running predictions.
114
+
115
+ > quick_pp predict <model_config> <data_hash>
116
+
117
+ **Example:**
118
+ ```bash
119
+ quick_pp predict mock mock
120
+ ```
121
+
122
+ ### Deploy Trained Models as an API
123
+
124
+ ```bash
125
+ quick_pp model-deployment
126
+ ```
127
+ You can access the deployed model's Swagger UI at `http://localhost:5555/docs`.
128
+
129
+ ### Start the Main Application
130
+
131
+ ```bash
132
+ quick_pp app
133
+ ```
134
+ - **API Docs:** `http://localhost:8888/docs`
135
+ - **qpp_assistant:** `http://localhost:8888/qpp_assistant` (you can log in with any username and password).
136
+
137
+ To use the mcp tools, you would need to first add the following SSE URLS through the interface;
138
+ http://localhost:8888/mcp - quick_pp tools.
139
+
140
+ http://localhost:5555/mcp - quick_pp ML model prediction tools (need to run `quick_pp model-deployment` first).
141
+
142
+ ## Documentation
143
+
144
+ Documentation is available at:
145
+ <https://quick-pp.readthedocs.io/en/latest/index.html>
@@ -0,0 +1,112 @@
1
+ # quick_pp
2
+
3
+ A Python package for quick-look preliminary petrophysical estimations.
4
+
5
+ ![quick_pp demo](docs/static/quick_pp_demo.gif)
6
+
7
+ ## Installation
8
+
9
+ You can install `quick_pp` directly from PyPI:
10
+
11
+ ```bash
12
+ pip install quick_pp
13
+ ```
14
+
15
+ For development or to use the `qpp_assistant`, you'll need to clone the repository and install dependencies:
16
+
17
+ 1. **Clone the repository:**
18
+ ```bash
19
+ git clone https://github.com/imranfadhil/quick_pp.git
20
+ cd quick_pp
21
+ ```
22
+
23
+ 2. **Create and activate a virtual environment** (tested with Python 3.11):
24
+ ```bash
25
+ uv venv --python 3.11
26
+ source .venv/bin/activate # On Windows, use: .venv\Scripts\activate
27
+ ```
28
+
29
+ 3. **Install the required packages:**
30
+ ```bash
31
+ uv pip install -r requirements.txt
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ### Jupyter Notebook Examples
37
+
38
+ The included notebooks demonstrate the core functionalities:
39
+
40
+ - `01_data_handler`: Create a MOCK `qppp` project file.
41
+ - `02_EDA`: Perform a quick exploratory data analysis.
42
+ - `03_*`: Carry out petrophysical interpretation of the MOCK wells.
43
+
44
+ > **Note:** For the API notebook, you need to run `python main.py app` before executing the cells.
45
+
46
+ ### `qpp_assistant` Setup
47
+
48
+ To use the `qpp_assistant`, follow these steps after the development installation:
49
+
50
+ 1. Specify the required credentials in a `.env` file (you can use `.env copy` as a template).
51
+ 2. Run Docker Compose: `docker-compose up -d`.
52
+ 3. Build your flow in Langflow at `http://localhost:7860`.
53
+ 4. Run the main application: `python main.py app`.
54
+ 5. Test your flow in the qpp Assistant at `http://localhost:8888/qpp_assistant`.
55
+
56
+ ## CLI
57
+
58
+ ### Train a Machine Learning Model
59
+
60
+ **Requirements:**
61
+ - The input data must be a Parquet file located at `/data/input/<data_hash>___.parquet`.
62
+ - The Parquet file must contain the input and target features as specified in `MODELLING_CONFIG` in `config.py`.
63
+
64
+ **Command:**
65
+
66
+ > quick_pp train <model_config> <data_hash>
67
+
68
+ quick_pp train mock mock
69
+
70
+ ### Run the MLflow Server
71
+
72
+ **Command:**
73
+ ```bash
74
+ quick_pp mlflow-server
75
+ ```
76
+ You can access the MLflow UI at `http://localhost:5015`.
77
+
78
+ ### Run Predictions
79
+
80
+ > **Note:** Trained models must be registered in MLflow before running predictions.
81
+
82
+ > quick_pp predict <model_config> <data_hash>
83
+
84
+ **Example:**
85
+ ```bash
86
+ quick_pp predict mock mock
87
+ ```
88
+
89
+ ### Deploy Trained Models as an API
90
+
91
+ ```bash
92
+ quick_pp model-deployment
93
+ ```
94
+ You can access the deployed model's Swagger UI at `http://localhost:5555/docs`.
95
+
96
+ ### Start the Main Application
97
+
98
+ ```bash
99
+ quick_pp app
100
+ ```
101
+ - **API Docs:** `http://localhost:8888/docs`
102
+ - **qpp_assistant:** `http://localhost:8888/qpp_assistant` (you can log in with any username and password).
103
+
104
+ To use the mcp tools, you would need to first add the following SSE URLS through the interface;
105
+ http://localhost:8888/mcp - quick_pp tools.
106
+
107
+ http://localhost:5555/mcp - quick_pp ML model prediction tools (need to run `quick_pp model-deployment` first).
108
+
109
+ ## Documentation
110
+
111
+ Documentation is available at:
112
+ <https://quick-pp.readthedocs.io/en/latest/index.html>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "quick-pp"
7
- version = "0.2.51"
7
+ version = "0.2.53"
8
8
  description = "Python package to assist in providing quick-look/ preliminary petrophysical estimation."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -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.5' # Need to be updated manually when releasing a new version/ change in pyproject.toml
23
+ __version__ = '0.2.53' # Need to be updated manually when releasing a new version/ change in pyproject.toml
@@ -99,6 +99,42 @@ def coal_flagging(nphi, rhob, rhob_threshold=2.0, nphi_threshold=0.3, window_siz
99
99
  return (trend_condition & threshold_condition).astype(float)
100
100
 
101
101
 
102
+ def tight_streak_flagging(rhob, rt, rhob_threshold=2.5, rt_threshold=2, window_size=15, trend_factor=0.03):
103
+ """Flag tight streak intervals based on high RHOB, high RT, and low NPHI.
104
+
105
+ Tight streaks (e.g., carbonate cemented layers) are characterized by high
106
+ bulk density, high resistivity, and low porosity. This function flags
107
+ these zones by identifying points where log values deviate significantly
108
+ from their local trend, in addition to crossing absolute thresholds.
109
+
110
+ Args:
111
+ rhob (pd.Series): Bulk density log (g/cm³).
112
+ rt (pd.Series): True resistivity log (ohm.m).
113
+ rhob_threshold (float, optional): RHOB threshold for tight streak. Defaults to 2.5.
114
+ rt_threshold (float, optional): RT threshold for tight streak. Defaults to 50.
115
+ window_size (int, optional): The size of the rolling window for trend calculation. Defaults to 21.
116
+ trend_factor (float, optional): A factor to control sensitivity to trend deviation.
117
+ Defaults to 0.05 (5%).
118
+
119
+ Returns:
120
+ pd.Series: A series of floats (0.0 or 1.0), 1.0 where a tight streak is flagged.
121
+ """
122
+ # Calculate rolling averages to establish local trends
123
+ rhob_trend = rhob.rolling(window=window_size, center=True, min_periods=1).mean()
124
+ rt_trend = rt.rolling(window=window_size, center=True, min_periods=1).mean()
125
+
126
+ # Flag where RHOB/RT are significantly above trend and NPHI is significantly below trend
127
+ trend_condition = (
128
+ (rhob > rhob_trend * (1 + trend_factor)) &
129
+ (rt > rt_trend * (1 + trend_factor))
130
+ )
131
+
132
+ # Flag where values cross absolute thresholds
133
+ threshold_condition = ((rhob > rhob_threshold) & (rt > rt_threshold))
134
+
135
+ return (trend_condition & threshold_condition).astype(float)
136
+
137
+
102
138
  def generate_fe_features(df):
103
139
  """Generate feature engineered features from the raw features.
104
140
 
@@ -115,6 +151,8 @@ def generate_fe_features(df):
115
151
  tqdm.write(f'Processing well {well_name}')
116
152
  well_df = well_df.sort_values('DEPTH').copy()
117
153
 
154
+ df.loc[well_df.index, 'TIGHT_FLAG'] = tight_streak_flagging(well_df['RHOB'], well_df['RT'])
155
+
118
156
  df.loc[well_df.index, 'COAL_FLAG'] = coal_flagging(well_df['NPHI'], well_df['RHOB'])
119
157
 
120
158
  rhob_mask = well_df['RHOB'].notna()
@@ -139,7 +139,7 @@ def predict_pipeline(
139
139
 
140
140
  # Merge specific columns from original data missing from pred_df
141
141
  merge_cols = ['WELL_NAME', 'DEPTH']
142
- missing_cols = ['ROCK_FLAG', 'COAL_FLAG']
142
+ missing_cols = ['ROCK_FLAG', 'COAL_FLAG', 'TIGHT_FLAG']
143
143
  pred_df = pd.merge(pred_df, data[merge_cols + missing_cols], on=merge_cols, how='left')
144
144
 
145
145
  # Postprocess the predictions and save
@@ -18,7 +18,6 @@ plt.rcParams.update(
18
18
 
19
19
 
20
20
  def update_fluid_contacts(well_data, well_config: dict):
21
- logger.debug(f"Updating fluid contacts for well with config: {well_config}")
22
21
  """Update fluid flags based on fluid contacts.
23
22
 
24
23
  Args:
@@ -58,7 +57,6 @@ def update_fluid_contacts(well_data, well_config: dict):
58
57
 
59
58
 
60
59
  def generate_zone_config(zones: list = ['ALL']):
61
- logger.info(f"Generating zone config for zones: {zones}")
62
60
  """Generate zone configuration.
63
61
 
64
62
  Args:
@@ -67,6 +65,7 @@ def generate_zone_config(zones: list = ['ALL']):
67
65
  Returns:
68
66
  dict: Zone configuration
69
67
  """
68
+ logger.info(f"Generating zone config for zones: {zones}")
70
69
  zone_config = {}
71
70
  for zone in zones:
72
71
  zone_config[zone] = {
@@ -76,7 +75,6 @@ def generate_zone_config(zones: list = ['ALL']):
76
75
 
77
76
 
78
77
  def update_zone_config(zone_config: dict, zone: str, fluid_contacts: dict):
79
- logger.info(f"Updating zone config for zone: {zone} with contacts: {fluid_contacts}")
80
78
  """Update zone configuration with fluid contacts.
81
79
 
82
80
  Args:
@@ -87,6 +85,7 @@ def update_zone_config(zone_config: dict, zone: str, fluid_contacts: dict):
87
85
  Returns:
88
86
  dict: Updated zone configuration
89
87
  """
88
+ logger.info(f"Updating zone config for zone: {zone} with contacts: {fluid_contacts}")
90
89
  if zone in zone_config:
91
90
  zone_config[zone].update(fluid_contacts)
92
91
  else:
@@ -95,7 +94,6 @@ def update_zone_config(zone_config: dict, zone: str, fluid_contacts: dict):
95
94
 
96
95
 
97
96
  def generate_well_config(well_names: list = ['X']):
98
- logger.info(f"Generating well config for wells: {well_names}")
99
97
  """Generate well configuration.
100
98
 
101
99
  Args:
@@ -104,6 +102,7 @@ def generate_well_config(well_names: list = ['X']):
104
102
  Returns:
105
103
  dict: Well configuration
106
104
  """
105
+ logger.info(f"Generating well config for wells: {well_names}")
107
106
  well_config = {}
108
107
  for i, well in enumerate(well_names):
109
108
  well_config[well] = {
@@ -115,9 +114,7 @@ def generate_well_config(well_names: list = ['X']):
115
114
  return well_config
116
115
 
117
116
 
118
- def update_well_config(
119
- well_config: dict, well_name: str, zone: str = '', fluid_contacts: dict = {}, sorting: int = 0):
120
- logger.info(f"Updating well config for well: {well_name}, zone: {zone}, sorting: {sorting}")
117
+ def update_well_config(well_config: dict, well_name: str, zone: str = '', fluid_contacts: dict = {}, sorting: int = 0):
121
118
  """Update well configuration with fluid contacts.
122
119
 
123
120
  Args:
@@ -130,6 +127,7 @@ def update_well_config(
130
127
  Returns:
131
128
  dict: Updated well configuration
132
129
  """
130
+ logger.info(f"Updating well config for well: {well_name}, zone: {zone}, sorting: {sorting}")
133
131
  if zone in well_config[well_name]['zones']:
134
132
  well_config[well_name]['zones'][zone].update(fluid_contacts)
135
133
  elif zone:
@@ -141,12 +139,12 @@ def update_well_config(
141
139
 
142
140
 
143
141
  def assert_well_config_structure(well_config):
144
- logger.debug("Asserting well config structure.")
145
142
  """Assert well configuration structure.
146
143
 
147
144
  Args:
148
145
  well_config (dict): Dictionary containing well sorting and fluid contacts.
149
146
  """
147
+ logger.debug("Asserting well config structure.")
150
148
  required_keys = {'sorting', 'zones'}
151
149
  optional_keys = {'GUT', 'GDT', 'GOC', 'GWC', 'OUT', 'ODT', 'OWC', 'WUT'}
152
150
  for well, config in well_config.items():
@@ -160,7 +158,6 @@ def assert_well_config_structure(well_config):
160
158
 
161
159
 
162
160
  def stick_plot(data, well_config: dict, zone: str = 'ALL'):
163
- logger.info(f"Generating stick plot for zone: {zone}")
164
161
  """Generate stick plot with water saturation and fluid contacts for specified zone.
165
162
 
166
163
  Example of well_config:
@@ -188,6 +185,7 @@ def stick_plot(data, well_config: dict, zone: str = 'ALL'):
188
185
  data (pandas.DataFrame): Pandas dataframe containing well log data.
189
186
  well_config (dict): Dictionary containing well sorting and fluid contacts.
190
187
  """
188
+ logger.info(f"Generating stick plot for zone: {zone}")
191
189
  assert 'SWT' in data.columns, 'SWT column not found in data.'
192
190
  assert_well_config_structure(well_config)
193
191
 
@@ -235,7 +233,6 @@ def neutron_density_xplot(nphi, rhob,
235
233
  fluid_point: tuple = (1.0, 1.0),
236
234
  wet_clay_point: tuple = (),
237
235
  dry_silt_point: tuple = (), **kwargs):
238
- logger.info("Generating neutron-density crossplot.")
239
236
  """Neutron-Density crossplot with lithology lines based on specified end points.
240
237
 
241
238
  Args:
@@ -250,6 +247,7 @@ def neutron_density_xplot(nphi, rhob,
250
247
  Returns:
251
248
  matplotlib.pyplot.Figure: Neutron porosity and bulk density cross plot.
252
249
  """
250
+ logger.info("Generating neutron-density crossplot.")
253
251
  A = dry_min1_point
254
252
  C = dry_clay_point
255
253
  D = fluid_point
@@ -299,17 +297,3 @@ def neutron_density_xplot(nphi, rhob,
299
297
  fig.tight_layout()
300
298
 
301
299
  return fig
302
-
303
-
304
- def sonic_density_xplot():
305
- logger.info("Called sonic_density_xplot (not implemented)")
306
- """ TODO: Implement sonic density crossplot
307
- """
308
- pass
309
-
310
-
311
- def sonic_neutron_xplot():
312
- logger.info("Called sonic_neutron_xplot (not implemented)")
313
- """ TODO: Implement sonic neutron crossplot
314
- """
315
- pass
@@ -8,6 +8,25 @@ from quick_pp.plotter.well_log_config import COLOR_DICT, TRACE_DEFS, XAXIS_DEFS
8
8
 
9
9
  # --- Helper to add traces from trace_defs ---
10
10
  def add_defined_traces(fig, df, index, no_of_track, trace_defs, **kwargs):
11
+ """Adds traces to the figure based on a definitions dictionary.
12
+
13
+ Args:
14
+ fig (plotly.graph_objects.Figure): The Plotly figure to add traces to.
15
+ df (pd.DataFrame): The DataFrame containing the log data.
16
+ index (pd.Series): The depth index for the y-axis.
17
+ no_of_track (int): The total number of tracks in the plot.
18
+ trace_defs (dict): A dictionary defining the traces to be plotted.
19
+ **kwargs: Additional keyword arguments to pass to `go.Scatter`.
20
+
21
+ Returns:
22
+ plotly.graph_objects.Figure: The figure with the added traces.
23
+
24
+ Notes:
25
+ - Skips 'COAL_FLAG' and 'ZONES' as they are handled separately.
26
+ - Updates trace styles from `trace_defs`.
27
+ - Manages x-axis visibility for overlapping traces.
28
+
29
+ """
11
30
  trace_ix = 0
12
31
  for col, trace_def in trace_defs.items():
13
32
  # Skip special cases handled separately
@@ -37,6 +56,20 @@ def add_defined_traces(fig, df, index, no_of_track, trace_defs, **kwargs):
37
56
 
38
57
 
39
58
  def add_crossover_traces(df):
59
+ """Calculates and adds gas crossover shading traces to the DataFrame.
60
+
61
+ If 'NPHI' and 'RHOB' are present, this function calculates the region
62
+ where neutron porosity crosses over bulk density, indicating potential
63
+ gas zones. It adds 'RHOB_ON_NPHI_SCALE', 'GAS_XOVER_TOP', and
64
+ 'GAS_XOVER_BOTTOM' columns to the DataFrame for plotting.
65
+
66
+ Args:
67
+ df (pd.DataFrame): The DataFrame containing log data.
68
+
69
+ Returns:
70
+ pd.DataFrame: The DataFrame with added crossover-related columns.
71
+
72
+ """
40
73
  if 'NPHI' in df.columns and 'RHOB' in df.columns and 'NPHI_XOVER_BOTTOM' not in df.columns:
41
74
  rhob_min, rhob_max = 1.95, 2.95
42
75
  nphi_min_scale, nphi_max_scale = 0.45, -0.15
@@ -54,6 +87,20 @@ def add_crossover_traces(df):
54
87
 
55
88
 
56
89
  def add_rock_flag_traces(df):
90
+ """Prepares rock flag data for plotting by one-hot encoding.
91
+
92
+ If a 'ROCK_FLAG' column exists, this function:
93
+ 1. Converts it to integer type.
94
+ 2. Assigns a unique color to each flag value in `COLOR_DICT`.
95
+ 3. One-hot encodes the 'ROCK_FLAG' column into separate 'ROCK_FLAG_X' columns.
96
+
97
+ Args:
98
+ df (pd.DataFrame): The DataFrame containing log data.
99
+
100
+ Returns:
101
+ pd.DataFrame: The DataFrame with one-hot encoded rock flag columns.
102
+
103
+ """
57
104
  if 'ROCK_FLAG' in df.columns:
58
105
  # Add ROCK_FLAG colors
59
106
  df['ROCK_FLAG'] = df['ROCK_FLAG'].fillna(0).astype(int)
@@ -75,6 +122,17 @@ def add_rock_flag_traces(df):
75
122
 
76
123
 
77
124
  def fix_missing_volumetrics(df):
125
+ """Ensures standard volumetric columns exist in the DataFrame.
126
+
127
+ Iterates through a predefined list of volumetric curve names. If a column
128
+ exists, it fills missing values with 0. If it doesn't exist, it is not added.
129
+
130
+ Args:
131
+ df (pd.DataFrame): The DataFrame containing log data.
132
+
133
+ Returns:
134
+ pd.DataFrame: The DataFrame with NaNs filled in volumetric columns.
135
+ """
78
136
  volumetrics = ['VCLAY', 'VSILT', 'VSAND', 'VCALC', 'VDOLO', 'VGAS', 'VOIL', 'VHC']
79
137
  for col in volumetrics:
80
138
  df[col] = df[col].fillna(0) if col in df.columns else None
@@ -82,6 +140,18 @@ def fix_missing_volumetrics(df):
82
140
 
83
141
 
84
142
  def fix_missing_depths(df):
143
+ """Resamples the DataFrame to a regular depth interval.
144
+
145
+ This function ensures the DataFrame has a consistent depth step by
146
+ creating a complete depth range and merging the original data onto it.
147
+ This prevents gaps in the final plot.
148
+
149
+ Args:
150
+ df (pd.DataFrame): The DataFrame containing log data with a 'DEPTH' column.
151
+
152
+ Returns:
153
+ pd.DataFrame: A resampled DataFrame with consistent depth steps.
154
+ """
85
155
  depth_min = df['DEPTH'].min()
86
156
  depth_max = df['DEPTH'].max()
87
157
  depth_step = df['DEPTH'].diff().mode()[0].round(4) # Most common depth step
@@ -206,6 +276,17 @@ def plotly_log(well_data, well_name: str = '', depth_uom="", trace_defs: dict =
206
276
  )
207
277
 
208
278
  def add_zone_markers(fig, df):
279
+ """Adds horizontal lines and labels for formation tops.
280
+
281
+ If a 'ZONES' column is present, this function identifies changes in
282
+ the zone names and adds a horizontal line and a text annotation to the
283
+ plot for each formation top.
284
+
285
+ Args:
286
+ fig (plotly.graph_objects.Figure): The figure to add markers to.
287
+ df (pd.DataFrame): The DataFrame containing 'DEPTH' and 'ZONES' columns.
288
+
289
+ """
209
290
  if 'ZONES' in df.columns:
210
291
  tops_df = df[['DEPTH', 'ZONES']].dropna().reset_index()
211
292
  if not tops_df.empty and sum([1 for c in tops_df.ZONES.unique() if 'ZONE_' in c]) < 30:
@@ -166,8 +166,8 @@ TRACE_DEFS = dict(
166
166
  BADHOLE=dict(
167
167
  track=1,
168
168
  secondary_y=False,
169
- hide_xaxis=True,
170
- style={'fill': 'tozerox', 'fillcolor': 'rgba(0, 0, 0, .25)'}
169
+ hide_xaxis=False,
170
+ style={'line_width': 0, 'fill': 'tozerox', 'fillcolor': 'rgba(0, 0, 0, .15)'}
171
171
  ),
172
172
  VSILT=dict(
173
173
  track=8,
@@ -308,6 +308,12 @@ TRACE_DEFS = dict(
308
308
  'fillcolor': 'rgba(98, 180, 207, .5)'
309
309
  }
310
310
  ),
311
+ TIGHT_FLAG=dict(
312
+ track=8,
313
+ secondary_y=False,
314
+ hide_xaxis=False,
315
+ style={'line_width': 0, 'fill': 'tozerox', 'fillcolor': '#0000A0'}
316
+ ),
311
317
  )
312
318
 
313
319
  # Centralize axis definitions for maintainability
@@ -341,7 +347,7 @@ XAXIS_DEFS = dict(
341
347
  title={'text': 'PERM (mD)', 'font': {'color': COLOR_DICT['PERM'], 'size': font_size}},
342
348
  tickfont={'color': COLOR_DICT['PERM'], 'size': font_size},
343
349
  side='top', anchor='free', position=.91, title_standoff=.1,
344
- range=[np.log10(0.1), np.log10(10000)], type='log', tickformat='d', tickangle=-90,
350
+ range=[np.log10(0.1), np.log10(1e5)], type='log', tickformat='d', tickangle=-90,
345
351
  minor_showgrid=True
346
352
  ),
347
353
  SWT=dict(
@@ -414,7 +420,7 @@ XAXIS_DEFS = dict(
414
420
  title={'text': 'BADHOLE', 'font': {'color': COLOR_DICT['BADHOLE'], 'size': font_size}},
415
421
  tickfont={'size': 1},
416
422
  side='top', anchor='free', position=.96, title_standoff=.1, overlaying='x1',
417
- range=[0.1, 5], type='linear', showgrid=False, zeroline=False
423
+ range=[0.1, 4], type='linear', showgrid=False, zeroline=False
418
424
  ),
419
425
  PEF=dict(
420
426
  title={'text': 'PEF', 'font': {'color': COLOR_DICT['PEF'], 'size': font_size}},
@@ -432,7 +438,7 @@ XAXIS_DEFS = dict(
432
438
  title={'text': 'CPERM (mD)', 'font': {'color': COLOR_DICT['CPERM'], 'size': font_size}},
433
439
  tickfont={'color': COLOR_DICT['CPERM'], 'size': font_size},
434
440
  side='top', anchor='free', position=.85, title_standoff=.1, overlaying='x5',
435
- range=[np.log10(0.1), np.log10(10000)], type='log', tickformat='d', tickangle=-90,
441
+ range=[np.log10(0.1), np.log10(1e5)], type='log', tickformat='d', tickangle=-90,
436
442
  zeroline=False, showgrid=False
437
443
  ),
438
444
  SHF=dict(
@@ -450,6 +456,9 @@ XAXIS_DEFS = dict(
450
456
  COAL_FLAG=dict(
451
457
  range=[.1, .2], type='linear', showgrid=False, zeroline=False,
452
458
  ),
459
+ TIGHT_FLAG=dict(
460
+ range=[.1, .2], type='linear', showgrid=False, zeroline=False, overlaying='x8'
461
+ ),
453
462
  DTC=dict(
454
463
  title={'text': 'DTC (us/ft)', 'font': {'color': COLOR_DICT['DTC'], 'size': font_size}},
455
464
  tickfont={'color': COLOR_DICT['DTC'], 'size': font_size},
@@ -1,6 +1,5 @@
1
1
  import numpy as np
2
2
  import pandas as pd
3
- import xarray as xr
4
3
  import matplotlib.pyplot as plt
5
4
  from scipy.optimize import minimize
6
5
  from scipy.signal import convolve, hilbert
@@ -175,11 +174,8 @@ def convert_md_to_tvd(df, well_coords):
175
174
  Returns:
176
175
  pandas.DataFrame: DataFrame with TVD column added.
177
176
  """
178
- dev_survey = wpp.deviation(
179
- well_coords['md'], well_coords['incl'], well_coords['azim']
180
- )
181
- md_range = np.arange(df.DEPTH.min(), df.DEPTH.max(), df.DEPTH.diff().mode()[0])
182
- df['TVD'] = dev_survey.minimum_curvature().resample(md_range).depth
177
+ dev_survey = wpp.deviation(md=well_coords['md'], inc=well_coords['incl'], azi=well_coords['azim'])
178
+ df['TVD'] = dev_survey.minimum_curvature().resample(df.DEPTH.values).depth
183
179
 
184
180
  # Get list of columns to resample
185
181
  numeric_cols = df.select_dtypes(include=np.number).columns.tolist()
@@ -238,6 +234,8 @@ def convert_well_trajectory_to_ilxl(seismic_cube, well_trajectory):
238
234
  seismic_cube (xarray.Dataset): 3D seismic cube with coordinates (inline, xline, twt/depth)
239
235
  well_trajectory (pandas.DataFrame): Well trajectory with columns for X,Y coordinates and depth/time
240
236
  """
237
+ import xarray as xr
238
+
241
239
  # Scale the coordinates if required
242
240
  try:
243
241
  seismic_cube.segysak.scale_coords()