Skip to content

Commit ded192a

Browse files
Initial commit
0 parents  commit ded192a

19 files changed

+869856
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

Database.xls

364 KB
Binary file not shown.

LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2018, Adewale Amosu
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
* Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

LICENSE.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Copyright <2017> <Adewale Amosu, Hamdi Mahmood>
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

PyLogFinder.py

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
#!/usr/bin/python
2+
#
3+
#
4+
#(c) 2017 Adewale Amosu
5+
#
6+
#
7+
###############################
8+
9+
import xlrd
10+
import sys
11+
import numpy as np
12+
import os
13+
import mmap
14+
import pprint
15+
import sys
16+
import matplotlib.pyplot as plt
17+
from matplotlib import colors
18+
from matplotlib.ticker import MultipleLocator
19+
import re
20+
21+
##############################
22+
print " "
23+
print " ------------------------------------------------------------------------------------------------"
24+
print " PyLogFinder.py: Program to check if specific logs are in multiple LAS files using any Mnemonic "
25+
print " (c) 2017 Authors: Adewale Amosu, Hamdi Mahmood"
26+
print " Texas A&M University"
27+
print " ------------------------------------------------------------------------------------------------"
28+
print " "
29+
print " Number of arguments: ", len(sys.argv)
30+
print " "
31+
print " The arguments are: " , str(sys.argv)
32+
print " "
33+
34+
35+
if len(sys.argv) <=1:
36+
print " ------------------------------------------------------------------------------------------------"
37+
print " "
38+
print " Usage: python PyLogFinder.py Foldername_containing_LAS_files, List_of_Mnemonics_separated_by_commas"
39+
print " "
40+
print " e.g: python PyLogFinder.py TEST_DATA,DT,DTS,GR,LLD,PE"
41+
print " "
42+
print " See 'Database.xls' for full list of Mnemonics or to add new Mnemonics"
43+
print " "
44+
print " ------------------------------------------------------------------------------------------------"
45+
sys.exit(1)
46+
47+
strval2 = sys.argv[1].split(',')
48+
strval=strval2[1:]
49+
#print strval
50+
51+
if len(strval2) <2:
52+
print " ------------------------------------------------------------------------------------------------"
53+
print " "
54+
print " Usage: python PyLogFinder.py Foldername_containing_LAS_files, List_of_Mnemonics_separated_by_commas"
55+
print " "
56+
print " e.g: python PyLogFinder.py TEST_DATA,DT,DTS,GR,LLD,PE"
57+
print " "
58+
print " See 'Database.xls' for full list of Mnemonics or to add new Mnemonics"
59+
print " "
60+
print " ------------------------------------------------------------------------------------------------"
61+
sys.exit(1)
62+
63+
64+
###############################
65+
## folder,store files in array
66+
#
67+
foldername=strval2[0]
68+
print " FolderName:", foldername
69+
print " "
70+
71+
dirlist=os.listdir(foldername)
72+
files=[]
73+
for filename in dirlist:
74+
if ".LAS" in filename:
75+
files.append('./'+foldername+'/'+filename)
76+
for filename in dirlist:
77+
if ".las" in filename:
78+
files.append('./'+foldername+'/'+filename)
79+
## print files
80+
##############################
81+
82+
83+
##############################
84+
#Extract from Database
85+
#
86+
data = xlrd.open_workbook('Database.xls')
87+
sheetname = data.sheet_names()
88+
logall = data.sheet_by_index(0)
89+
90+
valMN = [c.value for c in logall.col(0)]
91+
valTY = [c.value for c in logall.col(2)]
92+
valUN = [c.value for c in logall.col(3)]
93+
valDE = [c.value for c in logall.col(4)]
94+
#Print Data
95+
#for k in range(0, len(valMN)):
96+
# print valMN[k]," : ", valTY[k]," : ", valDE[k]
97+
#############################
98+
99+
100+
##############################
101+
# index2checkm
102+
inputind = []
103+
checkm =[]
104+
for k in range(0, len(strval)):
105+
inputind.append(valMN.index(strval[k]))
106+
ind1 = valMN.index(strval[k])
107+
checkm.append((valTY[ind1]))
108+
print " ", strval[k], inputind[k], checkm[k]
109+
##############################
110+
111+
112+
113+
#############################
114+
# Extract Mnemonics, grep in file, results store in 2D array
115+
#results = [[0 for _ in range(0, len(files))] for _ in range(0, len(checkm))]
116+
#pprint.pprint(results)
117+
results=np.zeros(shape=(len(files), len(checkm)))
118+
#pprint.pprint(results)
119+
120+
for j in range(0, len(files)):
121+
print " ------------------------------------------------------"
122+
for k in range(0, len(checkm)):
123+
print " "
124+
indices = [i for i, x in enumerate(valTY) if x == checkm[k]]
125+
grepL = np.array(valMN)[indices]
126+
#print checkm[k], indices
127+
for mnem in grepL:
128+
#if mnem+'.' in open(files[j]).read():
129+
f = open(files[j])
130+
s = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
131+
#if s.find(mnem) != -1:
132+
if re.search(r'\b' + mnem + r'\b', s):
133+
results[j][k]=1
134+
print " ",j,k, files[j], mnem, results[j][k]
135+
break
136+
137+
#pprint.pprint(results)
138+
139+
#############################
140+
# print result to screen and files
141+
f = open(foldername+"_Results.txt",'w')
142+
print " "
143+
sys.stdout.write(" ")
144+
sys.stdout.write("Files ")
145+
f.write("Files ")
146+
for k in range(0, len(strval)):
147+
sys.stdout.write(strval[k]+" ")
148+
f.write(strval[k]+" ")
149+
print " "
150+
f.write('\n')
151+
for j in range(0, len(files)):
152+
#print(files[j], " ", end='')
153+
sys.stdout.write(" ")
154+
sys.stdout.write(files[j])
155+
sys.stdout.write(" ")
156+
f.write(str(files[j]))
157+
f.write(" ")
158+
for k in range(0, len(checkm)):
159+
#print results[j, k]
160+
sys.stdout.write(" ")
161+
sys.stdout.write("%d " % (results[j,k]))
162+
sys.stdout.write(" ")
163+
f.write(str(results[j,k]))
164+
f.write(" ")
165+
print " "
166+
f.write('\n')
167+
168+
f.close()
169+
170+
171+
172+
##################################
173+
#Plots
174+
row_labels=files
175+
col_labels=strval
176+
cmap = colors.ListedColormap(['white', 'springgreen'])
177+
#cmap = colors.ListedColormap(['white', 'red'])
178+
fig, ax = plt.subplots(figsize=(25, 15))
179+
ax.imshow(results, cmap=cmap, interpolation='nearest', aspect='auto')
180+
ax.grid(which='minor', linestyle='-', linewidth=2,alpha=1)
181+
ax.xaxis.set_ticks_position("top")
182+
183+
plt.rc('font', size=23)
184+
plt.xticks(range(0, len(strval)), col_labels)
185+
plt.yticks(range(0, len(files)), row_labels)
186+
locs = np.arange(len(row_labels))
187+
for axis in [ax.yaxis]:
188+
axis.set_ticks(locs + 0.5, minor=True)
189+
axis.set(ticks=locs)
190+
locs = np.arange(len(col_labels))
191+
for axis in [ax.xaxis]:
192+
axis.set_ticks(locs + 0.5, minor=True)
193+
axis.set(ticks=locs)
194+
ax.grid(True, which='minor')
195+
plt.gca().set_position([0.25, 0.2, 0.65, 0.7])
196+
#
197+
#save and display
198+
plt.savefig(foldername+"_Results.png")
199+
plt.show()

READ_ME.pdf

50.2 KB
Binary file not shown.

READ_ME.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
PyLogFinder.py
2+
© 2017 Amosu Adewale, Hamdi Mahmood
3+
4+
• PyLogFinder is a python program for automating the process of analyzing a large database of LAS files and selecting the LAS files that contain specific geophysical logs needed. PyLogFinder uses a mnemonic database of 2665 common mnemonics in searching the LAS file database. The mnemonic database can be easily edited and expanded by the user.
5+
• It is written in Python 2.7.3
6+
• Make sure “PyLogFinder.py” is the same directory with the folder containing LAS files and the excel spreadsheet “Database.xls’
7+
• Usage (Type this in Terminal):
8+
python PyLogFinder.py Foldername_containing_LAS_files, List_of_Mnemonics_separated_by_commas
9+
10+
• For example: python
11+
PyLogFinder.py TEST_DATA,DT,DTS,GR,LLD,PE
12+
13+
• See 'Database.xls' for full list of Mnemonics or to add new Mnemonics.
14+

0 commit comments

Comments
 (0)