forked from yohanesnuwara/FormationPy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathND_plot.py
More file actions
104 lines (80 loc) · 3.87 KB
/
ND_plot.py
File metadata and controls
104 lines (80 loc) · 3.87 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
def ND_plot(denfl, df, column_nphi, column_rhob, column_hue, color_by,
figsize=(7,7), scatter_size=50, scatter_alpha=0.5):
"""
Producing Neutron-Density (Cross)plot
Input:
denfl is your fluid density
df is your dataframe
column_nphi and column_rhob are the column name of your NPHI and RHOB
column_hue is the column name that you want for the color of the points
e.g. depth, vshale, formation labels, etc.
color_by depends on the column_hue that you're giving
* if you're giving a continuous hue (numerical) like depth or vshale
define color_by='continuous'
* if you're giving a categorical hue (labels) like formation names
define color_by='categorical'
figsize, scatter_size, scatter_alpha are by default. You can also specify
by yourselves.
Output:
3 lines. Blue is sandstone, black is limestone, red is dolomite
Each line has dots representing porosity value from 0 to 0.5
by increment of 0.05
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
plt.style.use('ggplot')
sns.set_theme(color_codes=True)
lsX = np.arange(0, 0.55, 0.05)
ssSNP = 0.222*lsX**2 + 1.021*lsX + 0.024
dolSNP = 0.6*lsX**2 + 0.749*lsX - 0.00434
ssCNL = 0.222*lsX**2 + 1.021*lsX + 0.039
dolCNL = 1.40*lsX**2 + 0.389*lsX - 0.01259
ssSnpX = np.empty((np.size(lsX),0), float)
dolSnpX = np.empty((np.size(lsX),0), float)
ssCnlX = np.empty((np.size(lsX),0), float)
dolCnlX = np.empty((np.size(lsX),0), float)
for i in np.nditer(lsX):
ssSnpX = np.append(ssSnpX, np.roots([0.222, 1.021, 0.024 - i])[1])
dolSnpX = np.append(dolSnpX, np.roots([0.6, 0.749, -0.00434 - i])[1])
ssCnlX = np.append(ssCnlX, np.roots([0.222, 1.021, 0.039 - i])[1])
dolCnlX = np.append(dolCnlX, np.roots([1.40, 0.389, -0.01259 - i])[1])
densma_Ls = 2.71; densma_Ss = 2.65; densma_Dol = 2.87 #densma: density matrix
denLs = (denfl - densma_Ls) * lsX + densma_Ls
denSs = (denfl - densma_Ss) * lsX + densma_Ss
denDol = (denfl - densma_Dol) * lsX + densma_Dol
if color_by == 'continuous':
# plot data with color of the continuous variable defined (depth, vsh, etc.)
plt.figure(figsize=figsize)
plt.scatter(df[column_nphi], df[column_rhob], c=df[column_hue],
alpha=scatter_alpha, cmap='viridis')
plt.colorbar()
# plot the sand, limestone, and dolomite line (using Seaborn)
plt.plot(ssCnlX, denSs, '.-', color='blue', markersize=10, label = 'Sandstone')
plt.plot(lsX, denLs, '.-', color='black', markersize=10, label = 'Limestone')
plt.plot(dolCnlX, denDol, '.-', color='red', markersize=10, label = 'Dolomite')
plt.title('Neutron-Density Plot', size=20, pad=15)
plt.xlim(-0.05, 0.45)
plt.ylim(3, 1.9)
plt.xlabel('NPHI (v/v)'); plt.ylabel('RHOB (g/cc)')
if color_by == 'categorical':
# plot data with color of each formation names (using Seaborn)
lm = sns.lmplot(data=df, x=column_nphi, y=column_rhob, hue=column_hue,
fit_reg=False, height=figsize[0],
scatter_kws={'s': scatter_size, 'alpha': scatter_alpha})
ax = lm.axes
# plot the sand, limestone, and dolomite line (using Seaborn)
lines = pd.DataFrame({'ssCnlX': ssCnlX, 'lsX': lsX, 'dolCnlX': dolCnlX,
'denLs': denLs, 'denSs': denSs, 'denDol': denDol})
sns.lineplot(data=lines, x='ssCnlX', y='denSs', color='blue',
legend=False, marker='o', ax=ax[0,0])
sns.lineplot(data=lines, x='lsX', y='denLs', color='black',
legend=False, marker='o', ax=ax[0,0])
sns.lineplot(data=lines, x='dolCnlX', y='denDol', color='red',
legend=False, marker='o', ax=ax[0,0])
plt.title('Neutron-Density Plot', size=20, pad=15)
plt.xlim(-0.05, 0.45)
plt.ylim(3, 1.9)
plt.xlabel('NPHI (v/v)'); plt.ylabel('RHOB (g/cc)')
plt.show()