# segyio #
[](https://travis-ci.org/equinor/segyio)
[](https://ci.appveyor.com/project/statoil-travis/segyio)
[](https://pyup.io/repos/github/equinor/segyio/)
[](https://pyup.io/repos/github/equinor/segyio/)
[readthedocs](https://segyio.readthedocs.io/)
## Index ##
* [Introduction](#introduction)
* [Feature summary](#feature-summary)
* [Getting started](#getting-started)
* [Quick start](#quick-start)
* [Get segyio](#get-segyio)
* [Build segyio](#build-segyio)
* [Tutorial](#tutorial)
* [Basics](#basics)
* [Modes](#modes)
* [Mode examples](#mode-examples)
* [Goals](#project-goals)
* [Contributing](#contributing)
* [Examples](#examples)
* [Common issues](#common-issues)
* [History](#history)
## Introduction ##
Segyio is a small LGPL licensed C library for easy interaction with SEG-Y and
Seismic Unix formatted seismic data, with language bindings for Python and
Matlab. Segyio is an attempt to create an easy-to-use, embeddable,
community-oriented library for seismic applications. Features are added as they
are needed; suggestions and contributions of all kinds are very welcome.
To catch up on the latest development and features, see the
[changelog](changelog.md). To write future proof code, consult the planned
[breaking changes](breaking-changes.md).
## Feature summary ##
* A low-level C interface with few assumptions; easy to bind to other
languages
* Read and write binary and textual headers
* Read and write traces and trace headers
* Simple, powerful, and native-feeling Python interface with numpy
integration
* Read and write seismic unix files
* xarray integration with netcdf_segy
* Some simple applications with unix philosophy
## Getting started ##
When segyio is built and installed, you're ready to start programming! Check
out the [tutorial](#tutorial), [examples](#examples), [example
programs](python/examples), and [example
notebooks](https://github.com/equinor/segyio-notebooks). For a technical
reference with examples and small recipes, [read the
docs](https://segyio.readthedocs.io/). API docs are also available with pydoc -
start your favourite Python interpreter and type `help(segyio)`, which should
integrate well with IDLE, pycharm and other Python tools.
### Quick start ###
```python
import segyio
import numpy as np
with segyio.open('file.sgy') as f:
for trace in f.trace:
filtered = trace[np.where(trace < 1e-2)]
```
See the [examples](#examples) for more.
### Get segyio ###
A copy of segyio is available both as pre-built binaries and source code:
* In Debian [unstable](https://packages.debian.org/source/sid/segyio)
* `apt install python3-segyio`
* Wheels for Python from [PyPI](https://pypi.python.org/pypi/segyio/)
* `pip install segyio`
* Source code from [github](https://github.com/equinor/segyio)
* `git clone https://github.com/statoil/segyio`
* Source code in [tarballs](https://github.com/equinor/segyio/releases)
### Build segyio ###
To build segyio you need:
* A C99 compatible C compiler (tested mostly on gcc and clang)
* A C++ compiler for the Python extension, and C++11 for the tests
* [CMake](https://cmake.org/) version 2.8.12 or greater
* [Python](https://www.python.org/) 2.7 or 3.x.
* [numpy](http://www.numpy.org/) version 1.10 or greater
* [setuptools](https://pypi.python.org/pypi/setuptools) version 28 or greater
* [setuptools-scm](https://pypi.python.org/pypi/setuptools_scm)
* [pytest](https://pypi.org/project/pytest)
To build the documentation, you also need
[sphinx](https://pypi.org/project/Sphinx)
To build and install segyio, perform the following actions in your console:
```bash
git clone https://github.com/equinor/segyio
mkdir segyio/build
cd segyio/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
make
make install
```
`make install` must be done as root for a system install; if you want to
install in your home directory, add `-DCMAKE_INSTALL_PREFIX=~/` or some other
appropriate directory, or `make DESTDIR=~/ install`. Please ensure your
environment picks up on non-standard install locations (PYTHONPATH,
LD_LIBRARY_PATH and PATH).
If you have multiple Python installations, or want to use some alternative
interpreter, you can help cmake find the right one by passing
`-DPYTHON_EXECUTABLE=/opt/python/binary` along with install prefix and build
type.
To build the matlab bindings, invoke CMake with the option `-DBUILD_MEX=ON`. In
some environments the Matlab binaries are in a non-standard location, in which
case you need to help CMake find the matlab binaries by passing
`-DMATLAB_ROOT=/path/to/matlab`.
#### Developers ####
It's recommended to build in debug mode to get more warnings and to embed debug
symbols in the objects. Substituting `Debug` for `Release` in the
`CMAKE_BUILD_TYPE` is plenty.
Tests are located in the language/tests directories, and it's highly
recommended that new features added are demonstrated for correctness and
contract by adding a test. All tests can be run by invoking `ctest`. Feel free
to use the tests already written as a guide.
After building segyio you can run the tests with `ctest`, executed from the
build directory.
Please note that to run the Python examples you need to let your environment
know where to find the Python library. It can be installed as a user, or on
adding the segyio/build/python library to your pythonpath.
## Tutorial ##
All code in this tutorial assumes segyio is imported, and that numpy is
available as np.
```python
import segyio
import numpy as np
```
This tutorial assumes you're familiar with Python and numpy. For a refresh,
check out the [python tutorial](https://docs.python.org/3/tutorial/) and [numpy
quickstart](https://docs.scipy.org/doc/numpy-dev/user/quickstart.html)
### Basics ###
Opening a file for reading is done with the `segyio.open` function, and
idiomatically used with context managers. Using the `with` statement, files are
properly closed even in the case of exceptions. By default, files are opened
read-only.
```python
with segyio.open(filename) as f:
...
```
Open accepts several options (for more a more comprehensive reference, check
the open function's docstring with `help(segyio.open)`. The most important
option is the second (optional) positional argument. To open a file for
writing, do `segyio.open(filename, 'r+')`, from the C `fopen` function.
Files can be opened in *unstructured* mode, either by passing `segyio.open` the
optional arguments `strict=False`, in which case not establishing structure
(inline numbers, crossline numbers etc.) is not an error, and
`ignore_geometry=True`, in which case segyio won't even try to set these
internal attributes.
The segy file object has several public attributes describing this structure:
* `f.ilines`
Inferred inline numbers
* `f.xlines`
Inferred crossline numbers
* `f.offsets`
Inferred offsets numbers
* `f.samples`
Inferred sample offsets (frequency and recording time delay)
* `f.unstructured`
True if unstructured, False if structured
* `f.ext_headers`
The number of extended textual headers
If the file is opened *unstructured*, all the line properties will will be
`None`.
### Modes ###
In segyio, data is retrieved and written through so-called *modes*. Modes are
abstract arrays, or addressing schemes, and change what names and indices mean.
All modes are properties on the file handle object, support the `len` function,
and reads and writes are done through `f.mode[]`. Writes are done with
assignment. Modes support array slicing inspired by numpy. The following modes
are available:
* `trace`
The trace mode offers raw addressing of traces as they are

weixin_38744435
- 粉丝: 373
- 资源: 2万+
最新资源
- 认知方式与空间智能.docx
- 计算机等级考试二级WPSOffice练习系统V1.5
- PHP开发IDE工具PHPStorm配置文件-2025年版
- 基于Resnet与多头自注意力机制的信号识别技术研究:RadioML2018数据集的分类与性能分析,基于Resnet与多头自注意力机制的信号识别系统:性能优化与实验分析报告,多头自注意力机制识别信号
- H3C-S5130-E整本手册.zip
- FPGA运动目标检测仿真代码-基于正点原子达芬奇硬件与Vivado quartus软件的ov5640配置及HDMI仿真实现,FPGA运动目标检测仿真代码-基于正点原子达芬奇硬件与Vivado qu
- 信噪比估计算法与特征值、奇异值分解技术的融合应用及Matlab实现方法,基于特征值与奇异值分解的信噪比估计算法研究及Matlab实现方法,不同信号的信噪比估计算法 特征值分解、奇异值分解算法 MDL最
- CATIA DMU转向系统运动仿真:麦弗逊悬架下的独立车轮转向机制探究,CATIA DMU转向系统运动仿真:麦弗逊悬架下的独立车轮转向功能探究,CATIA DMU转向系统运动仿真(可编辑,无参数) 悬
- 数字音频接口光电转换模块
- 星禾AI-DeepSeek新手必看!DeepSeek个人应用全攻略|最全的 DeepSeek 使用指南(建议收藏)
- 数字音频光电转换模块文档
- c++小病毒(时间类型): 会从2025/2/17为起点一直增加时间到8007年
- 2025年及以后的主要战略技术趋势和重大战略预测报告
- 内存池的设计与实现代码之边界标识法
- 基于FVC2002数据集的MATLAB指纹识别系统研究与应用,基于MATLAB的FVC2002指纹数据集识别系统研究与应用,基于MATLAB的指纹识别系统 数据集为FVC2002指纹数据集 ,基于MA
- 配电网光伏储能双层优化配置模型:基于粒子群算法求解选址定容与运行调度联合优化,配电网光伏储能双层优化配置模型:基于粒子群算法的运行-规划联合求解,IEEE33节点案例分析,配电网光伏储能双层优化配置模
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


