forked from yohanesnuwara/FormationPy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwell_log_display.py
More file actions
152 lines (134 loc) · 6.02 KB
/
well_log_display.py
File metadata and controls
152 lines (134 loc) · 6.02 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
def well_log_display(df, column_depth, column_list,
column_semilog=None, min_depth=None, max_depth=None,
column_min=None, column_max=None, colors=None,
fm_tops=None, fm_depths=None,
tight_layout=1, title_size=10):
"""
Display log side‑by‑side style
Input:
df is your dataframe
specify min_depth and max_depth as the upper and lower depth limit
column_depth is the column name of your depth
column_list is the LIST of column names that you will display
column_semilog is specific for resistivity column; if your resistivities are
in column 3, specify as: column_semilog=2. Default is None, so if you don't
specify, the resistivity will be plotted in normal axis instead
column_min is list of minimum values for the x‑axes.
column_max is list of maximum values for the x‑axes.
colors is the list of colors specified for each log names. Default is None,
so if don't specify, the colors will be Matplotlib default (blue)
fm_tops and fm_depths are the list of formation top names and depths.
Default is None, so no tops are shown. Specify both lists, if you want
to show the tops
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import random
if column_semilog==None:
# column semilog not defined, RT will be plotted in normal axis
logs = column_list
# create the subplots; ncols equals the number of logs
fig, ax = plt.subplots(nrows=1, ncols=len(logs), figsize=(20,10))
# looping each log to display in the subplots
if colors==None:
# color is None (default)
for i in range(len(logs)):
# normal axis plot
ax[i].plot(df[logs[i]], df[column_depth])
ax[i].set_title(logs[i], size=title_size)
ax[i].minorticks_on()
ax[i].grid(which='major', linestyle='-', linewidth='0.5', color='lime')
ax[i].grid(which='minor', linestyle=':', linewidth='0.5', color='black')
if column_min!=None and column_max!=None:
# x-axis limits defined
ax[i].set_xlim(column_min[i], column_max[i])
if min_depth!=None and max_depth!=None:
# y-axis limit defined
ax[i].set_ylim(min_depth, max_depth)
ax[i].invert_yaxis()
else:
# colors are defined (as list)
for i in range(len(logs)):
# normal axis plot
ax[i].plot(df[logs[i]], df[column_depth], color=colors[i])
ax[i].set_title(logs[i], size=title_size)
ax[i].minorticks_on()
ax[i].grid(which='major', linestyle='-', linewidth='0.5', color='lime')
ax[i].grid(which='minor', linestyle=':', linewidth='0.5', color='black')
if column_min!=None and column_max!=None:
# x-axis limits defined
ax[i].set_xlim(column_min[i], column_max[i])
if min_depth!=None and max_depth!=None:
# y-axis limit defined
ax[i].set_ylim(min_depth, max_depth)
ax[i].invert_yaxis()
else:
# column semilog is defined, RT will be plotted in semilog axis
logs = column_list
# create the subplots; ncols equals the number of logs
fig, ax = plt.subplots(nrows=1, ncols=len(logs), figsize=(20,10))
# looping each log to display in the subplots
if colors==None:
# color is None (default)
for i in range(len(logs)):
if i == column_semilog:
# for resistivity, semilog plot
ax[i].semilogx(df[logs[i]], df[column_depth])
else:
# for non-resistivity, normal plot
ax[i].plot(df[logs[i]], df[column_depth])
ax[i].set_title(logs[i], size=title_size)
ax[i].minorticks_on()
ax[i].grid(which='major', linestyle='-', linewidth='0.5', color='lime')
ax[i].grid(which='minor', linestyle=':', linewidth='0.5', color='black')
if column_min!=None and column_max!=None:
# x-axis limits defined
ax[i].set_xlim(column_min[i], column_max[i])
if min_depth!=None and max_depth!=None:
# y-axis limit defined
ax[i].set_ylim(min_depth, max_depth)
ax[i].invert_yaxis()
else:
# colors are defined (as list)
for i in range(len(logs)):
if i == column_semilog:
# for resistivity, semilog plot
ax[i].semilogx(df[logs[i]], df[column_depth], color=colors[i])
else:
# for non-resistivity, normal plot
ax[i].plot(df[logs[i]], df[column_depth], color=colors[i])
ax[i].set_title(logs[i], size=title_size)
ax[i].minorticks_on()
ax[i].grid(which='major', linestyle='-', linewidth='0.5', color='lime')
ax[i].grid(which='minor', linestyle=':', linewidth='0.5', color='black')
if column_min!=None and column_max!=None:
# x-axis limits defined
ax[i].set_xlim(column_min[i], column_max[i])
if min_depth!=None and max_depth!=None:
# y-axis limit defined
ax[i].set_ylim(min_depth, max_depth)
ax[i].invert_yaxis()
# ---------------------------------------------------------------------------
# NEW: draw formation tops AND put the text label on each line
# ---------------------------------------------------------------------------
if fm_tops!=None and fm_depths!=None:
# produce a stable colour per top
rgb = [(random.random(), random.random(), random.random())
for _ in fm_tops]
for i in range(len(logs)):
for j, top in enumerate(fm_tops):
depth = fm_depths[j]
ax[i].axhline(y=depth, linestyle=":", c=rgb[j])
# place the formation‐name text slightly inside the left axis
xmin, xmax = ax[i].get_xlim()
xpos = xmin + 0.02 * (xmax - xmin) # 2 % from left edge
ax[i].text(
xpos, depth, top,
color=rgb[j], va='center', ha='left',
fontsize=7,
bbox=dict(boxstyle="round,pad=0.2", fc="white", alpha=0.6)
)
if tight_layout:
plt.tight_layout()
plt.show()