Skip to main content

Compress and decompress seismic data

Project description

seismic-zfp

LGPLv3 License Travis PyPi Version

Python library to convert SEG-Y files to compressed cubes and retrieve arbitrary sub-volumes from these, fast.

Motivation

Reading whole SEG-Y volumes to retrieve, for example, a single time-slice is wasteful.

Copying whole SEG-Y files uncompressed over networks is also wasteful.

This library addresses both issues by implementing the seismic-zfp (.SGZ) format. This format is based on ZFP compression from Peter Lindstrom's paper using the official Python bindings, distributed as zfpy.

ZFP compression enables smoothly varying d-dimensional data in 4d subvolumes to be compressed at a fixed bitrate. The 32-bit floating point values in 4x4x4 units of a 3D post-stack SEG-Y file are well suited to this scheme.

Decomposing an appropriately padded 3D seismic volume into groups of these units which exactly fill one 4KB disk block, compressing these groups, and writing them sequentially to disk yields a file with the following properties:

  • Compression ratio of 2n:1 compression, typically a bitrate of 4 works well, implying a ratio of 8:1
  • The location of any seismic sample is known
  • Arbitrary subvolumes can be read with minimal redundant I/O, for example:
    • Padding IL/XL dimensions with 4, and the z-dimension depending on bitrate
    • Padding IL/XL dimensions with 64 and the z-dimension with 4 (16:1 compression)

Using IL/XL optimized layout

  • Groups of 4 inlines or crosslines can be read with no redundant I/O
  • A single inline can be read and with no additional I/O compared to the SEG-Y best-case scenario (provided at least 4:1 compression ratio)
  • A z-slice can be read by accessing n_traces/16 disk blocks, compared to n_traces disk blocks for SEG-Y

Using z-slice optimized layout

  • A z-slice can be read by accessing just n_traces/4096 disk blocks, compared to n_traces disk blocks for SEG-Y

The seismic-zfp (.SGZ) format also allows for preservation of information in SEG-Y file and trace headers, with compression code identifying constant and varying trace header values and storing these appropriately.

NOTE: Previously the extension .sz was used for seismic-zfp, but has been replaced with .sgz to avoid confusion around the compression algorithm used.

Examples

Full example code is provided here, but the following reference is useful:

Create SGZ files from SEG-Y, and convert back to SEG-Y

from seismic_zfp.conversion import SegyConverter
with SegyConverter("in.sgy") as converter:
    # Create a "standard" SGZ file with 8:1 compression, using in-memory method
    converter.run("out-standard.sgz", bits_per_voxel=4,
                  method="InMemory")
    # Create a "z-slice optimized" SGZ file
    converter.run("out-advanced.sgz", bits_per_voxel=2, 
                  blockshape=(64, 64, 4))
# Convert back to SEG-Y
with SgzConverter("out-standard.sgz") as converter:
    converter.convert_to_segy("recovered.sgy")

Read an SGZ file

from seismic_zfp.read import SgzReader
with SgzReader("in.sgz") as reader:
    inline_slice = reader.read_inline(LINE_NO)
    crossline_slice = reader.read_crossline(LINE_NO)
    z_slice = reader.read_zslice(LINE_NO)
    sub_vol = reader.read_subvolume(min_il=min_il, max_il=max_il, 
                                    min_xl=min_xl, max_xl=max_xl, 
                                    min_z=min_z, max_z=max_z)

Use segyio-like interface to read SGZ files

import seismic_zfp
with seismic_zfp.open("in.sgz")) as sgzfile:
    inline_slice = sgzfile.iline[sgzfile.ilines[LINE_ID]]
    xslice_sgz = sgzfile.xline[sgzfile.xlines[LINE_ID]]
    zslice_sgz = sgzfile.depth_slice[sgzfile.zslices[SLICE_ID]]
    trace = sgzfile.trace[TRACE_ID]
    trace_header = sgzfile.header[TRACE_ID]
    binary_file_header = sgzfile.bin
    text_file_header = sgzfile.text[0]

Contributing

Contributions welcomed, whether you are reporting or fixing a bug, implementing or requesting a feature. Either make a github issue or fork the project and make a pull request. Please extend the unit tests with relevant passing/failing tests, run these as: python -m pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seismic-zfp-0.1.1.tar.gz (44.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seismic_zfp-0.1.1-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file seismic-zfp-0.1.1.tar.gz.

File metadata

  • Download URL: seismic-zfp-0.1.1.tar.gz
  • Upload date:
  • Size: 44.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.7

File hashes

Hashes for seismic-zfp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f775dc511f9d41f2f5918b62b45c5ead49369ad802d552ff3c08528d450425b5
MD5 28a526764343304bb0d5deccf448a1ec
BLAKE2b-256 fe25d7385a4579b68f1bcf5162e5b1bd675be5d062b9e66c2bb6afe7b47387eb

See more details on using hashes here.

File details

Details for the file seismic_zfp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: seismic_zfp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.7

File hashes

Hashes for seismic_zfp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 30a8254026391840d848dcbc618cad897742e9aeb0f5bc96a813621979d8828b
MD5 ee345e9a54ad71d52706548a06b45648
BLAKE2b-256 a26e0b9fc111569f2931b7158977f0f170d9dc85c28c3bb8fe622d6a5fdd2c7e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page