-
Notifications
You must be signed in to change notification settings - Fork 7
/
well.py
112 lines (97 loc) · 5.14 KB
/
well.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
plt.rcParams["font.family"] = "Helvetica"
plt.rcParams["font.size"] = 12
class well:
def __init__(self, name = None, topVerView = None, mdl = None, kop = None, bur = None, inc = None,
verStretchFactor = 1.05, horStretchFactor = 4):
self.tubulars = {}
self.cements = {}
self.largestTub = 0
self.deepestTub = 0
self.cementID = 0
self.showTubularSummary = True
self.showCementSummary = True
self.name = name
self.topVerView = topVerView
self.mdl = mdl
self.kop = kop
self.bur = bur
self.inc = inc
self.verStretchFactor = verStretchFactor
self.horStretchFactor = horStretchFactor
def addTubular(self, tub):
try:
assert tub.name not in self.tubulars.keys()
self.tubulars[tub.name] = {"xy":np.array([tub.inD, tub.low]), "width":tub.thickness, "height":tub.totalLength,
"outD": tub.outD, "summary": tub.summary, "low": tub.low, "shoeWidth":tub.shoeWidth}
if tub.outD > self.largestTub:
self.largestTub = tub.outD
if tub.low > self.deepestTub:
self.deepestTub = tub.low
except:
raise ValueError("Tubular names must be unique! that tubular has been added to this well")
def addCement(self, cem):
self.cements[self.cementID] = {"horVals": cem.horVals, "topVals": cem.topVals, "lowVals": cem.lowVals, "summary": cem.summary}
self.cementID += 1
def hideTubularSummary(self):
self.showTubularSummary = False
def hideCementSummary(self):
self.showCementSummary = False
def visualize(self):
stretchHorView = self.largestTub * self.horStretchFactor
stretchVerView = self.deepestTub * self.verStretchFactor
self.fig, self.ax = plt.subplots(figsize = (8.27, 11.69))
# the tubulars
for key, elem in self.tubulars.items():
self.ax.add_patch(Rectangle(elem["xy"], elem["width"], elem["height"], color = "black"))
self.ax.add_patch(Rectangle((-1*elem["xy"][0], elem["xy"][1]), -1*elem["width"], elem["height"], color = "black"))
# showing tubular summaries
if self.showTubularSummary == True:
xText = elem["outD"] + (0.075 * stretchHorView)
yText = elem["low"] * 0.85
self.ax.text(xText, yText, elem["summary"],
verticalalignment = "top", horizontalalignment = "left")
# the cement intervals
for key, elem in self.cements.items():
self.ax.fill_between(elem["horVals"], elem["topVals"], elem["lowVals"], color = "#6b705c")
self.ax.fill_between(-1*elem["horVals"], elem["topVals"], elem["lowVals"], color = "#6b705c")
# showing cement summaries
if self.showCementSummary == True:
xText = -elem["horVals"][1] - (0.4 * stretchHorView)
yText = elem["lowVals"][1]
self.ax.text(xText, yText, elem["summary"],
verticalalignment = "top", horizontalalignment = "left", color = "#6b705c")
# the shoes
for key, elem in self.tubulars.items():
if elem["shoeWidth"] is not None:
vizShoeHeight = stretchVerView * 0.01
p0 = [elem["outD"], elem["low"]]
p1 = [elem["outD"], elem["low"] - vizShoeHeight]
p2 = [elem["outD"] + elem["shoeWidth"], elem["low"]]
shoe = plt.Polygon([p0, p1, p2], color = "black")
self.ax.add_patch(shoe)
p0[0] *= -1
p1[0] *= -1
p2 = [-elem["outD"] - elem["shoeWidth"], elem["low"]]
shoe = plt.Polygon([p0, p1, p2], color = "black")
self.ax.add_patch(shoe)
self.ax.set_ylabel("MD [ft]")
self.ax.set_xlim([-stretchHorView, stretchHorView])
if self.topVerView is None:
self.ax.set_ylim([0, stretchVerView])
else:
self.ax.set_ylim([self.topVerView, stretchVerView])
if self.kop is not None:
kopColor = "#0C1713"
self.ax.hlines(self.kop, -stretchHorView, stretchHorView, linestyle = "--", color = kopColor, linewidth = 0.5, alpha = 0.75,zorder=0)
self.ax.annotate("KOP at {} ft".format(self.kop), xy = (-stretchHorView + 1, self.kop - 25), color = kopColor, alpha = 0.75)
if self.mdl is not None:
mdlColor = "#348ceb"
self.ax.hlines(self.mdl, -stretchHorView, stretchHorView, linestyle = "--", color = mdlColor, linewidth = 0.5, alpha = 0.75,zorder=0)
self.ax.annotate("Mudline at {} ft".format(self.mdl), xy = (-stretchHorView + 1, self.mdl - 25), color = mdlColor, alpha = 0.75)
self.ax.invert_yaxis()
plt.title(self.name, loc = "left")
plt.tight_layout()
plt.show()