segyio

raw JSON →
1.9.14 verified Mon Apr 27 auth: no python

segyio is a library for simple and fast reading and writing of SEG-Y files, a standard format for seismic data. Version 1.9.14 requires Python >=3.10. It is widely used in geoscience for efficient seismic data I/O. Release cadence is irregular.

pip install segyio
error ImportError: cannot import name 'tools' from 'segyio'
cause segyio.tools module was removed in version 1.9 or later.
fix
Update code to use the main segyio functions: segyio.open() instead of segyio.tools.wrap().
error AttributeError: 'SegyFile' object has no attribute 'trace_count'
cause The correct attribute is 'tracecount' (no underscore).
fix
Use segyfile.tracecount instead of segyfile.trace_count.
gotcha Trace headers are accessed via numpy structured arrays; use segyfile.header[trace_index] and to modify use segyfile.header[trace_index] = new_values. Incorrect indexing can cause silent corruptions.
fix Always use integer trace indices or slice objects. For example: header = segyfile.header[0].
gotcha The segyio.open() mode parameter defaults to 'r'. For writing, explicitly pass segyio.open('file.sgy', 'r+') or segyio.create(). Doing the wrong mode can cause permission errors.
fix Use segyio.open('file.sgy', 'r+') for read/write on existing files or segyio.create('new.sgy') for new files.
deprecated The segyio.tools module (e.g., segyio.tools.wrap) is deprecated. Prefer using the main segyio functions.
fix Use segyio.open() and segyio.create() directly instead of segyio.tools.

Open a SEG-Y file and display the number of traces.

import segyio
with segyio.open('data.sgy') as segyfile:
    print(f'Number of traces: {segyfile.tracecount}')