Skip to content

Commit

Permalink
Merge pull request #117 from jonnymaserati/feature/mti_tweaks
Browse files Browse the repository at this point in the history
Added some tweaks for the MTI
  • Loading branch information
jonnymaserati authored Jun 17, 2022
2 parents 056592e + 21e4fa0 commit 8f624a5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.
61 changes: 43 additions & 18 deletions welleng/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ def set_vertical_section(self, vertical_section_azimuth, deg=True):
)

def modified_tortuosity_index(
self, rtol=1.0, data=False, **kwargs
self, rtol=0.01, dls_tol=None, data=False, **kwargs
):
"""
Convenient method for calculating the Tortuosity Index (TI) using a
Expand All @@ -884,18 +884,21 @@ def modified_tortuosity_index(
Relative tolerance when determining closeness of normal vectors.
atol: float
Absolute tolerance when determining closeness of normal vectors.
data: boolean
dls_tol: float or None
Indicates whether or not to check for dls continuity within the
defined dls tolerance.
data: float
If true returns a dictionary of properties.
Returns
ti: (n,1) array or dict
Array of tortuosity index or a dict of results where:
"""
return modified_tortuosity_index(
self, rtol=rtol, data=data, **kwargs
self, rtol=rtol, dls_tol=dls_tol, data=data, **kwargs
)

def tortuosity_index(self, rtol=1.0, data=False, **kwargs):
def tortuosity_index(self, rtol=0.01, dls_tol=None, data=False, **kwargs):
"""
A modified version of the Tortuosity Index function originally
referenced in an IADD presentation on "Measuring Wellbore
Expand Down Expand Up @@ -930,7 +933,7 @@ def tortuosity_index(self, rtol=1.0, data=False, **kwargs):
"""

return tortuosity_index(
self, rtol=rtol, data=data, **kwargs
self, rtol=rtol, dls_tol=None, data=data, **kwargs
)

def directional_difficulty_index(self, **kwargs):
Expand All @@ -948,7 +951,7 @@ def directional_difficulty_index(self, **kwargs):


def modified_tortuosity_index(
survey, rtol=1.0, data=False, **kwargs
survey, rtol=0.01, dls_tol=None, data=False, **kwargs
):
"""
Method for calculating the Tortuosity Index (TI) using a modified
Expand All @@ -961,7 +964,7 @@ def modified_tortuosity_index(
kappa = kwargs.get('kapa', 1)

continuous, starts, mds, locs, n_sections, n_sections_arr = _get_ti_data(
survey, rtol
survey, rtol, dls_tol
)

l_cs = (
Expand Down Expand Up @@ -1009,7 +1012,7 @@ def modified_tortuosity_index(
return mti


def tortuosity_index(survey, rtol=1.0, data=False, **kwargs):
def tortuosity_index(survey, rtol=0.01, dls_tol=None, data=False, **kwargs):
"""
Method for calculating the Tortuosity Index (TI) as described in the
International Association of Directional Drilling presentation
Expand All @@ -1021,7 +1024,7 @@ def tortuosity_index(survey, rtol=1.0, data=False, **kwargs):
kappa = kwargs.get('kapa', 1e7)

continuous, starts, mds, locs, n_sections, n_sections_arr = _get_ti_data(
survey, rtol
survey, rtol, dls_tol
)

l_cs = (survey.md[1:] - mds[n_sections_arr - 1]) / coeff
Expand Down Expand Up @@ -1097,7 +1100,7 @@ def directional_difficulty_index(survey, **kwargs):
return ddi


def _get_ti_data(survey, rtol):
def _get_ti_data(survey, rtol, dls_tol=None):
# tol_0 = np.full((len(survey.md) - 2, 3), rtol)
# delta_md = (survey.md[2:] - survey.md[1:-1]).reshape(-1, 1)
# delta_norm = survey.normals[1:] - survey.normals[:-1]
Expand All @@ -1109,14 +1112,27 @@ def _get_ti_data(survey, rtol):
# & np.isnan(survey.normals[:-1]).all(axis=-1)
# )
# )
continuous = np.all(
np.isclose(
survey.normals[:-1],
survey.normals[1:],
if dls_tol is None:
dls_continuity = np.full(len(survey.dls) - 2, True)
else:
dls_continuity = np.isclose(
survey.dls[1:-1],
survey.dls[2:],
equal_nan=True,
rtol=rtol, atol=rtol
), axis=-1
)
rtol=dls_tol,
atol=rtol
)
continuous = np.all((
np.all(
np.isclose(
survey.normals[:-1],
survey.normals[1:],
equal_nan=True,
rtol=rtol, atol=rtol
), axis=-1
),
dls_continuity
), axis=0)

starts = np.concatenate((
np.array([0]),
Expand Down Expand Up @@ -1887,6 +1903,12 @@ def from_connections(
"""
if type(section_data) is not list:
section_data = [section_data]

# get reference mds
mds_ref = []
for s in section_data:
mds_ref.extend([s.md1, s.md_target])

section_data_interp = interpolate_well(section_data, step)
# generate lists for survey
md, inc, azi = np.vstack([np.array(list(zip(
Expand All @@ -1906,6 +1928,8 @@ def from_connections(
surface_unit=surface_unit
)

interpolated = np.array([False if m in mds_ref else True for m in md])

survey = Survey(
md=md,
inc=inc,
Expand All @@ -1917,7 +1941,8 @@ def from_connections(
radius=radius,
header=survey_header,
error_model=error_model,
unit=depth_unit
unit=depth_unit,
interpolated=interpolated
)

return survey
Expand Down
2 changes: 1 addition & 1 deletion welleng/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.4.10'
__version__ = '0.4.11'

0 comments on commit 8f624a5

Please sign in to comment.