Module: LasReader
- Included in:
- CWLSLas
- Defined in:
- lib/las_reader.rb,
lib/las_reader/version.rb
Defined Under Namespace
Classes: Curve, CurveInfo, Mnemonic, WellInfo
Constant Summary
collapse
- VERSION =
"0.0.4"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#curves ⇒ Object
Returns the value of attribute curves.
11
12
13
|
# File 'lib/las_reader.rb', line 11
def curves
@curves
end
|
#parameters ⇒ Object
Returns the value of attribute parameters.
12
13
14
|
# File 'lib/las_reader.rb', line 12
def parameters
@parameters
end
|
#version ⇒ Object
Returns the value of attribute version.
9
10
11
|
# File 'lib/las_reader.rb', line 9
def version
@version
end
|
#well_info ⇒ Object
Returns the value of attribute well_info.
13
14
15
|
# File 'lib/las_reader.rb', line 13
def well_info
@well_info
end
|
#wrap ⇒ Object
Returns the value of attribute wrap.
10
11
12
|
# File 'lib/las_reader.rb', line 10
def wrap
@wrap
end
|
Instance Method Details
#load_file(file_name) ⇒ Object
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
# File 'lib/las_reader.rb', line 163
def load_file(file_name)
temp_array = []
@curves = {}
@parameters = {}
@acurves = []
read_state = 0
unless File.exist?(file_name)
raise "No such file or directory"
end
File.open(file_name).each do |line|
next if line[0].chr == '#'
if line[0].chr == '~'
case line[1].chr
when 'V' read_state = 1
when 'W' @well_info = WellInfo.new
read_state = 2
when 'C' read_state = 3
when 'P' read_state = 4
when 'O' read_state = 5
when 'A' read_state = 6
else
raise "unsupported file format for #{line}"
read_state = 0 end
else
case read_state
when 1
set_version(line.lstrip)
when 2
set_well_info(line.lstrip)
when 3
set_curve_info(line.lstrip)
when 4
set_parameters(line.lstrip)
when 5
set_other_info(line)
when 6
if self.wrap
temp_array = log_wrap_data(line,temp_array)
else
log_nowrap_data(line)
end
end
end
end
end
|
#log_nowrap_data(info) ⇒ Object
153
154
155
156
157
158
159
160
161
|
# File 'lib/las_reader.rb', line 153
def log_nowrap_data(info)
d=info.scan(/[-]?[0-9]+.[0-9]+/)
unless d.nil?
self.curves.each do |k,v|
value = d[@acurves.index(k)].to_f
v.log_data << ((value == @well_info.null_value) ? nil : value)
end
end
end
|
#log_wrap_data(info, temp_array) ⇒ Object
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/las_reader.rb', line 140
def log_wrap_data(info,temp_array)
d=info.scan(/[-]?[0-9]+.[0-9]+/)
a = temp_array + d if not d.nil?
if a.size == self.curves.size
self.curves.each do |k,v|
value = a[@acurves.index(k)].to_f
v.log_data << ((value == @well_info.null_value) ? nil : value)
end
a = []
end
return a
end
|
#set_curve_info(info) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/las_reader.rb', line 28
def set_curve_info(info)
mnemonic = info.match(/(\w+)\s*\.(\S*)\s+(.*):\s*(.*)$/)
unless mnemonic.nil?
@curves["#{mnemonic[1]}"] = Curve.new(mnemonic[1],mnemonic[2],mnemonic[3],mnemonic[4])
@acurves << mnemonic[1]
end
end
|
#set_other_info(info) ⇒ Object
137
138
|
# File 'lib/las_reader.rb', line 137
def set_other_info(info)
end
|
#set_parameters(info) ⇒ Object
36
37
38
39
40
41
|
# File 'lib/las_reader.rb', line 36
def set_parameters(info)
mnemonic = info.match(/(\w+)\s*\.(\S+)\s+(.*):\s*(.*)$/)
unless mnemonic.nil?
@parameters["#{mnemonic[1]}"] = Mnemonic.new(mnemonic[1],mnemonic[2],mnemonic[3],mnemonic[4])
end
end
|
#set_version(info) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/las_reader.rb', line 15
def set_version(info)
version = info.match(/(VERS\s*\.).+([1-3]\.[0-9]).*:\s*(.*)/)
if version.nil?
wrap_mode = info.match(/(WRAP\s*\.).+(YES|NO).*:\s*(.*)/)
if not wrap_mode.nil?
@wrap = (wrap_mode[2] == "YES") ? true : false
end
else
@version = version[2]
raise "LAS version not supported" if @version.to_f > 2.0
end
end
|
#set_well_info(info) ⇒ Object
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
|
# File 'lib/las_reader.rb', line 43
def set_well_info(info)
strt = info.match(/(STRT)\s*\.(\w).+\s([0-9]+\.[0-9]+).*:\s*(.*)/)
unless strt.nil?
@well_info.start_depth = strt[3].to_f
@well_info.depth_unit = strt[2]
return
end
stop = info.match(/(STOP)\s*\.(\w).+\s([0-9]+\.[0-9]+).*:\s*(.*)/)
unless stop.nil?
@well_info.stop_depth = stop[3].to_f
return
end
step = info.match(/(STEP)\s*\.(\w).+\s(-?[0-9]+\.[0-9]+).*:\s*(.*)/)
unless step.nil?
@well_info.step = step[3].to_f
return
end
null = info.match(/(NULL)\s*\..+\s(-?[0-9]+\.[0-9]+).*:\s*(.*)/)
unless null.nil?
@well_info.null_value = null[2].to_f
return
end
comp = info.match(/(COMP\s*\..+COMPANY:\s*(.*))|(COMP\s*\.\s*(.*)\s+:\s*COMPANY)/)
unless comp.nil?
@well_info.company_name = (comp[2] or comp[4]).strip
return
end
well = info.match(/(WELL\s*\..+WELL:\s*(.*))|(WELL\s*\.\s*(.*)\s+:\s*WELL)/)
unless well.nil?
@well_info.well_name = (well[2] or well[4]).strip
return
end
fld = info.match(/(FLD\s*\..+FIELD:\s*(.*))|(FLD\s*\.\s*(.*)\s+:\s*FIELD)/)
unless fld.nil?
@well_info.field_name = (fld[2] or fld[4]).strip
return
end
loc = info.match(/(LOC\s*\..+LOCATION:\s*(.*))|(LOC\s*\.\s*(.*)\s+:\s*LOCATION)/)
unless loc.nil?
@well_info.location = (loc[2] or loc[4]).strip
return
end
prov = info.match(/(PROV\s*\..+PROVINCE:\s*(.*))|(PROV\s*\.\s*(.*)\s+:\s*PROVINCE)/)
unless prov.nil?
@well_info.province = (prov[2] or prov[4]).strip
return
end
cnty = info.match(/(CNTY\s*\..+COUNTY:\s*(.*))|(CNTY\s*\.\s*(.*)\s+:\s*COUNTY)/)
unless cnty.nil?
@well_info.county = (cnty[2] or cnty[4]).strip
return
end
stat = info.match(/(STAT\s*\..+STATE:\s*(.*))|(STAT\s*\.\s*(.*)\s+:\s*STATE)/)
unless stat.nil?
@well_info.state = (stat[2] or stat[4]).strip
return
end
ctry = info.match(/(CTRY\s*\..+COUNTRY:\s*(.*))|(CTRY\s*\.\s*(.*)\s+:\s*COUNTRY)/)
unless ctry.nil?
@well_info.country = (ctry[2] or ctry[4]).strip
return
end
srvc = info.match(/(SRVC\s*\..+SERVICE COMPANY:\s*(.*))|(SRVC\s*\.\s*(.*)\s+:\s*SERVICE COMPANY)/)
unless srvc.nil?
@well_info.service_company = (srvc[2] or srvc[4]).strip
return
end
data = info.match(/(DATE\s*\..+LOG DATE:\s*(.*))|(DATE\s*\.\s*(.*)\s+:\s*LOG DATE)/)
unless data.nil?
@well_info.date_logged = (data[2] or data[4]).strip
return
end
uwi = info.match(/(UWI\s*\..+UNIQUE WELL ID:\s*(.*))|(UWI\s*\.\s*(.*)\s+:\s*UNIQUE WELL ID)/)
unless uwi.nil?
@well_info.uwi = (uwi[2] or uwi[4]).strip
return
end
end
|