quick-pp 0.2.72__tar.gz → 0.2.74__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 (79) hide show
  1. {quick_pp-0.2.72 → quick_pp-0.2.74}/PKG-INFO +1 -1
  2. {quick_pp-0.2.72 → quick_pp-0.2.74}/pyproject.toml +1 -1
  3. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/__init__.py +3 -3
  4. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/core_calibration.py +170 -91
  5. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/lithology/sand_shale.py +1 -1
  6. {quick_pp-0.2.72 → quick_pp-0.2.74}/.gitignore +0 -0
  7. {quick_pp-0.2.72 → quick_pp-0.2.74}/LICENSE +0 -0
  8. {quick_pp-0.2.72 → quick_pp-0.2.74}/README.md +0 -0
  9. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/__init__.py +0 -0
  10. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/exceptions.py +0 -0
  11. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/fastapi_mlflow/__init__.py +0 -0
  12. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/fastapi_mlflow/_mlflow_types.py +0 -0
  13. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/fastapi_mlflow/applications.py +0 -0
  14. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/fastapi_mlflow/exceptions.py +0 -0
  15. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/fastapi_mlflow/predictors.py +0 -0
  16. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/main.py +0 -0
  17. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/mlflow_model_deployment.py +0 -0
  18. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/router.py +0 -0
  19. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/schemas/lithology_hc_correction.py +0 -0
  20. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/schemas/lithology_ssc.py +0 -0
  21. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/schemas/lithology_vsh_gr.py +0 -0
  22. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/schemas/permeability_choo.py +0 -0
  23. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/schemas/permeability_others.py +0 -0
  24. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/schemas/porosity.py +0 -0
  25. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/schemas/ressum.py +0 -0
  26. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/schemas/saturation_archie.py +0 -0
  27. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/schemas/saturation_b.py +0 -0
  28. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/schemas/saturation_qv.py +0 -0
  29. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/schemas/saturation_rw.py +0 -0
  30. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/schemas/saturation_temp_grad.py +0 -0
  31. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/schemas/saturation_waxman_smits.py +0 -0
  32. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/services/chat.py +0 -0
  33. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/services/las_handler.py +0 -0
  34. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/services/lithology.py +0 -0
  35. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/services/permeability.py +0 -0
  36. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/services/porosity.py +0 -0
  37. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/services/reservoir_summary.py +0 -0
  38. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/services/saturation.py +0 -0
  39. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/static/favicon.ico +0 -0
  40. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/static/logo.png +0 -0
  41. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/template/chat.html +0 -0
  42. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/api/template/home.html +0 -0
  43. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/cli.py +0 -0
  44. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/config.py +0 -0
  45. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/database/__init__.py +0 -0
  46. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/database/db_connector.py +0 -0
  47. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/database/models.py +0 -0
  48. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/database/objects.py +0 -0
  49. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/database/setup_postgresql_db.sql +0 -0
  50. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/database/setup_sqlite_db.sql +0 -0
  51. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/fluid_type.py +0 -0
  52. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/las_handler.py +0 -0
  53. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/lithology/__init__.py +0 -0
  54. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/lithology/carbonate.py +0 -0
  55. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/lithology/multi_mineral.py +0 -0
  56. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/lithology/sand_silt_clay.py +0 -0
  57. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/lithology/thin_beds.py +0 -0
  58. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/machine_learning/__init__.py +0 -0
  59. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/machine_learning/config.py +0 -0
  60. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/machine_learning/feature_engineering.py +0 -0
  61. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/machine_learning/mock_data/mock_data.parquet +0 -0
  62. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/machine_learning/predict_pipeline.py +0 -0
  63. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/machine_learning/train_pipeline.py +0 -0
  64. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/machine_learning/utils.py +0 -0
  65. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/permeability.py +0 -0
  66. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/plotter/__init__.py +0 -0
  67. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/plotter/plotter.py +0 -0
  68. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/plotter/well_log.py +0 -0
  69. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/plotter/well_log_config.py +0 -0
  70. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/porosity.py +0 -0
  71. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/qaqc.py +0 -0
  72. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/ressum.py +0 -0
  73. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/rock_physics/__init__.py +0 -0
  74. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/rock_physics/geomechanics.py +0 -0
  75. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/rock_physics/geophysics.py +0 -0
  76. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/rock_physics/rpm.py +0 -0
  77. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/rock_type.py +0 -0
  78. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/saturation.py +0 -0
  79. {quick_pp-0.2.72 → quick_pp-0.2.74}/quick_pp/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quick-pp
3
- Version: 0.2.72
3
+ Version: 0.2.74
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>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "quick-pp"
7
- version = "0.2.72"
7
+ version = "0.2.74"
8
8
  description = "Python package to assist in providing quick-look preliminary petrophysical estimation."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -11,7 +11,7 @@ logger.add(
11
11
  colorize=True,
12
12
  format="<green>[{time:YYYY-MM-DD HH:mm:ss}]</green> <level>{level: <8}</level> | <cyan>{name}</cyan> | "
13
13
  "<level>{message}</level>",
14
- level="INFO"
14
+ level="INFO",
15
15
  )
16
16
 
17
17
  # Silence overly verbose loggers from dependencies (if needed, using stdlib logging)
@@ -19,5 +19,5 @@ logging.getLogger("matplotlib").setLevel(logging.WARNING)
19
19
  logging.getLogger("mlflow").setLevel(logging.WARNING)
20
20
 
21
21
  __author__ = """Imran Fadhil"""
22
- __email__ = 'imranfadhil@gmail.com'
23
- __version__ = '0.2.72' # Need to be updated manually when releasing a new version/ change in pyproject.toml
22
+ __email__ = "imranfadhil@gmail.com"
23
+ __version__ = "0.2.74" # Need to be updated manually when releasing a new version/ change in pyproject.toml
@@ -9,18 +9,16 @@ from quick_pp.utils import power_law_func, inv_power_law_func
9
9
  from quick_pp import logger
10
10
 
11
11
 
12
- plt.style.use('seaborn-v0_8-paper')
12
+ plt.style.use("seaborn-v0_8-paper")
13
13
  plt.rcParams.update(
14
- {
15
- 'axes.labelsize': 10,
16
- 'xtick.labelsize': 10,
17
- 'legend.fontsize': 'small'
18
- }
14
+ {"axes.labelsize": 10, "xtick.labelsize": 10, "legend.fontsize": "small"}
19
15
  )
20
16
 
21
17
 
22
18
  # Cross plots
23
- def poroperm_xplot(poro, perm, a=None, b=None, core_group=None, label='', log_log=False):
19
+ def poroperm_xplot(
20
+ poro, perm, a=None, b=None, core_group=None, label="", log_log=False
21
+ ):
24
22
  """Generate porosity-permeability cross plot.
25
23
 
26
24
  Args:
@@ -32,7 +30,7 @@ def poroperm_xplot(poro, perm, a=None, b=None, core_group=None, label='', log_lo
32
30
  label (str, optional): Label for the data group. Defaults to ''.
33
31
  log_log (bool, optional): Whether to plot log-log or not. Defaults to False.
34
32
  """
35
- sc = plt.scatter(poro, perm, marker='.', c=core_group, cmap='Set1')
33
+ sc = plt.scatter(poro, perm, marker=".", c=core_group, cmap="Set1")
36
34
  if core_group is not None:
37
35
  for i, row in enumerate(zip(poro, perm, core_group)):
38
36
  plt.annotate(row[2], (row[0], row[1]), fontsize=8, alpha=0.7)
@@ -40,15 +38,21 @@ def poroperm_xplot(poro, perm, a=None, b=None, core_group=None, label='', log_lo
40
38
  line_color = sc.get_facecolors()[0]
41
39
  line_color[-1] = 0.5
42
40
  cpore = np.geomspace(0.01, 0.5, 30)
43
- plt.plot(cpore, power_law_func(cpore, a, b), color=line_color, label=label, linestyle='dashed')
41
+ plt.plot(
42
+ cpore,
43
+ power_law_func(cpore, a, b),
44
+ color=line_color,
45
+ label=label,
46
+ linestyle="dashed",
47
+ )
44
48
  plt.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
45
- plt.xlabel('CPORE (frac)')
49
+ plt.xlabel("CPORE (frac)")
46
50
  plt.xlim(0.001, 0.5)
47
- plt.ylabel('CPERM (mD)')
48
- plt.ylim(.001, 1e5)
49
- plt.yscale('log')
51
+ plt.ylabel("CPERM (mD)")
52
+ plt.ylim(0.001, 1e5)
53
+ plt.yscale("log")
50
54
  if log_log:
51
- plt.xscale('log')
55
+ plt.xscale("log")
52
56
 
53
57
 
54
58
  def bvw_xplot(bvw, pc, a=None, b=None, label=None, ylim=None, log_log=False):
@@ -63,19 +67,21 @@ def bvw_xplot(bvw, pc, a=None, b=None, label=None, ylim=None, log_log=False):
63
67
  ylim (tuple, optional): Range for the y axis in (min, max) format. Defaults to None.
64
68
  log_log (bool, optional): Whether to plot log-log or not. Defaults to False.
65
69
  """
66
- sc = plt.plot(bvw, pc, marker='s', label=label)
70
+ sc = plt.plot(bvw, pc, marker="s", label=label)
67
71
  if a is not None and b is not None:
68
- line_color = sc[0].get_color() + '66' # Set opacity to 0
72
+ line_color = sc[0].get_color() + "66" # Set opacity to 0
69
73
  cbvw = np.linspace(0.05, 0.35, 30)
70
- plt.scatter(cbvw, inv_power_law_func(cbvw, a, b), marker='x', color=line_color)
71
- plt.xlabel('BVW (frac)')
72
- plt.ylabel('Pc (psi)')
73
- plt.ylim(ylim) if ylim else plt.ylim(0.01, plt.gca().get_lines()[-1].get_ydata().max())
74
+ plt.scatter(cbvw, inv_power_law_func(cbvw, a, b), marker="x", color=line_color)
75
+ plt.xlabel("BVW (frac)")
76
+ plt.ylabel("Pc (psi)")
77
+ plt.ylim(ylim) if ylim else plt.ylim(
78
+ 0.01, plt.gca().get_lines()[-1].get_ydata().max()
79
+ )
74
80
  if label:
75
81
  plt.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
76
82
  if log_log:
77
- plt.xscale('log')
78
- plt.yscale('log')
83
+ plt.xscale("log")
84
+ plt.yscale("log")
79
85
 
80
86
 
81
87
  def pc_xplot(sw, pc, label=None, ylim=None):
@@ -90,11 +96,13 @@ def pc_xplot(sw, pc, label=None, ylim=None):
90
96
  ylim (tuple, optional): Range for the y axis in (min, max) format. Defaults to None.
91
97
  log_log (bool, optional): Whether to plot log-log or not. Defaults to False.
92
98
  """
93
- plt.plot(sw, pc, marker='.', label=label)
94
- plt.xlabel('Sw (frac)')
99
+ plt.plot(sw, pc, marker=".", label=label)
100
+ plt.xlabel("Sw (frac)")
95
101
  plt.xlim(0.01, 1)
96
- plt.ylabel('Pc (psi)')
97
- plt.ylim(ylim) if ylim else plt.ylim(0.01, plt.gca().get_lines()[-1].get_ydata().max())
102
+ plt.ylabel("Pc (psi)")
103
+ plt.ylim(ylim) if ylim else plt.ylim(
104
+ 0.01, plt.gca().get_lines()[-1].get_ydata().max()
105
+ )
98
106
  if label:
99
107
  plt.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
100
108
 
@@ -110,18 +118,28 @@ def pc_xplot_plotly(sw, pc, label=None, ylim=None, fig=go.Figure()):
110
118
  """
111
119
  fig.add_trace(go.Scatter(x=sw, y=pc, name=label))
112
120
  fig.update_layout(
113
- xaxis_title='Sw (frac)',
114
- yaxis_title='Pc (psi)',
121
+ xaxis_title="Sw (frac)",
122
+ yaxis_title="Pc (psi)",
115
123
  xaxis_range=[0, 1],
116
124
  yaxis_range=[0, 50] if ylim is None else [ylim[0], ylim[1]],
117
- legend=dict(x=1.04, y=1, traceorder='normal'),
125
+ legend=dict(x=1.04, y=1, traceorder="normal"),
118
126
  height=500,
119
- width=800
127
+ width=800,
120
128
  )
121
129
  return fig
122
130
 
123
131
 
124
- def j_xplot(sw, j, a=None, b=None, core_group=None, label=None, log_log=False, ax=None, ylim=None):
132
+ def j_xplot(
133
+ sw,
134
+ j,
135
+ a=None,
136
+ b=None,
137
+ core_group=None,
138
+ label=None,
139
+ log_log=False,
140
+ ax=None,
141
+ ylim=None,
142
+ ):
125
143
  """Generate J-Sw cross plot.
126
144
 
127
145
  Args:
@@ -129,26 +147,51 @@ def j_xplot(sw, j, a=None, b=None, core_group=None, label=None, log_log=False, a
129
147
  j (float): Calculated J value (unitless).
130
148
  a (float, optional): a constant in j=a*sw^b. Defaults to None.
131
149
  b (float, optional): b constant in j=a*sw^b. Defaults to None.
150
+ core_group (array-like, optional): Grouping for core samples to be used for coloring. Defaults to None.
132
151
  label (str, optional): Label for the data group. Defaults to ''.
133
152
  ylim (tuple, optional): Range for the y axis in (min, max) format. Defaults to None.
134
153
  log_log (bool, optional): Whether to plot log-log or not. Defaults to False.
135
154
  """
136
155
  ax = ax or plt.gca()
137
- scatter = ax.scatter(sw, j, marker='.', c=core_group, cmap='Set1')
156
+
138
157
  if core_group is not None:
139
- legend1 = ax.legend(*scatter.legend_elements(), title="Core Sample")
140
- ax.add_artist(legend1)
158
+ # Check if core_group contains non-numeric data
159
+ if any(isinstance(item, str) for item in core_group):
160
+ color_data, uniques = pd.factorize(core_group)
161
+ scatter = ax.scatter(sw, j, marker=".", c=color_data, cmap="Set1")
162
+ legend1 = ax.legend(
163
+ handles=scatter.legend_elements()[0],
164
+ labels=uniques.tolist(),
165
+ title="Core Sample",
166
+ bbox_to_anchor=(1.04, 0.9),
167
+ loc="upper left",
168
+ )
169
+ ax.add_artist(legend1)
170
+ else:
171
+ scatter = ax.scatter(sw, j, marker=".", c=core_group, cmap="Set1")
172
+ legend1 = ax.legend(
173
+ *scatter.legend_elements(),
174
+ title="Core Sample",
175
+ bbox_to_anchor=(1.04, 0.9),
176
+ loc="upper left",
177
+ )
178
+ ax.add_artist(legend1)
179
+ else:
180
+ ax.scatter(sw, j, marker=".")
181
+
141
182
  if a is not None and b is not None:
142
183
  csw = np.geomspace(0.01, 1.0, 20)
143
- ax.plot(csw, inv_power_law_func(csw, a, b), label=label, linestyle='dashed')
144
- ax.set_xlabel('Sw (frac)')
184
+ ax.plot(csw, inv_power_law_func(csw, a, b), label=label, linestyle="dashed")
185
+ ax.set_xlabel("Sw (frac)")
145
186
  ax.set_xlim(0.01, 1)
146
- ax.set_ylabel('J')
147
- ax.set_ylim(ylim) if ylim else ax.set_ylim(0.01, max(ax.get_lines()[-1].get_ydata()))
187
+ ax.set_ylabel("J")
188
+ ax.set_ylim(ylim) if ylim else ax.set_ylim(
189
+ 0.01, max(ax.get_lines()[-1].get_ydata())
190
+ )
148
191
  if log_log:
149
- ax.set_yscale('log')
192
+ ax.set_yscale("log")
150
193
  ax.set_ylim(0.01, 100)
151
- ax.set_xscale('log')
194
+ ax.set_xscale("log")
152
195
  if label:
153
196
  ax.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
154
197
  return ax
@@ -166,7 +209,7 @@ def fit_j_curve(sw, j):
166
209
  tuple: a and b constants from the best-fit curve.
167
210
  """
168
211
  try:
169
- popt, _ = curve_fit(inv_power_law_func, sw, j, p0=[.01, 1])
212
+ popt, _ = curve_fit(inv_power_law_func, sw, j, p0=[0.01, 1])
170
213
  a = [round(c, 3) for c in popt][0]
171
214
  b = [round(c, 3) for c in popt][1]
172
215
  return a, b
@@ -175,7 +218,9 @@ def fit_j_curve(sw, j):
175
218
  return 1, 1
176
219
 
177
220
 
178
- def skelt_harrison_xplot(sw, pc, gw, ghc, a, b, c, d, core_group=None, label=None, ylim=None, ax=None):
221
+ def skelt_harrison_xplot(
222
+ sw, pc, gw, ghc, a, b, c, d, core_group=None, label=None, ylim=None, ax=None
223
+ ):
179
224
  """Generate Skelt-Harrison curve.
180
225
 
181
226
  Args:
@@ -188,13 +233,15 @@ def skelt_harrison_xplot(sw, pc, gw, ghc, a, b, c, d, core_group=None, label=Non
188
233
  d (float): d constant from the best-fit curve. Related to entry pressure.
189
234
  """
190
235
  ax = ax or plt.gca()
191
- ax.scatter(sw, pc, marker='.', c=core_group, cmap='Set1')
192
- h = np.geomspace(.01, 10000, 100)
193
- pci = h * (gw - ghc) * .433 # Convert g/cc to psi/ft
236
+ ax.scatter(sw, pc, marker=".", c=core_group, cmap="Set1")
237
+ h = np.geomspace(0.01, 10000, 100)
238
+ pci = h * (gw - ghc) * 0.433 # Convert g/cc to psi/ft
194
239
  ax.plot(skelt_harrison_func(h, a, b, c, d), pci, label=label)
195
- ax.set_ylabel('Pc (psi)')
196
- ax.set_ylim(ylim) if ylim else ax.set_ylim(0.01, ax.get_lines()[-1].get_ydata().max())
197
- ax.set_xlabel('Sw (frac)')
240
+ ax.set_ylabel("Pc (psi)")
241
+ ax.set_ylim(ylim) if ylim else ax.set_ylim(
242
+ 0.01, ax.get_lines()[-1].get_ydata().max()
243
+ )
244
+ ax.set_xlabel("Sw (frac)")
198
245
  ax.set_xlim(0, 1)
199
246
  ax.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
200
247
  return ax
@@ -220,7 +267,7 @@ def skelt_harrison_func(h, a, b, c, d):
220
267
  Returns:
221
268
  float or np.array: The calculated water saturation (fraction).
222
269
  """
223
- return 1 - a * np.exp(-(b / (h + d))**c)
270
+ return 1 - a * np.exp(-((b / (h + d)) ** c))
224
271
 
225
272
 
226
273
  def fit_skelt_harrison_curve(sw, h):
@@ -234,7 +281,7 @@ def fit_skelt_harrison_curve(sw, h):
234
281
  tuple: a and b constants from the best-fit curve.
235
282
  """
236
283
  try:
237
- popt, _ = curve_fit(skelt_harrison_func, h, sw, p0=[.9, 100, 1.5, 1.5])
284
+ popt, _ = curve_fit(skelt_harrison_func, h, sw, p0=[0.9, 100, 1.5, 1.5])
238
285
  a = [round(c, 3) for c in popt][0]
239
286
  b = [round(c, 3) for c in popt][1]
240
287
  c = [round(c, 3) for c in popt][2]
@@ -270,7 +317,7 @@ def fit_poroperm_curve(poro, perm):
270
317
  tuple: a and b constants from the best-fit curve.
271
318
  """
272
319
  try:
273
- popt, _ = curve_fit(power_law_func, poro, perm, nan_policy='omit')
320
+ popt, _ = curve_fit(power_law_func, poro, perm, nan_policy="omit")
274
321
  a = [round(c) for c in popt][0]
275
322
  b = [round(c, 3) for c in popt][1]
276
323
  return a, b
@@ -280,7 +327,7 @@ def fit_poroperm_curve(poro, perm):
280
327
 
281
328
 
282
329
  def leverett_j(pc, ift, theta, perm, phit):
283
- """ Estimate Leverett J.
330
+ """Estimate Leverett J.
284
331
 
285
332
  Args:
286
333
  pc (float): Capillary pressure (psi).
@@ -292,7 +339,9 @@ def leverett_j(pc, ift, theta, perm, phit):
292
339
  Returns:
293
340
  float: Leverett J value.
294
341
  """
295
- return 0.21665 * pc / (ift * abs(np.cos(np.radians(theta)))) * (perm / phit)**(0.5)
342
+ return (
343
+ 0.21665 * pc / (ift * abs(np.cos(np.radians(theta)))) * (perm / phit) ** (0.5)
344
+ )
296
345
 
297
346
 
298
347
  def sw_skelt_harrison(depth, fwl, a, b, c, d):
@@ -326,7 +375,7 @@ def sw_lambda(phit, h, a, b, lamda):
326
375
  Returns:
327
376
  float: Water saturation.
328
377
  """
329
- return (a / (h * phit**b))**(1 / lamda)
378
+ return (a / (h * phit**b)) ** (1 / lamda)
330
379
 
331
380
 
332
381
  def sw_cuddy(phit, h, a, b):
@@ -365,8 +414,8 @@ def sw_shf_leverett_j(perm, phit, depth, fwl, ift, theta, gw, ghc, a, b, phie=No
365
414
  float: Water saturation from saturation height function.
366
415
  """
367
416
  h = (fwl - depth).clip(0)
368
- pc = h * (gw - ghc) * .433 # Convert g/cc to psi/ft
369
- shf = (a / leverett_j(pc, ift, theta, perm, phit))**(1 / b)
417
+ pc = h * (gw - ghc) * 0.433 # Convert g/cc to psi/ft
418
+ shf = (a / leverett_j(pc, ift, theta, perm, phit)) ** (1 / b)
370
419
  return shf if not phie else shf * (1 - (phie / phit)) + (phie / phit)
371
420
 
372
421
 
@@ -386,7 +435,7 @@ def sw_shf_cuddy(phit, depth, fwl, gw, ghc, a, b):
386
435
  float: Water saturation from saturation height function.
387
436
  """
388
437
  h = (fwl - depth).clip(0)
389
- shf = a / ((h * (gw - ghc) * .433)**b * phit)
438
+ shf = a / ((h * (gw - ghc) * 0.433) ** b * phit)
390
439
  return shf
391
440
 
392
441
 
@@ -410,10 +459,15 @@ def sw_shf_choo(perm, phit, phie, depth, fwl, ift, theta, gw, ghc, b0=0.4):
410
459
  """
411
460
  swb = 1 - (phie / phit)
412
461
  h = (fwl - depth).clip(0)
413
- pc = h * (gw - ghc) * .433
414
- shf = 10**((2 * b0 - 1) * np.log10(1 + swb**-1) + np.log10(1 + swb)) / (
415
- (0.2166 * (pc / (ift * abs(np.cos(np.radians(theta))))) * (
416
- perm / phit)**(0.5))**(b0 * np.log10(1 + swb**-1) / 3))
462
+ pc = h * (gw - ghc) * 0.433
463
+ shf = 10 ** ((2 * b0 - 1) * np.log10(1 + swb**-1) + np.log10(1 + swb)) / (
464
+ (
465
+ 0.2166
466
+ * (pc / (ift * abs(np.cos(np.radians(theta)))))
467
+ * (perm / phit) ** (0.5)
468
+ )
469
+ ** (b0 * np.log10(1 + swb**-1) / 3)
470
+ )
417
471
  return shf
418
472
 
419
473
 
@@ -439,7 +493,8 @@ def autocorrelate_core_depth(df):
439
493
  """
440
494
  from dtw import dtw
441
495
  from sklearn.preprocessing import minmax_scale
442
- required_cols = ['WELL_NAME', 'DEPTH', 'PHIT', 'CPORE', 'CPERM', 'CORE_ID']
496
+
497
+ required_cols = ["WELL_NAME", "DEPTH", "PHIT", "CPORE", "CPERM", "CORE_ID"]
443
498
  for col in required_cols:
444
499
  if col not in df.columns:
445
500
  raise AssertionError(f"Missing required column: {col}")
@@ -447,18 +502,29 @@ def autocorrelate_core_depth(df):
447
502
  all_wells_data = []
448
503
  shift_summaries = []
449
504
 
450
- for well, data in tqdm(df.groupby('WELL_NAME'), desc='Correlating core depths'):
451
- core_data = data[['DEPTH', 'CORE_ID', 'CPORE', 'CPERM']].dropna().sort_values('DEPTH').reset_index(drop=True)
505
+ for well, data in tqdm(df.groupby("WELL_NAME"), desc="Correlating core depths"):
506
+ core_data = (
507
+ data[["DEPTH", "CORE_ID", "CPORE", "CPERM"]]
508
+ .dropna()
509
+ .sort_values("DEPTH")
510
+ .reset_index(drop=True)
511
+ )
452
512
 
453
513
  if core_data.empty:
454
514
  all_wells_data.append(data)
455
515
  continue
456
516
 
457
- log_data = data[['DEPTH', 'PHIT']].dropna().sort_values('DEPTH').reset_index(drop=True)
458
- tqdm.write(f'Processing {well}: {len(core_data)} core data and {len(log_data)} log data')
517
+ log_data = (
518
+ data[["DEPTH", "PHIT"]].dropna().sort_values("DEPTH").reset_index(drop=True)
519
+ )
520
+ tqdm.write(
521
+ f"Processing {well}: {len(core_data)} core data and {len(log_data)} log data"
522
+ )
459
523
 
460
524
  # Create a window of log data around core points to speed up DTW
461
- core_indices_in_log = np.searchsorted(log_data.DEPTH, core_data.DEPTH, side='left')
525
+ core_indices_in_log = np.searchsorted(
526
+ log_data.DEPTH, core_data.DEPTH, side="left"
527
+ )
462
528
  window = 50 # Increased window size to allow for larger shifts
463
529
  window_indices = core_indices_in_log[:, None] + np.arange(-window, window + 1)
464
530
  window_indices = np.clip(window_indices, 0, len(log_data) - 1)
@@ -466,17 +532,19 @@ def autocorrelate_core_depth(df):
466
532
  log_data_subset = log_data.iloc[unique_indices].reset_index(drop=True)
467
533
 
468
534
  # Extract numpy arrays for DTW
469
- phit_vals = minmax_scale(log_data_subset['PHIT'].values)
470
- cpore_vals = minmax_scale(core_data['CPORE'].values)
535
+ phit_vals = minmax_scale(log_data_subset["PHIT"].values)
536
+ cpore_vals = minmax_scale(core_data["CPORE"].values)
471
537
 
472
- alignment = dtw(cpore_vals, phit_vals, keep_internals=True, step_pattern="symmetric2")
538
+ alignment = dtw(
539
+ cpore_vals, phit_vals, keep_internals=True, step_pattern="symmetric2"
540
+ )
473
541
 
474
542
  # Map alignment indices back to original data
475
543
  core_indices = alignment.index1
476
544
  log_subset_indices = alignment.index2
477
545
 
478
- original_depths = core_data.loc[core_indices, 'DEPTH'].values
479
- corrected_depths = log_data_subset.loc[log_subset_indices, 'DEPTH'].values
546
+ original_depths = core_data.loc[core_indices, "DEPTH"].values
547
+ corrected_depths = log_data_subset.loc[log_subset_indices, "DEPTH"].values
480
548
 
481
549
  # Calculate the shift for each point in the DTW path
482
550
  depth_shifts = corrected_depths - original_depths
@@ -491,31 +559,38 @@ def autocorrelate_core_depth(df):
491
559
 
492
560
  # Apply the consistent shift to all original core data for this well
493
561
  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
562
+ shifted_core_data["DEPTH_CORRECTED"] = shifted_core_data["DEPTH"] + best_shift
563
+ shifted_core_data["DEPTH_SHIFT"] = best_shift
496
564
 
497
565
  # 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']]
566
+ summary = shifted_core_data[
567
+ ["CORE_ID", "DEPTH", "DEPTH_CORRECTED", "DEPTH_SHIFT"]
568
+ ].copy()
569
+ summary.rename(columns={"DEPTH": "ORIGINAL_DEPTH"}, inplace=True)
570
+ summary["WELL_NAME"] = well
571
+ summary = summary[
572
+ ["WELL_NAME", "CORE_ID", "ORIGINAL_DEPTH", "DEPTH_CORRECTED", "DEPTH_SHIFT"]
573
+ ]
502
574
  shift_summaries.append(summary)
503
575
 
504
576
  # 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'
509
- })
577
+ final_shifted = shifted_core_data.rename(
578
+ columns={
579
+ "CPORE": "CPORE_SHIFTED",
580
+ "CPERM": "CPERM_SHIFTED",
581
+ "CORE_ID": "CORE_ID_SHIFTED",
582
+ }
583
+ )
510
584
 
511
585
  # --- SOLUTION: Use index-based merging to avoid column conflicts ---
512
586
 
513
587
  # Prepare the log data: keep only necessary columns and set DEPTH as index
514
- log_df_to_merge = data.set_index('DEPTH')
588
+ log_df_to_merge = data.set_index("DEPTH")
515
589
 
516
590
  # 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')
591
+ core_df_to_merge = final_shifted[
592
+ ["DEPTH_CORRECTED", "CPORE_SHIFTED", "CPERM_SHIFTED", "CORE_ID_SHIFTED"]
593
+ ].set_index("DEPTH_CORRECTED")
519
594
 
520
595
  # Merge the two dataframes on their indices (which are the depths)
521
596
  well_corrected_df = pd.merge(
@@ -523,21 +598,25 @@ def autocorrelate_core_depth(df):
523
598
  core_df_to_merge,
524
599
  left_index=True,
525
600
  right_index=True,
526
- how='outer'
601
+ how="outer",
527
602
  ).reset_index()
528
603
 
529
604
  # The merged 'index' column is the unified depth column, so rename it
530
- well_corrected_df.rename(columns={'index': 'DEPTH'}, inplace=True)
605
+ well_corrected_df.rename(columns={"index": "DEPTH"}, inplace=True)
531
606
 
532
607
  # Sort by the final unified depth
533
- well_corrected_df.sort_values('DEPTH', inplace=True)
608
+ well_corrected_df.sort_values("DEPTH", inplace=True)
534
609
 
535
610
  # Add well name back if lost during merge
536
- well_corrected_df['WELL_NAME'] = well
611
+ well_corrected_df["WELL_NAME"] = well
537
612
  all_wells_data.append(well_corrected_df)
538
613
 
539
614
  # Combine all processed well data and summaries
540
615
  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()
616
+ final_summary_df = (
617
+ pd.concat(shift_summaries, ignore_index=True)
618
+ if shift_summaries
619
+ else pd.DataFrame()
620
+ )
542
621
 
543
622
  return return_df, final_summary_df
@@ -95,7 +95,7 @@ class SandShale:
95
95
  vcld = np.empty(0)
96
96
  for i, point in enumerate(E):
97
97
  var_pt = line_intersection((A, C), (D, point))
98
- projlithofrac = length_a_b(var_pt, A)
98
+ projlithofrac = length_a_b(var_pt, C)
99
99
  sand_frac = projlithofrac / rocklithofrac
100
100
  sand_frac = 0 if var_pt[0] > C[0] else sand_frac
101
101
  vsand = np.append(vsand, sand_frac)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes