quick-pp 0.2.70__tar.gz → 0.2.71__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. {quick_pp-0.2.70 → quick_pp-0.2.71}/PKG-INFO +3 -3
  2. {quick_pp-0.2.70 → quick_pp-0.2.71}/pyproject.toml +6 -5
  3. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/__init__.py +1 -1
  4. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/core_calibration.py +77 -64
  5. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/lithology/sand_shale.py +4 -3
  6. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/plotter/well_log_config.py +3 -3
  7. quick_pp-0.2.71/quick_pp/saturation.py +927 -0
  8. quick_pp-0.2.70/quick_pp/saturation.py +0 -792
  9. {quick_pp-0.2.70 → quick_pp-0.2.71}/.gitignore +0 -0
  10. {quick_pp-0.2.70 → quick_pp-0.2.71}/LICENSE +0 -0
  11. {quick_pp-0.2.70 → quick_pp-0.2.71}/README.md +0 -0
  12. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/__init__.py +0 -0
  13. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/exceptions.py +0 -0
  14. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/fastapi_mlflow/__init__.py +0 -0
  15. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/fastapi_mlflow/_mlflow_types.py +0 -0
  16. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/fastapi_mlflow/applications.py +0 -0
  17. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/fastapi_mlflow/exceptions.py +0 -0
  18. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/fastapi_mlflow/predictors.py +0 -0
  19. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/main.py +0 -0
  20. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/mlflow_model_deployment.py +0 -0
  21. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/router.py +0 -0
  22. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/schemas/lithology_hc_correction.py +0 -0
  23. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/schemas/lithology_ssc.py +0 -0
  24. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/schemas/lithology_vsh_gr.py +0 -0
  25. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/schemas/permeability_choo.py +0 -0
  26. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/schemas/permeability_others.py +0 -0
  27. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/schemas/porosity.py +0 -0
  28. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/schemas/ressum.py +0 -0
  29. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/schemas/saturation_archie.py +0 -0
  30. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/schemas/saturation_b.py +0 -0
  31. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/schemas/saturation_qv.py +0 -0
  32. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/schemas/saturation_rw.py +0 -0
  33. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/schemas/saturation_temp_grad.py +0 -0
  34. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/schemas/saturation_waxman_smits.py +0 -0
  35. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/services/chat.py +0 -0
  36. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/services/las_handler.py +0 -0
  37. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/services/lithology.py +0 -0
  38. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/services/permeability.py +0 -0
  39. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/services/porosity.py +0 -0
  40. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/services/reservoir_summary.py +0 -0
  41. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/services/saturation.py +0 -0
  42. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/static/favicon.ico +0 -0
  43. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/static/logo.png +0 -0
  44. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/template/chat.html +0 -0
  45. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/api/template/home.html +0 -0
  46. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/cli.py +0 -0
  47. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/config.py +0 -0
  48. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/database/__init__.py +0 -0
  49. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/database/db_connector.py +0 -0
  50. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/database/models.py +0 -0
  51. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/database/objects.py +0 -0
  52. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/database/setup_postgresql_db.sql +0 -0
  53. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/database/setup_sqlite_db.sql +0 -0
  54. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/fluid_type.py +0 -0
  55. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/las_handler.py +0 -0
  56. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/lithology/__init__.py +0 -0
  57. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/lithology/carbonate.py +0 -0
  58. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/lithology/multi_mineral.py +0 -0
  59. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/lithology/sand_silt_clay.py +0 -0
  60. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/lithology/thin_beds.py +0 -0
  61. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/machine_learning/__init__.py +0 -0
  62. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/machine_learning/config.py +0 -0
  63. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/machine_learning/feature_engineering.py +0 -0
  64. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/machine_learning/mock_data/mock_data.parquet +0 -0
  65. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/machine_learning/predict_pipeline.py +0 -0
  66. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/machine_learning/train_pipeline.py +0 -0
  67. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/machine_learning/utils.py +0 -0
  68. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/permeability.py +0 -0
  69. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/plotter/__init__.py +0 -0
  70. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/plotter/plotter.py +0 -0
  71. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/plotter/well_log.py +0 -0
  72. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/porosity.py +0 -0
  73. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/qaqc.py +0 -0
  74. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/ressum.py +0 -0
  75. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/rock_physics/__init__.py +0 -0
  76. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/rock_physics/geomechanics.py +0 -0
  77. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/rock_physics/geophysics.py +0 -0
  78. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/rock_physics/rpm.py +0 -0
  79. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/rock_type.py +0 -0
  80. {quick_pp-0.2.70 → quick_pp-0.2.71}/quick_pp/utils.py +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quick-pp
3
- Version: 0.2.70
4
- Summary: Python package to assist in providing quick-look/ preliminary petrophysical estimation.
3
+ Version: 0.2.71
4
+ Summary: Python package to assist in providing quick-look preliminary petrophysical estimation.
5
5
  Project-URL: Homepage, https://github.com/imranfadhil/quick_pp
6
6
  Author-email: Imran Fadhil <imranfadhil@gmail.com>
7
7
  License-Expression: MIT
8
8
  License-File: LICENSE
9
- Keywords: analysis,geoscience,log,petrophysics,quick_pp,well
9
+ Keywords: geoscience,multi mineral,petrophysics,quick_pp,rock typing,saturation height function,shf,well log,well plot
10
10
  Classifier: Development Status :: 2 - Pre-Alpha
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: License :: OSI Approved :: MIT License
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "quick-pp"
7
- version = "0.2.70"
8
- description = "Python package to assist in providing quick-look/ preliminary petrophysical estimation."
7
+ version = "0.2.71"
8
+ description = "Python package to assist in providing quick-look preliminary petrophysical estimation."
9
9
  readme = "README.md"
10
10
  license = "MIT"
11
11
  requires-python = ">=3.11"
@@ -13,12 +13,13 @@ authors = [
13
13
  { name = "Imran Fadhil", email = "imranfadhil@gmail.com" },
14
14
  ]
15
15
  keywords = [
16
- "analysis",
17
16
  "geoscience",
18
- "log",
19
17
  "petrophysics",
18
+ "well log", "well plot",
20
19
  "quick_pp",
21
- "well",
20
+ "multi mineral",
21
+ "rock typing",
22
+ "saturation height function", "shf",
22
23
  ]
23
24
  classifiers = [
24
25
  "Development Status :: 2 - Pre-Alpha",
@@ -20,4 +20,4 @@ logging.getLogger("mlflow").setLevel(logging.WARNING)
20
20
 
21
21
  __author__ = """Imran Fadhil"""
22
22
  __email__ = 'imranfadhil@gmail.com'
23
- __version__ = '0.2.70' # Need to be updated manually when releasing a new version/ change in pyproject.toml
23
+ __version__ = '0.2.71' # Need to be updated manually when releasing a new version/ change in pyproject.toml
@@ -438,18 +438,20 @@ def autocorrelate_core_depth(df):
438
438
  and 'DEPTH_SHIFT'.
439
439
  """
440
440
  from dtw import dtw
441
+ from sklearn.preprocessing import minmax_scale
441
442
  required_cols = ['WELL_NAME', 'DEPTH', 'PHIT', 'CPORE', 'CPERM', 'CORE_ID']
442
443
  for col in required_cols:
443
444
  if col not in df.columns:
444
445
  raise AssertionError(f"Missing required column: {col}")
445
446
 
447
+ all_wells_data = []
446
448
  shift_summaries = []
447
- return_df = pd.DataFrame()
449
+
448
450
  for well, data in tqdm(df.groupby('WELL_NAME'), desc='Correlating core depths'):
449
451
  core_data = data[['DEPTH', 'CORE_ID', 'CPORE', 'CPERM']].dropna().sort_values('DEPTH').reset_index(drop=True)
450
452
 
451
453
  if core_data.empty:
452
- return_df = pd.concat([return_df, data])
454
+ all_wells_data.append(data)
453
455
  continue
454
456
 
455
457
  log_data = data[['DEPTH', 'PHIT']].dropna().sort_values('DEPTH').reset_index(drop=True)
@@ -457,74 +459,85 @@ def autocorrelate_core_depth(df):
457
459
 
458
460
  # Create a window of log data around core points to speed up DTW
459
461
  core_indices_in_log = np.searchsorted(log_data.DEPTH, core_data.DEPTH, side='left')
460
- window = 1
462
+ window = 50 # Increased window size to allow for larger shifts
461
463
  window_indices = core_indices_in_log[:, None] + np.arange(-window, window + 1)
462
464
  window_indices = np.clip(window_indices, 0, len(log_data) - 1)
463
465
  unique_indices = np.unique(window_indices.flatten())
464
466
  log_data_subset = log_data.iloc[unique_indices].reset_index(drop=True)
465
467
 
466
- # Extract the numpy arrays for the DTW algorithm
467
- phit_vals = log_data_subset['PHIT'].values
468
- cpore_vals = core_data['CPORE'].values
469
-
470
- alignment = dtw(cpore_vals, phit_vals,
471
- distance_only=False,
472
- keep_internals=True,
473
- step_pattern="symmetric2")
474
-
475
- # The alignment object contains the mapping between indices
476
- core_indices = alignment.index1 # Indices for the `core_data` DataFrame
477
- log_indices = alignment.index2 # Indices for the `log_data_subset` DataFrame
478
-
479
- # Create a detailed map from the alignment
480
- correction_map_df = pd.DataFrame({
481
- 'ORIGINAL_DEPTH': core_data.loc[core_indices, 'DEPTH'].values,
482
- 'CORE_ID_SHIFTED': core_data.loc[core_indices, 'CORE_ID'].values,
483
- 'CPORE_SHIFTED': core_data.loc[core_indices, 'CPORE'].values,
484
- 'CPERM_SHIFTED': core_data.loc[core_indices, 'CPERM'].values,
485
- 'MATCHED_PHIT': log_data_subset.loc[log_indices, 'PHIT'].values,
486
- 'DEPTH_CORRECTED': log_data_subset.loc[log_indices, 'DEPTH'].values
468
+ # Extract numpy arrays for DTW
469
+ phit_vals = minmax_scale(log_data_subset['PHIT'].values)
470
+ cpore_vals = minmax_scale(core_data['CPORE'].values)
471
+
472
+ alignment = dtw(cpore_vals, phit_vals, keep_internals=True, step_pattern="symmetric2")
473
+
474
+ # Map alignment indices back to original data
475
+ core_indices = alignment.index1
476
+ log_subset_indices = alignment.index2
477
+
478
+ original_depths = core_data.loc[core_indices, 'DEPTH'].values
479
+ corrected_depths = log_data_subset.loc[log_subset_indices, 'DEPTH'].values
480
+
481
+ # Calculate the shift for each point in the DTW path
482
+ depth_shifts = corrected_depths - original_depths
483
+
484
+ # Determine the single best shift for the entire core sequence (using the median for robustness)
485
+ if len(depth_shifts) > 0:
486
+ best_shift = round(np.median(depth_shifts), 4)
487
+ else:
488
+ best_shift = 0.0
489
+
490
+ tqdm.write(f"Determined best shift for {well}: {best_shift:.2f}")
491
+
492
+ # Apply the consistent shift to all original core data for this well
493
+ shifted_core_data = core_data.copy()
494
+ shifted_core_data['DEPTH_CORRECTED'] = shifted_core_data['DEPTH'] + best_shift
495
+ shifted_core_data['DEPTH_SHIFT'] = best_shift
496
+
497
+ # Create summary for this well
498
+ summary = shifted_core_data[['CORE_ID', 'DEPTH', 'DEPTH_CORRECTED', 'DEPTH_SHIFT']].copy()
499
+ summary.rename(columns={'DEPTH': 'ORIGINAL_DEPTH'}, inplace=True)
500
+ summary['WELL_NAME'] = well
501
+ summary = summary[['WELL_NAME', 'CORE_ID', 'ORIGINAL_DEPTH', 'DEPTH_CORRECTED', 'DEPTH_SHIFT']]
502
+ shift_summaries.append(summary)
503
+
504
+ # Prepare shifted data for merging
505
+ final_shifted = shifted_core_data.rename(columns={
506
+ 'CPORE': 'CPORE_SHIFTED',
507
+ 'CPERM': 'CPERM_SHIFTED',
508
+ 'CORE_ID': 'CORE_ID_SHIFTED'
487
509
  })
488
510
 
489
- # Find the best match for each original core depth by minimizing porosity difference
490
- correction_map_df['PORO_DIFF'] = (correction_map_df['CPORE_SHIFTED'] - correction_map_df['MATCHED_PHIT']).abs()
491
- correction_map_df['DEPTH_SHIFT'] = round(
492
- correction_map_df.DEPTH_CORRECTED - correction_map_df.ORIGINAL_DEPTH, 3)
493
- best_matches = correction_map_df.sort_values('PORO_DIFF').drop_duplicates('ORIGINAL_DEPTH')
494
-
495
- if not best_matches.empty:
496
- summary = best_matches[['CORE_ID_SHIFTED', 'ORIGINAL_DEPTH', 'DEPTH_CORRECTED', 'DEPTH_SHIFT']].copy()
497
- summary.rename(columns={'CORE_ID_SHIFTED': 'CORE_ID'}, inplace=True)
498
- summary['WELL_NAME'] = well
499
- # Reorder columns for clarity
500
- summary = summary[['WELL_NAME', 'CORE_ID', 'ORIGINAL_DEPTH', 'DEPTH_CORRECTED', 'DEPTH_SHIFT']]
501
- shift_summaries.append(summary)
502
-
503
- # Merge the corrected core data back into the original well data
504
- df_corrected = pd.merge(
505
- data,
506
- best_matches[['DEPTH_CORRECTED', 'CORE_ID_SHIFTED', 'CPORE_SHIFTED', 'CPERM_SHIFTED']],
507
- left_on='DEPTH',
508
- right_on='DEPTH_CORRECTED',
509
- how='left'
510
- )
511
-
512
- # Remove original depths if being corrected
513
- ori_core_ids = df_corrected['CORE_ID'].dropna().unique()
514
- shifted_core_ids = df_corrected['CORE_ID_SHIFTED'].dropna().unique()
515
-
516
- mask_shifted = df_corrected['CORE_ID'].isin(shifted_core_ids)
517
- mask_ori = df_corrected['CORE_ID_SHIFTED'].isin(ori_core_ids)
518
-
519
- df_corrected.loc[mask_shifted, ['CORE_ID', 'CPORE', 'CPERM']] = np.nan
520
- df_corrected.loc[mask_ori, ['CORE_ID', 'CPORE', 'CPERM']] = df_corrected.loc[
521
- mask_ori, ['CORE_ID_SHIFTED', 'CPORE_SHIFTED', 'CPERM_SHIFTED']].values
522
-
523
- return_df = pd.concat([return_df, df_corrected])
524
-
525
- # After the loop, combine all summaries into a single DataFrame
526
- final_summary_df = pd.DataFrame()
527
- if shift_summaries:
528
- final_summary_df = pd.concat(shift_summaries, ignore_index=True)
511
+ # --- SOLUTION: Use index-based merging to avoid column conflicts ---
512
+
513
+ # Prepare the log data: keep only necessary columns and set DEPTH as index
514
+ log_df_to_merge = data.set_index('DEPTH')
515
+
516
+ # Prepare the shifted core data: keep shifted values and set corrected depth as index
517
+ core_df_to_merge = final_shifted[['DEPTH_CORRECTED', 'CPORE_SHIFTED', 'CPERM_SHIFTED', 'CORE_ID_SHIFTED']] \
518
+ .set_index('DEPTH_CORRECTED')
519
+
520
+ # Merge the two dataframes on their indices (which are the depths)
521
+ well_corrected_df = pd.merge(
522
+ log_df_to_merge,
523
+ core_df_to_merge,
524
+ left_index=True,
525
+ right_index=True,
526
+ how='outer'
527
+ ).reset_index()
528
+
529
+ # The merged 'index' column is the unified depth column, so rename it
530
+ well_corrected_df.rename(columns={'index': 'DEPTH'}, inplace=True)
531
+
532
+ # Sort by the final unified depth
533
+ well_corrected_df.sort_values('DEPTH', inplace=True)
534
+
535
+ # Add well name back if lost during merge
536
+ well_corrected_df['WELL_NAME'] = well
537
+ all_wells_data.append(well_corrected_df)
538
+
539
+ # Combine all processed well data and summaries
540
+ return_df = pd.concat(all_wells_data, ignore_index=True)
541
+ final_summary_df = pd.concat(shift_summaries, ignore_index=True) if shift_summaries else pd.DataFrame()
529
542
 
530
543
  return return_df, final_summary_df
@@ -96,9 +96,10 @@ class SandShale:
96
96
  for i, point in enumerate(E):
97
97
  var_pt = line_intersection((A, C), (D, point))
98
98
  projlithofrac = length_a_b(var_pt, A)
99
- vshale = projlithofrac / rocklithofrac
100
- vsand = np.append(vsand, (1 - vshale))
101
- vcld = np.append(vcld, vshale)
99
+ sand_frac = projlithofrac / rocklithofrac
100
+ sand_frac = 0 if var_pt[0] > C[0] else sand_frac
101
+ vsand = np.append(vsand, sand_frac)
102
+ vcld = np.append(vcld, 1 - sand_frac)
102
103
 
103
104
  logger.debug(f"Lithology fraction calculation completed for {len(vsand)} points")
104
105
  return vsand, vcld
@@ -3,9 +3,9 @@ import numpy as np
3
3
 
4
4
  COLOR_DICT = {
5
5
  'BADHOLE': 'rgba(0, 0, 0, .25)',
6
- 'BS': 'brown',
6
+ 'BS': 'black',
7
7
  'BVW': "#B7EDFF",
8
- 'CALI': '#618F63',
8
+ 'CALI': 'brown',
9
9
  'COAL_FLAG': '#262626',
10
10
  'CPERM': '#FF0000',
11
11
  'CPORE': '#FF0000',
@@ -157,7 +157,7 @@ TRACE_DEFS = dict(
157
157
  hide_xaxis=False,
158
158
  style={
159
159
  'line_dash': 'dot', 'line_width': 1, 'line_color': COLOR_DICT['CALI'], 'fill': 'tozerox',
160
- 'fillcolor': 'rgba(165, 42, 42, .15)'
160
+ 'fillcolor': "#FF880020"
161
161
  }
162
162
  ),
163
163
  BS=dict(