Skip to content

Reading

Henryk Modzelewski edited this page Oct 4, 2019 · 2 revisions

SegyIO's segy_read function is used to read entire SEGY files. The file will be returned in a SeisBlock object, which contains the data array, a vector of BinaryTraceHeader objects, and a BinaryFileHeader.

Example

First start up Julia, load the package, and move into the directory storing the example SEGY file.

julia> using SegyIO
julia> cd(joinpath(SegyIO.myRoot,"data"))

Reading a file is a simple as passing the file path to the reader

julia> block = segy_read("overthrust_2D_shot_1_20.segy");

Of course, the file does not need to be in the pwd.

julia> block = segy_read(joinpath(SegyIO.myRoot,"data","overthrust_2D_shot_1_20.segy"));

SegyIO currently requires fixed trace length (variable trace length might be added in the future), and will warn if the fixed trace length flag is not set in the file header.

The reader returns the contents of the SEGY file in a SeisBlock composite type. This type contains:

  • The FileHeader, containing the textual and binary file headers
  • A vector of BinaryTraceHeaders, one for each trace
  • The trace data collected into an array (nsamples x ntraces)

Show methods for BinaryTraceHeaders and FileHeaders are provided

julia> block.fileheader
BinaryFileHeader:
                                Job:         1
                               Line:         1
                               Reel:         1
               DataTracePerEnsemble:         1
          AuxiliaryTracePerEnsemble:         0
                                 dt:      4000
                             dtOrig:         0
                                 ns:       751
                             nsOrig:         0
                   DataSampleFormat:         1
                       EnsembleFold:         0
                       TraceSorting:         0
                    VerticalSumCode:         0
                SweepFrequencyStart:         0
                  SweepFrequencyEnd:         0
                        SweepLength:         0
                          SweepType:         0
                       SweepChannel:         0
              SweepTaperlengthStart:         0
                SweepTaperLengthEnd:         0
                          TaperType:         0
               CorrelatedDataTraces:         0
                         BinaryGain:         0
            AmplitudeRecoveryMethod:         0
                  MeasurementSystem:         0
              ImpulseSignalPolarity:         0
              VibratoryPolarityCode:         0
           SegyFormatRevisionNumber:         0
               FixedLengthTraceFlag:         0
          NumberOfExtTextualHeaders:         0

SegyIO provides the option of reading only user-specified BinaryTraceHeader values from disk. This allows the reader to only focus on what matters, and can improve performance considerably.

julia> @elapsed segy_read(joinpath(SegyIO.myRoot,"data","overthrust_2D_shot_1_20.segy"));
0.105732397

julia> @elapsed segy_read(joinpath(SegyIO.myRoot,"data","overthrust_2D_shot_1_20.segy"), ["SourceX"; "SourceY"])
0.012128395

SegyIO's performance comes from parsing metadata in memory. This can be toggled using the buffer keyword.

julia> @elapsed segy_read(joinpath(SegyIO.myRoot,"data","overthrust_2D_shot_1_20.segy"), buffer=false)
2.640242233

julia> @elapsed segy_read(joinpath(SegyIO.myRoot,"data","overthrust_2D_shot_1_20.segy"), ["SourceX"; "SourceY"], buffer=false)
0.069372419

To get all values of a BinaryTraceHeader field for an entire block, use get_header

julia> sx = get_header(block, "SourceX")
julia> sy = get_header(block, :SourceY)
julia> typeof(sx)
Array{Int32,1}

The header field values are returned in a vector, trace order is preserved.

Clone this wiki locally