-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtrajectory.py
84 lines (70 loc) · 2.1 KB
/
trajectory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import numpy as np
from functions import distance
class Station:
"""
This class represent a survey station.
"""
def __init__(self):
self.md = None
self.inc = None
self.azi = None
self.x = None
self.y = None
self.z = None
self.is_inflection = False
self.ti = 0 # single TI
self.cumulative_ti = None # TI till this station
def set_data(self, data):
self.md = data[0] # "measured_depth"
self.inc = data[1] # "inclination"
self.azi = data[2] # "azimuth"
self.x = data[3] # "northing"
self.y = data[4] # "easting"
self.z = data[5] # "tvd"
def _get_3d_point(self):
return np.array([self.x, self.y, self.z])
def equal_inc_azi(self, other):
if isinstance(other, Station):
if self.inc == other.inc and self.azi == other.azi:
return True
return False
@property
def p(self):
return self._get_3d_point()
def to_dict(self):
return {
'md': self.md,
'inc': self.inc,
'azi': self.azi,
'x': self.x,
'y': self.y,
'z': self.z,
'is_inflection': self.is_inflection,
'ti': self.ti,
'cumulative_ti': self.cumulative_ti
}
def is_straight(st1: Station, st2: Station):
"""
To check if it is a straight line from the first station to the next
:param st1:
:param st2:
:return:
"""
if st1.inc == st2.inc and st1.azi == st2.azi:
return True
return False
def calculate_and_set_single_tortuosity(st1: Station, st2: Station):
"""
Compute and return tortuosity from station 1 to station 2
Station 2 has a higher MD compared to Station 1
:param st1:
:param st2:
:return: individual/single TI
"""
if st2.md < st1.md:
raise ValueError(f"MD of the station 2 ({st2.md}) should be larger than station 1 ({st1.md}).")
ti = np.abs((st2.md - st1.md) / (distance(st2.p, st1.p))) - 1
if ti < 0:
ti = 0
st2.ti = ti
return ti