跳转到主要内容

使用TileDB快速访问地震数据的Python库

项目描述

TileDB logo

GitHub Actions status

TileDB-Segy

TileDB-Segy是一个小巧的MIT许可Python库,用于轻松与地震数据交互,由TileDB提供支持。它结合了一个直观的、类似segyio的API和一个强大的存储引擎。

功能摘要

可用功能

  • 将SEG-Y和Seismic Unix格式的地震数据转换为TileDB数组。
  • 简单而强大的只读API,紧密模拟自 segyio
  • 100% 单元测试覆盖率。
  • 完全类型注解。

目前缺少的功能

  • 写操作API。
  • 转换回SEG-Y。
  • TileDB配置和性能调整。
  • 全面文档。
  • 实际应用。

安装

TileDB-Segy可以通过

  • PyPI 使用 pip 安装

    pip install tiledb-segy
    
  • 通过克隆Git仓库从源代码安装

    git clone https://github.com/TileDB-Inc/TileDB-Segy.git
    cd TileDB-Segy
    pip install .
    

    你可以使用以下命令运行测试套件

    python setup.py test
    

从SEG-Y转换

TileDB-Segy附带一个命令行界面(CLI),称为 segy2tiledb,用于将SEG-Y和Seismic Unix格式的文件转换为TileDB格式的数组。它至少需要一个输入文件,并在同一父目录下生成一个名为 .tsgy 的目录

$ segy2tiledb a123.segy
$ du -sh a123.*
73M a123.sgy
55M a123.tsgy

要查看完整的选项列表,请运行

$ segy2tiledb -h
usage: segy2tiledb [-h] [-o] [-g {auto,structured,unstructured}] [--su]
                   [--iline ILINE] [--xline XLINE]
                   [--endian {big,msb,little,lsb}] [-s TILE_SIZE]
                   input [output]

Convert a SEG-Y file to tiledb-segy format

positional arguments:
  input                 Input SEG-Y file path
  output                Output directory path (default: None)

optional arguments:
  -h, --help            show this help message and exit
  -o, --overwrite       Overwrite the output directory if it already exists (default: False)
  -g {auto,structured,unstructured}, --geometry {auto,structured,unstructured}
                        Output geometry:
                        - auto: same as the input SEG-Y.
                        - structured: same as `auto` but abort if a geometry cannot be inferred.
                        - unstructured: opt out on building geometry information.
                         (default: auto)

segyio options:
  --su                  Open a seismic unix file instead of SEG-Y (default: False)
  --iline ILINE         Inline number field in the trace headers (default: 189)
  --xline XLINE         Crossline number field in the trace headers (default: 193)
  --endian {big,msb,little,lsb}
                        File endianness, big/msb (default) or little/lsb (default: big)

tiledb options:
  -s TILE_SIZE, --tile-size TILE_SIZE
                        Tile size in bytes.
                        Larger tile size improves disk access time at the cost of higher memory (default: 4000000)

API

TileDB-Segy通常遵循 segyio API;您可以参考其文档了解公共属性(ilinesxlinesoffsetssamples)和寻址模式(traceheaderattributesilinexlinefastslowdepth_slicegathertextbin)。

您可以在以下Jupyter笔记本中找到使用示例

与segyio的差异

  • segyio 中返回numpy数组生成器的寻址模式,在 tiledb-segy 中返回更高维度的单个numpy数组。例如,在一个具有50个ilines、20个xlines、100个samples和3个offsets的SEG-Y中

    • f.iline[0:5]:
      • segyio 返回一个生成器,产生5个形状为(20,100)的二维numpy数组
      • tiledb-segy 返回一个形状为(5,20,100)的三维numpy数组
    • f.iline[0:5, :]:
      • segyio 返回一个生成器,产生15个形状为(20,100)的二维numpy数组
      • tiledb-segy 返回一个形状为(5,3,20,100)的四维numpy数组
  • binheaderattributes(name) 返回的映射使用字符串键而不是 segyio.TraceField 枚举或整数。

  • tiledb.segy.open(dir_path),相当于 segyio.open(file_path),不接受任何可选参数(例如 strictignore_geometry)。

  • 非结构化和结构化SEG-Y分别表示为两个不同类的实例,分别是 tiledb.segy.Segytiledb.segy.StructuredSegy

    • StructuredSegy 扩展 Segy,因此整个非结构化API都由结构化API继承。
    • 所有特定于结构化文件的属性和寻址模式(例如 ilinesgather)仅对 StructuredSegy 可用。相比之下,segyio 在访问非结构化文件上的这些属性时返回 None 或引发异常。
    • segyio.tools.dt 作为 Segy.dt(fallback=4000.0) 方法公开。
    • segyio.tools.cube 作为 StructuredSegy.cube() 方法公开。
    • 没有 unstructured 属性;请使用 not isinstance(f, StructuredSegy) 代替。
  • 没有 tracecount 属性;请使用 len(trace) 代替。

  • 没有 ext_headers 属性;请使用 len(text[1:]) 代替。

项目详情


下载文件

下载适合您平台的文件。如果您不确定该选择哪一个,请了解有关安装包的更多信息。

源分发

tiledb-segy-0.3.1.tar.gz (16.3 kB 查看哈希值)

上传时间

构建分发

tiledb_segy-0.3.1-py3-none-any.whl (16.1 kB 查看哈希值)

上传时间 Python 3

支持