pysegy
pysegy
pysegy is a minimal Python library for working with SEGY Rev 1 data. The project provides helpers to read and write files as well as utilities to scan large surveys without loading every trace in memory.
Capabilities
- Read complete SEGY files with
segy_readand access both binary and trace headers. - Write new data sets using
segy_writefrom NumPy arrays. - Lazily inspect large archives via
segy_scanand theSegyScanobject. - Retrieve individual header fields with automatic scaling through
get_header. - Compatible with any
fsspecfilesystem for local or remote storage.
Installation
Install the project in editable mode from the repository root:
python -m pip install -e .Or to install the latest pypi release
pip install pysegy
Testing
Run the unit tests with pytest:
pytest -vsThe tests run automatically on GitHub Actions with coverage reports uploaded to Codecov.
Scan benchmark
The scan benchmark compares sequential and threaded scanning of a file or directory:
python benchmarks/scan_benchmark.py /path/to/large.segy
python benchmarks/scan_benchmark.py /path/to/survey --pattern '*.segy'Without an argument the bundled data directory is scanned. Threading pays off once several files or many shots are involved; a single small file is dominated by the fixed cost of opening it.
Inspiration
This project started as a lightweight port of the Julia package SegyIO.jl. The goal is to provide a similar user experience for Python while keeping the code base small and easy to understand.