Skip to content

Commit

Permalink
fix empty fileheader
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Jan 31, 2024
1 parent 4d74906 commit 2a651d8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SegyIO"
uuid = "157a0f19-4d44-4de5-a0d0-07e2f0ac4dfa"
authors = ["Henryk Modzelewski <[email protected]>"]
version = "0.8.3"
version = "0.8.4"

[deps]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down
7 changes: 2 additions & 5 deletions src/read/read_con.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ function read_con(con::SeisCon, blocks::Array{Int,1};
# Pre-allocate
data = Array{datatype,2}(undef, con.ns, prealloc_traces)
headers = zeros(BinaryTraceHeader, prealloc_traces)
fh = FileHeader()
set_fileheader!(fh.bfh, :ns, con.ns)
set_fileheader!(fh.bfh, :DataSampleFormat, con.dsf)
fh = read_fileheader(con.blocks[1].file)

trace_count = 0
# Read all blocks
Expand Down Expand Up @@ -75,8 +73,7 @@ function read_con(con::SeisCon, keys::Array{String,1}, blocks::Array{Int,1};
# Pre-allocate
data = Array{datatype,2}(undef, con.ns, prealloc_traces)
headers = zeros(BinaryTraceHeader, prealloc_traces)
fh = FileHeader(); set_fileheader!(fh.bfh, :ns, con.ns)
set_fileheader!(fh.bfh, :DataSampleFormat, con.dsf)
fh = read_fileheader(con.blocks[1].file)

trace_count = 0
# Read all blocks
Expand Down
16 changes: 16 additions & 0 deletions src/read/read_fileheader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,19 @@ function read_fileheader(s::IO, keys::Array{String,1}; bigendian::Bool = true)
seek(s, 3600)
return FileHeader(String(th[1:3200]), bfh)
end


"""
# Info
Use: fileheader = read_fileheader(s::String; bigendian::Bool = true)
Returns a binary file header formed using bytes 3200-3600 from the stream 's' that is
automatically opened then closed
"""
function read_fileheader(s::String; bigendian::Bool = true)
open(s) do file
fh = read_fileheader(file; bigendian=bigendian)
return fh
end
end

0 comments on commit 2a651d8

Please sign in to comment.