From 77513d46ee43ba143f2ae6205552d22568e6b5ed Mon Sep 17 00:00:00 2001 From: AtilaSaraiva Date: Fri, 6 Sep 2024 20:00:30 -0600 Subject: [PATCH] making the default value for ntrace to be nothing, to make sure that all the traces are parsed by default on SeisHeaderInfo --- src/ReadWrite/SeisHeaderInfo.jl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ReadWrite/SeisHeaderInfo.jl b/src/ReadWrite/SeisHeaderInfo.jl index e632811..b52a5a1 100644 --- a/src/ReadWrite/SeisHeaderInfo.jl +++ b/src/ReadWrite/SeisHeaderInfo.jl @@ -5,18 +5,19 @@ Print Seis header information to screen. The input is the name of the data file # Arguments -- `ntrace=100000` : Number of traces to analyze +- `ntrace=nothing` : Number of traces to analyze *Credits: AS, 2015* """ -function SeisHeaderInfo(filename::String;ntrace::Integer=100000) +function SeisHeaderInfo(filename::String;ntrace::Union{Integer,Nothing}=nothing) key = fieldnames(Header) nhead = length(key) filename_headers = ParseHeaderName(filename) stream = open(filename_headers) NX = GetNumTraces(filename) + newNTrace = isnothing(ntrace) ? NX : ntrace h = GrabHeader(stream,1) println("Displaying information for ", filename," (",NX," traces):") min_h = zeros(Float32,length(key)) @@ -32,11 +33,11 @@ function SeisHeaderInfo(filename::String;ntrace::Integer=100000) itrace = 2 while itrace <= NX nx = NX - itrace + 1 - ntrace = nx > ntrace ? ntrace : nx + newNTrace = nx > newNTrace ? newNTrace : nx position = 4*nhead*(itrace-1) seek(stream,position) - h1 = read!(stream,Array{Header32Bits}(undef,nhead*ntrace)) - h1 = reshape(h1,nhead,convert(Int,ntrace)) + h1 = read!(stream,Array{Header32Bits}(undef,nhead*newNTrace)) + h1 = reshape(h1,nhead,convert(Int,newNTrace)) for ikey = 1 : length(key) keytype = eval(Meta.parse("typeof(SeisMain.InitSeisHeader().$(string(key[ikey])))")) h2 = reinterpret(keytype,vec(h1[ikey,:])) @@ -49,9 +50,9 @@ function SeisHeaderInfo(filename::String;ntrace::Integer=100000) if (b > max_h[ikey]) max_h[ikey] = b end - mean_h[ikey] += c*ntrace + mean_h[ikey] += c*newNTrace end - itrace += ntrace + itrace += newNTrace end for ikey=1:length(key)