quick-pp 0.1.4__tar.gz → 0.1.5__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 (60) hide show
  1. {quick_pp-0.1.4 → quick_pp-0.1.5}/PKG-INFO +1 -1
  2. quick_pp-0.1.5/docs/source/index.rst +33 -0
  3. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/source/quick_pp.rst +1 -11
  4. {quick_pp-0.1.4 → quick_pp-0.1.5}/quick_pp/__init__.py +1 -1
  5. {quick_pp-0.1.4 → quick_pp-0.1.5}/quick_pp/config.py +39 -14
  6. quick_pp-0.1.5/quick_pp/core_calibration.py +257 -0
  7. quick_pp-0.1.5/quick_pp/fluid_type.py +65 -0
  8. {quick_pp-0.1.4 → quick_pp-0.1.5}/quick_pp/las_handler.py +65 -32
  9. quick_pp-0.1.5/quick_pp/lithology/__init__.py +80 -0
  10. quick_pp-0.1.5/quick_pp/lithology/carbonate.py +176 -0
  11. quick_pp-0.1.5/quick_pp/lithology/multi_mineral.py +142 -0
  12. quick_pp-0.1.5/quick_pp/lithology/sand_shale.py +83 -0
  13. quick_pp-0.1.5/quick_pp/lithology/sand_silt_clay.py +190 -0
  14. quick_pp-0.1.5/quick_pp/objects.py +176 -0
  15. {quick_pp-0.1.4 → quick_pp-0.1.5}/quick_pp/permeability.py +55 -4
  16. quick_pp-0.1.5/quick_pp/plotter.py +578 -0
  17. {quick_pp-0.1.4 → quick_pp-0.1.5}/quick_pp/porosity.py +23 -12
  18. quick_pp-0.1.5/quick_pp/qaqc.py +382 -0
  19. quick_pp-0.1.5/quick_pp/ressum.py +165 -0
  20. quick_pp-0.1.5/quick_pp/rock_type.py +55 -0
  21. {quick_pp-0.1.4 → quick_pp-0.1.5}/quick_pp/saturation.py +84 -9
  22. quick_pp-0.1.5/quick_pp/utils.py +149 -0
  23. {quick_pp-0.1.4 → quick_pp-0.1.5}/quick_pp.egg-info/PKG-INFO +1 -1
  24. {quick_pp-0.1.4 → quick_pp-0.1.5}/quick_pp.egg-info/SOURCES.txt +8 -1
  25. quick_pp-0.1.4/docs/source/index.rst +0 -20
  26. quick_pp-0.1.4/quick_pp/lithology.py +0 -394
  27. quick_pp-0.1.4/quick_pp/plotter.py +0 -379
  28. quick_pp-0.1.4/quick_pp/qaqc.py +0 -203
  29. quick_pp-0.1.4/quick_pp/ressum.py +0 -82
  30. quick_pp-0.1.4/quick_pp/rock_type.py +0 -24
  31. quick_pp-0.1.4/quick_pp/utils.py +0 -67
  32. {quick_pp-0.1.4 → quick_pp-0.1.5}/AUTHORS.rst +0 -0
  33. {quick_pp-0.1.4 → quick_pp-0.1.5}/CONTRIBUTING.rst +0 -0
  34. {quick_pp-0.1.4 → quick_pp-0.1.5}/HISTORY.rst +0 -0
  35. {quick_pp-0.1.4 → quick_pp-0.1.5}/LICENSE +0 -0
  36. {quick_pp-0.1.4 → quick_pp-0.1.5}/MANIFEST.in +0 -0
  37. {quick_pp-0.1.4 → quick_pp-0.1.5}/README.rst +0 -0
  38. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/Makefile +0 -0
  39. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/_build/html/_static/file.png +0 -0
  40. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/_build/html/_static/minus.png +0 -0
  41. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/_build/html/_static/plus.png +0 -0
  42. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/make.bat +0 -0
  43. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/source/authors.rst +0 -0
  44. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/source/conf.py +0 -0
  45. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/source/contributing.rst +0 -0
  46. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/source/history.rst +0 -0
  47. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/source/installation.rst +0 -0
  48. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/source/modules.rst +0 -0
  49. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/source/readme.rst +0 -0
  50. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/source/usage.rst +0 -0
  51. {quick_pp-0.1.4 → quick_pp-0.1.5}/docs/static/quick_pp_demo.gif +0 -0
  52. {quick_pp-0.1.4 → quick_pp-0.1.5}/quick_pp.egg-info/dependency_links.txt +0 -0
  53. {quick_pp-0.1.4 → quick_pp-0.1.5}/quick_pp.egg-info/entry_points.txt +0 -0
  54. {quick_pp-0.1.4 → quick_pp-0.1.5}/quick_pp.egg-info/not-zip-safe +0 -0
  55. {quick_pp-0.1.4 → quick_pp-0.1.5}/quick_pp.egg-info/requires.txt +0 -0
  56. {quick_pp-0.1.4 → quick_pp-0.1.5}/quick_pp.egg-info/top_level.txt +0 -0
  57. {quick_pp-0.1.4 → quick_pp-0.1.5}/setup.cfg +0 -0
  58. {quick_pp-0.1.4 → quick_pp-0.1.5}/setup.py +0 -0
  59. {quick_pp-0.1.4 → quick_pp-0.1.5}/tests/__init__.py +0 -0
  60. {quick_pp-0.1.4 → quick_pp-0.1.5}/tests/test_quick_pp.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quick_pp
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: Python package to assist in providing quick-look/ preliminary petrophysical estimation.
5
5
  Home-page: https://github.com/imranfadhil/quick_pp
6
6
  Author: Imran Fadhil
@@ -0,0 +1,33 @@
1
+ quick_pp: Petrophysics quick-look interpretation in Python
2
+ ===========================================================
3
+
4
+ quick_pp is a Python package for petrophysical quick-look interpretation. It is designed to be a simple and easy-to-use
5
+ tool for petrophysicists and geoscientists to perform quick-look interpretation of well log data. It is built on top of
6
+ the popular scientific computing libraries in Python, such as NumPy, SciPy, and Matplotlib.
7
+
8
+ .. toctree::
9
+ :maxdepth: 2
10
+ :caption: User Guide:
11
+
12
+ installation
13
+ usage
14
+
15
+ .. toctree::
16
+ :maxdepth: 2
17
+ :caption: API Reference:
18
+
19
+ quick_pp
20
+
21
+ .. toctree::
22
+ :maxdepth: 2
23
+ :caption: Other Information:
24
+
25
+ authors
26
+ contributing
27
+ history
28
+
29
+ Indices and tables
30
+ ==================
31
+ * :ref:`genindex`
32
+ * :ref:`modindex`
33
+ * :ref:`search`
@@ -1,8 +1,6 @@
1
- quick\_pp package
1
+ Docstrings for quick_pp package
2
2
  =================
3
3
 
4
- Submodules
5
- ----------
6
4
 
7
5
  quick\_pp.las\_handler module
8
6
  -----------------------------
@@ -83,11 +81,3 @@ quick\_pp.utils module
83
81
  :members:
84
82
  :undoc-members:
85
83
  :show-inheritance:
86
-
87
- Module contents
88
- ---------------
89
-
90
- .. automodule:: quick_pp
91
- :members:
92
- :undoc-members:
93
- :show-inheritance:
@@ -1,3 +1,3 @@
1
1
  __author__ = """Imran Fadhil"""
2
2
  __email__ = 'imranfadhil@gmail.com'
3
- __version__ = '0.1.4'
3
+ __version__ = '0.1.5'
@@ -41,27 +41,52 @@ class Config(object):
41
41
  SILT_LINE_ANGLE=119 # Deg angle from horizontal
42
42
  )
43
43
 
44
+ CARB_NEU_DEN_ENDPOINTS = dict(
45
+ FLUID_POINT=(.93, 1.0),
46
+ DRY_CALC_POINT=(0.0, 2.71),
47
+ DRY_DOLO_POINT=(0.01, 2.87),
48
+ DRY_CLAY_POINT=(0.24, 2.78),
49
+ )
50
+
51
+ CARB_DEN_PEF_ENDPOINTS = dict(
52
+ FLUID_POINT=(1.0, 1.0),
53
+ DRY_CALC_POINT=(5.08, 2.71),
54
+ DRY_DOLO_POINT=(3.14, 2.87),
55
+ DRY_CLAY_POINT=(2.2, 2.78),
56
+ )
57
+
44
58
  MINERALS_LOG_VALUE = {
45
- 'GR_QUARTZ': 30.0,
46
- 'NPHI_QUARTZ': -0.04,
47
- 'RHOB_QUARTZ': 2.65,
48
- 'DTC_QUARTZ': 55.0,
59
+ 'GR_QUARTZ': 0.0,
60
+ 'NPHI_QUARTZ': -0.02,
61
+ 'RHOB_QUARTZ': 2.64,
62
+ 'DTC_QUARTZ': 52.9,
49
63
  'PEF_QUARTZ': 1.8,
64
+
50
65
  'GR_CALCITE': 0.0,
51
66
  'NPHI_CALCITE': 0.0,
52
67
  'RHOB_CALCITE': 2.71,
53
- 'DTC_CALCITE': 47.6,
54
- 'PEF_CALCITE': 5.08,
68
+ 'DTC_CALCITE': 49.7,
69
+ 'PEF_CALCITE': 5.1,
70
+
55
71
  'GR_DOLOMITE': 0.0,
56
- 'NPHI_DOLOMITE': 0.009,
57
- 'RHOB_DOLOMITE': 2.87,
72
+ 'NPHI_DOLOMITE': 0.01,
73
+ 'RHOB_DOLOMITE': 2.85,
58
74
  'DTC_DOLOMITE': 43.5,
59
- 'PEF_DOLOMITE': 3.14,
60
- 'GR_SH': 110.0,
61
- 'NPHI_SH': 0.3,
62
- 'RHOB_SH': 2.5,
63
- 'DTC_SH': 110.0,
64
- 'PEF_SH': 2.2,
75
+ 'PEF_DOLOMITE': 3.1,
76
+
77
+ 'GR_SILT': 80.0,
78
+ 'NPHI_SILT': 0.1,
79
+ 'RHOB_SILT': 2.68,
80
+ 'DTC_SILT': 100.0,
81
+ 'PEF_SILT': 2.0,
82
+
83
+ # Kaolinite
84
+ 'GR_SH': 130.0,
85
+ 'NPHI_SH': 0.34,
86
+ 'RHOB_SH': 2.41,
87
+ 'DTC_SH': 143.0,
88
+ 'PEF_SH': 1.8,
89
+
65
90
  'GR_MUD': 0.0,
66
91
  'NPHI_MUD': 1.0,
67
92
  'RHOB_MUD': 1.3,
@@ -0,0 +1,257 @@
1
+ from scipy.optimize import curve_fit
2
+ import matplotlib.pyplot as plt
3
+ import numpy as np
4
+
5
+ plt.style.use('seaborn-v0_8-paper')
6
+ plt.rcParams.update(
7
+ {
8
+ 'axes.labelsize': 10,
9
+ 'xtick.labelsize': 10,
10
+ 'legend.fontsize': 'small'
11
+ }
12
+ )
13
+
14
+
15
+ def leverett_j_function(pc, ift, perm, phit):
16
+ """Leverett J function.
17
+
18
+ Args:
19
+ pc (float): Capillary pressure.
20
+ ift (float): Interfacial tension.
21
+ perm (float): Permeability.
22
+ phit (float): Total porosity.
23
+
24
+ Returns:
25
+ float: Leverett J function.
26
+ """
27
+ return 0.216 * (pc / ift) * (perm / phit)**(0.5)
28
+
29
+
30
+ def pseudo_leverett_j_function(pc, ift, perm, phit):
31
+ """Pseudo-Leverett J function.
32
+
33
+ Args:
34
+ pc (float): Capillary pressure.
35
+ ift (float): Interfacial tension.
36
+ perm (float): Permeability.
37
+ phit (float): Total porosity.
38
+
39
+ Returns:
40
+ float: Pseudo-Leverett J function.
41
+ """
42
+ pass
43
+
44
+
45
+ def sw_leverett_j(pc, ift, perm, phit, a, b):
46
+ """Saturation J function.
47
+
48
+ Args:
49
+ pc (float): Capillary pressure.
50
+ ift (float): Interfacial tension.
51
+ perm (float): Permeability.
52
+ phit (float): Total porosity.
53
+
54
+ Returns:
55
+ float: Saturation J function.
56
+ """
57
+ return (a / (0.216 * (pc / ift) * (perm / phit)**(0.5)))**(1 / b)
58
+
59
+
60
+ def sw_skelt_harrison():
61
+ pass
62
+
63
+
64
+ def sw_cuddy(phit, h, a, b):
65
+ """Cuddy's saturation model.
66
+
67
+ Args:
68
+ sw (float): Water saturation.
69
+ phit (float): Total porosity.
70
+ h (float): True vertical depth.
71
+ a (float): Cementation exponent.
72
+ b (float): Saturation exponent.
73
+
74
+ Returns:
75
+ float: Water saturation.
76
+
77
+ """
78
+ return a / phit * h**b
79
+
80
+
81
+ def func(x, a, b):
82
+ return a * x**b
83
+
84
+
85
+ def fit_j_curve(sw, j):
86
+ """_summary_
87
+
88
+ Args:
89
+ sw (_type_): _description_
90
+ j (_type_): _description_
91
+ """
92
+ try:
93
+ popt, _ = curve_fit(func, sw, j)
94
+ a = [round(c, 3) for c in popt][0]
95
+ b = [round(c, 3) for c in popt][1]
96
+ return a, b
97
+ except Exception as e:
98
+ print(e)
99
+ return 1, 1
100
+
101
+
102
+ def j_xplot(sw, j, a=None, b=None, label='', log_log=False, ylim=None):
103
+
104
+ sc = plt.plot(sw, j, marker='s', label=label)
105
+ if a and b:
106
+ line_color = sc[0].get_color() + '80' # Set opacity to 0.5
107
+ csw = np.geomspace(0.1, 1.0, 30)
108
+ plt.plot(csw, func(csw, a, b), color=line_color, linestyle='dashed')
109
+ plt.xlabel('Sw (frac)')
110
+ plt.xlim(0.01, 1)
111
+ plt.ylabel('J')
112
+ plt.ylim(ylim) if ylim else plt.ylim(0.01, plt.gca().get_lines()[-1].get_ydata().max())
113
+ plt.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
114
+ if log_log:
115
+ plt.xscale('log')
116
+ plt.yscale('log')
117
+
118
+
119
+ def fit_poroperm_curve(poro, perm):
120
+ """_summary_
121
+
122
+ Args:
123
+ poro (_type_): _description_
124
+ perm (_type_): _description_
125
+ """
126
+ try:
127
+ popt, _ = curve_fit(func, poro, perm)
128
+ a = [round(c) for c in popt][0]
129
+ b = [round(c, 3) for c in popt][1]
130
+ return a, b
131
+ except Exception as e:
132
+ print(e)
133
+ return 1, 1
134
+
135
+
136
+ def poroperm_xplot(poro, perm, a=None, b=None, label='', log_log=False):
137
+
138
+ sc = plt.scatter(poro, perm, marker='o', label=label)
139
+ if a and b:
140
+ line_color = sc.get_facecolors()[0]
141
+ line_color[-1] = 0.5
142
+ cpore = np.geomspace(0.05, 0.5, 30)
143
+ plt.plot(cpore, func(cpore, a, b), color=line_color, linestyle='dashed')
144
+ plt.xlabel('CPORE (frac)')
145
+ plt.xlim(0, 0.5)
146
+ plt.ylabel('CPERM (mD)')
147
+ plt.yscale('log')
148
+ plt.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
149
+ if log_log:
150
+ plt.xscale('log')
151
+
152
+
153
+ def bvw_xplot(bvw, pc, a=None, b=None, label='', ylim=None, log_log=False):
154
+
155
+ sc = plt.plot(bvw, pc, marker='s', label=label)
156
+ if a and b:
157
+ line_color = sc[0].get_color() + '66' # Set opacity to 0
158
+ cbvw = np.linspace(0.05, 0.35, 30)
159
+ plt.scatter(cbvw, func(cbvw, a, b), marker='x', color=line_color)
160
+ plt.xlabel('BVW (frac)')
161
+ plt.ylabel('Pc (psi)')
162
+ plt.ylim(ylim) if ylim else plt.ylim(0.01, plt.gca().get_lines()[-1].get_ydata().max())
163
+ plt.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
164
+ if log_log:
165
+ plt.xscale('log')
166
+ plt.yscale('log')
167
+
168
+
169
+ def estimate_hafwl(sw, poro, perm, ift, gw, ghc, a, b):
170
+ """Estimate the height (feet) above free water level.
171
+
172
+ Args:
173
+ sw (float): Water saturation (frac).
174
+ poro (float): Porosity (frac).
175
+ perm (float): Permeability (mD).
176
+ ift (float): Interfacial tension (dynes/cm).
177
+ gw (float): Gas density (psi/ft).
178
+ ghc (float): Gas height (psi/ft).
179
+ a (float): A constant from J function.
180
+ b (float): B constant from J function.
181
+
182
+ Returns:
183
+ float: Height above free water level.
184
+ """
185
+ # Calculate the saturation J function.
186
+ j = a * sw**b
187
+ return (j / 0.216) * (ift / (gw - ghc)) * (perm / poro)**0.5
188
+
189
+
190
+ def sw_shf_leverett_j(perm, poro, depth, fwl, ift, gw, ghc, a, b):
191
+ """Saturation height function.
192
+
193
+ Args:
194
+ perm (float): Permeability (mD).
195
+ poro (float): Porosity (frac).
196
+ depth (_type_): _description_
197
+ fwl (_type_): _description_
198
+ ift (float): Interfacial tension (dynes/cm).
199
+ gw (float): Gas density (psi/ft).
200
+ ghc (float): Gas height (psi/ft).
201
+ a (float): A constant from J function.
202
+ b (float): B constant from J function.
203
+
204
+ Returns:
205
+ _type_: _description_
206
+ """ """TODO: Saturation height function.
207
+ """
208
+ h = fwl - depth
209
+ pc = h * (gw - ghc)
210
+ shf = ((0.216 * (pc / ift) * (perm / poro)**(0.5)) / a)**(1 / b)
211
+ # return np.where(shf > 1, 1, shf)
212
+ return shf
213
+
214
+
215
+ def sw_shf_cuddy(poro, depth, fwl, gw, ghc, a, b):
216
+ """Saturation height function.
217
+
218
+ Args:
219
+ poro (float): Porosity (frac).
220
+ depth (_type_): _description_
221
+ fwl (_type_): _description_
222
+ a (float): Cementation exponent.
223
+ b (float): Saturation exponent.
224
+
225
+ Returns:
226
+ _type_: _description_
227
+ """
228
+ h = fwl - depth
229
+ shf = (h * (gw - ghc) / a)**(1 / b) / poro
230
+ # return np.where(shf > 1, 1, shf)
231
+ return shf
232
+
233
+
234
+ def sw_shf_choo(perm, phit, phie, depth, fwl, ift, gw, ghc, b0=0.4):
235
+ """Saturation height function.
236
+
237
+ Args:
238
+ perm (float): Permeability (mD).
239
+ phit (float): Total porosity (frac).
240
+ phie (float): Effective porosity (frac).
241
+ depth (float): _description_
242
+ fwl (float): _description_
243
+ ift (float): Interfacial tension (dynes/cm).
244
+ gw (float): Gas density (psi/ft).
245
+ ghc (float): Gas height (psi/ft).
246
+ b0 (float): _description_. Defaults to 0.4.
247
+
248
+ Returns:
249
+ _type_: _description_
250
+ """
251
+ swb = 1 - (phie / phit)
252
+ h = fwl - depth
253
+ pc = h * (gw - ghc)
254
+ shf = 10**((2 * b0 - 1) * np.log10(1 + swb**-1) + np.log10(1 + swb)) / (
255
+ (0.2166 * (pc / ift) * (perm / phit)**(0.5))**(b0 * np.log10(1 + swb**-1) / 3))
256
+ # return np.where(shf > 1, 1, shf)
257
+ return shf
@@ -0,0 +1,65 @@
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+ from scipy.optimize import curve_fit
4
+
5
+ plt.style.use('seaborn-v0_8-paper')
6
+ plt.rcParams.update(
7
+ {
8
+ 'axes.labelsize': 10,
9
+ 'xtick.labelsize': 10,
10
+ 'legend.fontsize': 'small'
11
+ }
12
+ )
13
+
14
+
15
+ def func(x, m, c):
16
+ return m * x + c
17
+
18
+
19
+ def fit_pressure_gradient(tvdss, formation_pressure):
20
+ """Fit pressure gradient from formation pressure and true vertical depth subsea.
21
+
22
+ Args:
23
+ tvdss (float): True vertical depth subsea.
24
+ formation_pressure (float): Formation pressure.
25
+
26
+ Returns:
27
+ tuple: Gradient and intercept of the best-fit line.
28
+ """
29
+ popt, _ = curve_fit(func, tvdss, formation_pressure)
30
+ return round(popt[0], 3), round(popt[1], 3)
31
+
32
+
33
+ def fluid_contact_plot(tvdss, formation_pressue, m, c, fluid_type: str = 'WATER',
34
+ ylim: tuple = (5000, 3000), xlim: tuple = (1000, 5000),
35
+ goc: float = 0, owc: float = 0, gwc: float = 0):
36
+ """Generate fluid contact plot which is used to determine the fluid contact in a well.
37
+
38
+ Args:
39
+ tvdss (float): True vertical depth subsea.
40
+ formation_pressure (float): Formation pressure.
41
+
42
+ Returns:
43
+ matplotlib.pyplot.Figure: Fluid contact plot.
44
+ """
45
+ color_dict = dict(
46
+ OIL=('green', 'o'),
47
+ GAS=('red', 'x'),
48
+ WATER=('blue', '^'),
49
+ HYDROSTATIC=('brown', 's')
50
+ )
51
+ marker = color_dict.get(fluid_type.upper(), ('black', 'o'))
52
+ label = f'{fluid_type} gradient: {round(m, 3)} psi/ft'
53
+ sc = plt.scatter(formation_pressue, tvdss, label=label, c=marker[0], marker=marker[1])
54
+
55
+ line_color = sc.get_facecolors()[0]
56
+ line_color[-1] = 0.5
57
+ tvd_pts = np.linspace(ylim[0] - 30, ylim[1] + 30, 30)
58
+ plt.plot(func(tvd_pts, m, c), tvd_pts, color=line_color)
59
+
60
+ plt.ylim(ylim)
61
+ plt.ylabel('TVDSS (ft)')
62
+ plt.xlim(xlim)
63
+ plt.xlabel('Formation Pressure (psi)')
64
+ plt.legend()
65
+ plt.title('Fluid Contact Plot')
@@ -1,5 +1,6 @@
1
1
  import re
2
2
  import lasio
3
+ import os
3
4
  import numpy as np
4
5
  import pandas as pd
5
6
  import mmap
@@ -176,7 +177,8 @@ def pre_process(welly_object):
176
177
 
177
178
  well_name = header_df[
178
179
  (header_df['mnemonic'] == 'WELL') | (header_df['descr'].str.upper() == 'WELL')]['value'].values[0]
179
- data_df.insert(0, 'WELL_NAME', well_name)
180
+ if 'WELL_NAME' not in data_df.columns:
181
+ data_df.insert(0, 'WELL_NAME', well_name)
180
182
 
181
183
  return data_df
182
184
 
@@ -203,8 +205,9 @@ def extract_dataset(section_dict):
203
205
  data_bytes = data_bytes + v
204
206
 
205
207
  file_object = header_bytes.decode('Windows-1252') + data_bytes.decode('Windows-1252')
206
- las_object = lasio.read(file_object)
208
+ las_object = lasio.read(file_object, read_policy=())
207
209
 
210
+ # Fix las_object
208
211
  df = las_object.df()
209
212
  df = df.apply(pd.to_numeric, errors='coerce')
210
213
  las_object.set_data_from_df(df)
@@ -245,7 +248,13 @@ def concat_datasets(file_object, header_line_numbers, parameter_line_numbers, re
245
248
  else:
246
249
  temp_file_object = file_object[pointer:].decode('Windows-1252')
247
250
  temp_file_object = well_info + temp_file_object
248
- las_object = lasio.read(temp_file_object)
251
+ las_object = lasio.read(temp_file_object, read_policy=())
252
+
253
+ # Fix las_object
254
+ df = las_object.df()
255
+ df = df.apply(pd.to_numeric, errors='coerce')
256
+ las_object.set_data_from_df(df)
257
+
249
258
  welly_object = welly.Well.from_lasio(las_object)
250
259
  temp_well_df = pre_process(welly_object)
251
260
  well_df = pd.concat([well_df, temp_well_df], axis=1)
@@ -254,6 +263,26 @@ def concat_datasets(file_object, header_line_numbers, parameter_line_numbers, re
254
263
  return well_df, header_df, welly_object
255
264
 
256
265
 
266
+ def check_index_consistent(welly_object):
267
+ """Check if index is consistent in welly_object
268
+
269
+ Args:
270
+ welly_object (object): Welly object
271
+
272
+ Returns:
273
+ bool: True if index is consistent
274
+ """
275
+ try:
276
+ index_diff = np.diff(welly_object.las[0].index)
277
+ if all(index_diff == index_diff[0]) and all(index_diff > 0):
278
+ return True
279
+ else:
280
+ return False
281
+ except Exception as e:
282
+ print(f"[las_handler] `check_index_consistent` Error | {e}")
283
+ return False
284
+
285
+
257
286
  def resample_depth(welly_object, step_depth=0.5):
258
287
  """Convert m to ft and resample DEPTH to feet with 0.5 step
259
288
 
@@ -264,34 +293,37 @@ def resample_depth(welly_object, step_depth=0.5):
264
293
  Returns:
265
294
  pd.DataFrame: Resampled dataframe
266
295
  """
267
- return_df = welly_object.df()
268
- for i, curve_name in enumerate(list(welly_object.data.keys())):
269
- pre_curve = welly_object.data[curve_name]
270
- if pre_curve.index_units and pre_curve.index_units.lower() in ['metres', 'm']:
271
- pre_curve.df.index = welly.well._convert_depth_index_units(pre_curve.index, unit_from='m', unit_to='ft')
272
- pre_curve.index_units = 'ft'
273
-
274
- # Set new start if not 0.5
275
- new_start = pre_curve.start
276
- if np.mod(new_start, 0.5) != 0:
277
- new_start = np.round((new_start * 2)) / 2
278
-
279
- # Set the new stop of depth.
280
- new_stop = pre_curve.start + (
281
- step_depth * np.ceil((pre_curve.stop - pre_curve.start) / step_depth)
282
- )
283
-
284
- new_curve = pre_curve.to_basis(start=new_start, stop=new_stop, step=step_depth)
285
- new_curve = pd.DataFrame(new_curve.values, index=new_curve.index.values, columns=[curve_name])
286
- # Create new dataframe when first loop.
287
- if i == 0:
288
- new_clips_df = pd.DataFrame(new_curve.values, index=new_curve.index.values, columns=[curve_name])
289
- # Merge new dataframe with the previous loop.
290
- else:
291
- new_curve_df = pd.DataFrame(new_curve.values, index=new_curve.index.values, columns=[curve_name])
292
- new_clips_df = pd.merge(new_clips_df, new_curve_df, left_index=True, right_index=True)
296
+ if check_index_consistent(welly_object):
297
+ for i, curve_name in enumerate(list(welly_object.data.keys())):
298
+ pre_curve = welly_object.data[curve_name]
299
+ if pre_curve.index_units and pre_curve.index_units.lower() in ['metres', 'm']:
300
+ pre_curve.df.index = welly.well._convert_depth_index_units(pre_curve.index, unit_from='m', unit_to='ft')
301
+ pre_curve.index_units = 'ft'
302
+
303
+ # Set new start if not 0.5
304
+ new_start = pre_curve.start
305
+ if np.mod(new_start, 0.5) != 0:
306
+ new_start = np.round((new_start * 2)) / 2
307
+
308
+ # Set the new stop of depth.
309
+ new_stop = pre_curve.start + (
310
+ step_depth * np.ceil((pre_curve.stop - pre_curve.start) / step_depth)
311
+ )
312
+ new_curve = pre_curve.to_basis(start=new_start, stop=new_stop, step=step_depth)
313
+ new_curve = pd.DataFrame(new_curve.values, index=new_curve.index.values, columns=[curve_name])
314
+ # Create new dataframe when first loop.
315
+ if i == 0:
316
+ new_clips_df = pd.DataFrame(new_curve.values, index=new_curve.index.values, columns=[curve_name])
317
+ # Merge new dataframe with the previous loop.
318
+ else:
319
+ new_curve_df = pd.DataFrame(new_curve.values, index=new_curve.index.values, columns=[curve_name])
320
+ new_clips_df = pd.merge(new_clips_df, new_curve_df, left_index=True, right_index=True)
321
+
322
+ return_df = new_clips_df.copy()
323
+
324
+ else:
325
+ return_df = welly_object.las[0]
293
326
 
294
- return_df = new_clips_df.copy()
295
327
  # Convert index 'DEPTH' as column
296
328
  if "DEPTH" in return_df.columns:
297
329
  return_df.set_index('DEPTH', inplace=True)
@@ -301,7 +333,7 @@ def resample_depth(welly_object, step_depth=0.5):
301
333
  return return_df
302
334
 
303
335
 
304
- def export_to_las(well_data, well_name):
336
+ def export_to_las(well_data, well_name, folder=''):
305
337
  """Export dataframe to las file.
306
338
 
307
339
  Args:
@@ -313,7 +345,8 @@ def export_to_las(well_data, well_name):
313
345
  well_data['DEPT'] = well_data['DEPTH']
314
346
  well_data.set_index('DEPT', inplace=True, drop=True)
315
347
  w = welly.Well().from_df(well_data, units=units, name=well_name)
316
- w.to_las(f'{well_name}.las')
348
+ well_path = os.path.join(folder, f"{well_name}.las")
349
+ w.to_las(well_path)
317
350
 
318
351
 
319
352
  if __name__ == '__main__':
@@ -0,0 +1,80 @@
1
+ import numpy as np
2
+ import statistics
3
+ from scipy.signal import detrend
4
+ from sklearn.preprocessing import MinMaxScaler
5
+
6
+
7
+ def shale_volume_larinov_tertiary(igr):
8
+ """
9
+ Computes shale volume from gamma ray using Larinov's method for tertiary rocks.
10
+
11
+ Parameters
12
+ ----------
13
+ igr : float
14
+ Interval gamma ray [API].
15
+
16
+ Returns
17
+ -------
18
+ vshale : float
19
+ Shale volume [fraction].
20
+
21
+ """
22
+ return 0.083 * (2**(3.7 * igr) - 1)
23
+
24
+
25
+ def shale_volume_larinov_older(igr):
26
+ """
27
+ Computes shale volume from gamma ray using Larinov's method for older rocks.
28
+
29
+ Parameters
30
+ ----------
31
+ igr : float
32
+ Interval gamma ray [API].
33
+
34
+ Returns
35
+ -------
36
+ vshale : float
37
+ Shale volume [fraction].
38
+
39
+ """
40
+ return 0.33 * (2**(2 * igr) - 1)
41
+
42
+
43
+ def shale_volume_steiber(igr):
44
+ """
45
+ Computes shale volume from gamma ray using Steiber's method.
46
+
47
+ Parameters
48
+ ----------
49
+ igr : float
50
+ Interval gamma ray [API].
51
+
52
+ Returns
53
+ -------
54
+ vshale : float
55
+ Shale volume [fraction].
56
+
57
+ """
58
+ return igr / (3 - 2 * igr)
59
+
60
+
61
+ def gr_index(gr):
62
+ """
63
+ Computes gamma ray index from gamma ray.
64
+
65
+ Parameters
66
+ ----------
67
+ gr : float
68
+ Gamma ray [API].
69
+
70
+ Returns
71
+ -------
72
+ gr_index : float
73
+ Gamma ray index [API].
74
+
75
+ """
76
+ gr = np.where(np.isnan(gr), np.min(gr), gr)
77
+ dtr_gr = detrend(gr, axis=0) + statistics.mean(gr)
78
+ scaler = MinMaxScaler()
79
+ igr = scaler.fit_transform(dtr_gr.reshape(-1, 1))
80
+ return igr