SegyioLoader
- class segfast.segyio_loader.SegyioLoader(path, endian='big', strict=False, ignore_geometry=True)[source]
A thin wrapper around segyio library for convenient loading of headers and traces.
Most of the methods directly call the public API of segyio.
For trace loading, we use private methods and attributes of
segyio.SegyFile
, which allow:reading data into the pre-defined buffer
read only parts of the trace
This gives up to 50% speed-up over public API for the scenario of loading sequence of traces, and up to 15% over public API in case of loading full lines (inlines or crosslines).
- property sample_interval
Sample interval of seismic traces.
- property delay
Delay recording time of seismic traces.
- load_headers(headers, indices=None, reconstruct_tsf=True, sort_columns=True, return_specs=False, tracewise=True, pbar=False, **kwargs)[source]
Load requested trace headers from a SEG-Y file for each trace into a dataframe. If needed, we reconstruct the
'TRACE_SEQUENCE_FILE'
manually be re-indexing traces.- Parameters:
headers (sequence) –
- An array-like where each element can be:
str
– header name,int
– header starting byte,TraceHeaderSpec
– used as is,tuple
– args to initTraceHeaderSpec
,dict
– kwargs to initTraceHeaderSpec
.
Note that for
SegyioLoader
all nonstandard headers byte positions and dtypes will be ignored.indices (sequence or None) – Indices of traces to load trace headers for. If not given, trace headers are loaded for all traces.
reconstruct_tsf (bool) – Whether to reconstruct
TRACE_SEQUENCE_FILE
manually.sort_columns (bool) – Whether to sort columns in the resulting dataframe by their starting bytes.
return_specs (bool) – Whether to return header specs used to load trace headers.
tracewise (bool) – Whether to iterate over the file in a trace-wise manner, instead of header-wise.
pbar (bool, str) – If
bool
, then whether to display the progress bar over the file sweep. Ifstr
, then type of progress bar to display:'t'
for textual,'n'
for widget.
- Return type:
pandas.DataFrame
- make_headers_specs(headers)[source]
Transform headers list to list of
TraceHeaderSpec
instances.
- load_traces(indices, limits=None, buffer=None)[source]
Load traces by their indices. By pre-allocating memory for all of the requested traces, we significantly speed up the process.
- Parameters:
indices (sequence) – Indices (
TRACE_SEQUENCE_FILE
) of the traces to read.limits (sequence of ints, slice, optional) – Slice of the data along the depth axis.
buffer (numpy.ndarray, optional) – Buffer to read the data into. If possible, avoids copies.
- load_depth_slices(indices, buffer=None)[source]
Load horizontal (depth) slices of the data. Requires an almost full sweep through SEG-Y, therefore is slow.
- Parameters:
indices (sequence) – Indices (ordinals) of the depth slices to read.
buffer (numpy.ndarray, optional) – Buffer to read the data into. If possible, avoids copies.
- Return type:
- make_chunk_iterator(chunk_size=None, n_chunks=None, limits=None, buffer=None)[source]
Create an iterator over the entire file traces in chunks.
Each chunk contains no more than
chunk_size
traces. Ifchunk_size
is not provided andn_chunks
is given instead, there are no more thann_chunks
chunks. One and only one ofchunk_size
andn_chunks
should be provided.Each element in the iterator is a dictionary with
'data'
,'start'
and'end'
keys.- Parameters:
chunk_size (int, optional) – Maximum size of the chunk.
n_chunks (int, optional) – Maximum number of chunks.
limits (sequence of ints, slice, optional) – Slice of the data along the depth (last) axis. Passed directly to
load_traces()
.buffer (numpy.ndarray, optional) – Buffer to read the data into. If possible, avoids copies. Passed directly to
load_traces()
.
- Returns:
iterator, info (tuple with two elements)
iterator (iterable) – An iterator over the entire SEG-Y traces. Each element in the iterator is a dictionary with
'data'
,'start'
and'end'
keys.info (dict) – Description of the iterator with
'chunk_size'
,'n_chunks'
,'chunk_starts'
and'chunk_ends'
keys.
- chunk_iterator(chunk_size=None, n_chunks=None, limits=None, buffer=None)[source]
A shorthand for
make_chunk_iterator()
with no info returned.
- class segfast.segyio_loader.SafeSegyioLoader(path, endian='big', strict=False, ignore_geometry=True)[source]
A thin wrapper around segyio library for convenient loading of headers and traces.
Unlike
SegyioLoader
, uses only public APIs to load traces.Used mainly for performance measurements.