-
Notifications
You must be signed in to change notification settings - Fork 12
/
ts_generator.pysh
150 lines (105 loc) · 4.98 KB
/
ts_generator.pysh
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
#!/usr/bin/env python3
# python loglan
# Imports
import math
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import pandas as pd
import geolog
import numpy as np
from PIL import Image
#from colorama import Fore, Style
k=0
# Load data from geolog
while geolog.getrow():
Por = phie
Perm = perm
# =============================================================================
# # ===========================================================================
# # #--------------------------------------------------------------------------
# # # Read/Write Spreadsheet
# # # Read in data which is Gathered Thin Section Data
# # #--------------------------------------------------------------------------
# # ===========================================================================
# =============================================================================
#read the file
file = r'./data/Clastic_TS_Altair_Geolog.xlsx'
CoreTSdata = pd.read_excel(file,index_col=False)
Index=CoreTSdata['Sample']
Porosity_TS=CoreTSdata['Porosity']
Permeability_TS=CoreTSdata['Permeability']
Path_TS=CoreTSdata['image']
# =============================================================================
# # ===========================================================================
# # #--------------------------------------------------------------------------
# # #
# # # This is the beginnin of Inverse Distance^2
# # # to select a representative Thin Section
# # #
# # #--------------------------------------------------------------------------
# # ===========================================================================
# =============================================================================
# lev = float(input("Enter level in well = "))
# for k in range(0,rows_data,1):
# for k in range(925,1645,1):
# TS_image = []
por = (Por-por_min)/(por_max - por_min)
perm= (math.log10(Perm) - perm_min)/(perm_max - perm_min)
dist_inv = []
dist_phi = []
dist_lperm = []
TS = []
inv_dist_array = []
dist_inv_total = 0
Porosity_total = 0
Permeability_total = 0
dist_inv = []
dist_phi = []
dist_lperm = []
inv_dist_array2 = []
dist_inv_total=0
#------------------------------------------------------------------------------
# Display the Representative Thin Section
#------------------------------------------------------------------------------
Porosity_norm_ts = []
Permeability_norm_ts = []
#this is the mapinv_reference_data being used using the mapinv Porosity and Permeability vs. por and perm
for i in range(0,len(CoreTSdata),1):
Porosity_norm_ts.append((Porosity_TS[i] - por_min) / (por_max - por_min))
Permeability_norm_ts.append((math.log10(Permeability_TS[i]) - perm_min) / (perm_max - perm_min))
#Euclidian Distance
dist_phi.append( abs(por - Porosity_norm_ts[i] ))
dist_lperm.append( abs(perm - Permeability_norm_ts[i]))
dist_inv.append( 1 / math.sqrt( dist_phi[i]**2 + dist_lperm[i]**2) )
inv_dist_array2.append(dist_inv); # add items
a = np.array(inv_dist_array2)
inv_dist_thresh = np.percentile(a, 99.999)
#plt.figure(2)
for p in range(0,len(CoreTSdata),1):
if dist_inv[p] > inv_dist_thresh - 0.001 and dist_inv[p] > 0.001:
TS = Path_TS[p]
invdist = 1/dist_inv[p]
# Por_TS = Porosity_TS[p]
# Perm_TS = Permeability_TS[p]
# print(" Reference Data: Porosity =",Porosity[p], ", Permeability =", Permeability[p],", Inv Dist '",dist_inv[i],TS)
# print(Fore.GREEN +" Porosity =",Porosity_TS[p], ", Permeability =", Permeability_TS[p])
# print(Fore.GREEN +" Inv Dist '",dist_inv[p],", TS Image =", Path_TS[p])
# img=mpimg.imread(TS)
# imgplot = plt.imshow(img)
# plt.show()
# else:
# TS = 'blank.PNG'
# Por_TS = 0
# Perm_TS = 0
# img=mpimg.imread(TS)
# ------------------------------------------------------------------------------
# Console Plots turned off for now
# ------------------------------------------------------------------------------
image=TS
####print()
print("Depth =", depth, "Por =", Por, "Perm =", Perm, "Inv Dist =", dist_inv[i], 'Thin Section =', image)
#img = mpimg.imread(TS)
########imgplot = plt.imshow(img)
#######plt.show()
# Store data into geolog
geolog.putrow()