-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathread_block_headers.jl
59 lines (49 loc) · 1.57 KB
/
read_block_headers.jl
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
export read_block_headers!
function read_block_headers!(b::BlockScan, keys::Array{String, 1}, ns::Int, dsf::Int, headers)
f = open(b.file)
swap_bytes = bswap_needed(f)
seek(f, b.startbyte)
brange = b.endbyte - b.startbyte
s = IOBuffer(read(f, brange))
ntraces = Int((brange)/(240 + ns*4))
fh = FileHeader()
fh.bfh.ns = ns
fh.bfh.DataSampleFormat = dsf
# Check dsf
datatype = Float32
if fh.bfh.DataSampleFormat == 1
datatype = IBMFloat32
elseif fh.bfh.DataSampleFormat != 5
@error "Data type not supported ($(fh.bfh.DataSampleFormat))"
end
th_b2s = th_byte2sample()
tmph = zeros(UInt8, 240)
# Read each traceheader
for trace in 1:ntraces
read_traceheader!(s, keys, th_b2s, headers[trace]; swap_bytes=swap_bytes, th=tmph)
skip(s, ns*4)
end
end
function read_block_headers!(b::BlockScan, ns::Int, dsf::Int, headers)
f = open(b.file)
swap_bytes = bswap_needed(f)
seek(f, b.startbyte)
brange = b.endbyte - b.startbyte
s = IOBuffer(read(f, brange))
ntraces = Int((brange)/(240 + ns*4))
fh = FileHeader()
fh.bfh.ns = ns; fh.bfh.DataSampleFormat = dsf
# Check dsf
datatype = Float32
if fh.bfh.DataSampleFormat == 1
datatype = IBMFloat32
elseif fh.bfh.DataSampleFormat != 5
@error "Data type not supported ($(fh.bfh.DataSampleFormat))"
end
th_b2s = th_byte2sample()
# Read each traceheader
for trace in 1:ntraces
read_traceheader!(s, th_b2s, headers[trace]; swap_bytes=swap_bytes)
skip(s, ns*4)
end
end