Package: seismic-zfp
seismic-zfpPython library to convert SEG-Y files to compressed cubes and retrieve arbitrary sub-volumes from these, fast.MotivationReading 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 theseismic-zfp (.SGZ) format.
This format is based onZFP compressionfromPeter Lindstrom's paperusing the official Python bindings, distributed as zfpy.ZFP compression enables smoothly varying d-dimensional data in 4dsubvolumes
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:1The location of any seismic sample is knownArbitrary subvolumes can be read withminimalredundant I/O, for example:Padding IL/XL dimensions with 4, and the z-dimension depending on bitratePadding IL/XL dimensions with 64 and the z-dimension with 4 (16:1 compression)Using IL/XL optimized layoutGroups of 4 inlines or crosslines can be read withnoredundant I/OA single inline can be read and withnoadditional 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-YUsing z-slice optimized layoutA z-slice can be read by accessingjustn_traces/4096 disk blocks,
compared to n_traces disk blocks for SEG-Y2D SEG-Y SupportAs of v0.2.4 support for compressing 2D SEG-Y files (INLINE_3D and CROSSLINE_3D always zero) is included.
Compression and reading follows the same pattern as 3D files, but segyio emulation only provides the
following attributes: trace, header, samples, bin & text. However an additional funciton read_subplane()
is available for extracting horizontally and vertically contrained data.HeadersTheseismic-zfp (.SGZ) formatalso 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.For further explanation of the design and implementation of seismic-zfp, please refer topublications.NOTE: Previously the extension .sz was used for seismic-zfp, but has been replaced with .sgz to avoid confusion around the compression algorithm used.Get seismic-zfpWheels fromPyPIwith zgy and vds support:pip install seismic-zfp[zgy,vds]Wheels fromPyPIwithout zgy or vds support:pip install seismic-zfpSource fromGithub:git clone https://github.com/equinor/seismic-zfp.gitNote that seismic-zfp depends on the Python packageZFPY, which is a binary distribution on PyPI built for Linux and Windows.The optional dependencypyvds- requires openvds package from Bluware which isnotopen-sourceThe optional dependency of zgy2sgz has been replaced withpyzgy- a pure-Python alternative.ExamplesFull example code is providedhere, but the following reference is useful:Create SGZ files from SEG-Y, ZGY or VDSfromseismic_zfp.conversionimportSegyConverter,ZgyConverter,VdsConverterwithSegyConverter("in.sgy")asconverter:# Create a "standard" SGZ file with 8:1 compression, using in-memory methodconverter.run("out_standard.sgz",bits_per_voxel=4)# Create a "z-slice optimized" SGZ fileconverter.run("out_adv.sgz",bits_per_voxel=2,blockshape=(64,64,4))withZgyConverter("in_8-int.zgy")asconverter:# 8-bit integer ZGY and 1-bit SGZ have similar qualityconverter.run("out_8bit.sgz",bits_per_voxel=1)withVdsConverter("in.vds")asconverter:# VDS compression is superior, but doesn't permit non-cubic bricks...converter.run("out.sgz",bits_per_voxel=4,blockshape=(8,8,128))Convert SGZ files to SEG-Y# Convert SGZ to SEG-YwithSgzConverter("out_standard.sgz")asconverter:converter.convert_to_segy("recovered.sgy")Read an SGZ filefromseismic_zfp.readimportSgzReaderwithSgzReader("in.sgz")asreader:inline_slice=reader.read_inline(LINE_IDX)crossline_slice=reader.read_crossline(LINE_IDX)z_slice=reader.read_zslice(LINE_IDX)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 filesimportseismic_zfpwithseismic_zfp.open("in.sgz"))assgzfile:il_slice=sgzfile.iline[sgzfile.ilines[LINE_NUMBER]]xl_slices=[xlforxlinsgzfile.xline]zslices=sgzfile.depth_slice[:5317]trace=sgzfile.trace[TRACE_IDX]trace_header=sgzfile.header[TRACE_IDX]binary_file_header=sgzfile.bintext_file_header=sgzfile.text[0]Including equivalents to segyio.toolswithseismic_zfp.open("in.sgz")assgz_file:dt_sgz=seismic_zfp.tools.dt(sgz_file)cube_sgz=seismic_zfp.tools.cube("in.sgz")Plus some extended utility functionality:withseismic_zfp.open("in.sgz"))assgzfile:subvolume=sgzfile.subvolume[IL_NO_START:IL_NO_STOP:IL_NO_STEP,XL_NO_START:XL_NO_STOP:XL_NO_STEP,SAMP_NO_START:SAMP_NO_STOP:SAMP_NO_STEP]header_arr=sgzfile.get_tracefield_values(segyio.tracefield.TraceField.NStackedTraces)Command Line InterfaceA simple command line interface for converting from SEGY or ZGY to SGZ is also bundled with seismic-zfp. This is available using the commandseismic-zfp.Converting from SEG-Y to SGZ and backseismic-zfpsgy2sgz<INPUTFILEPATH><OUTPUTFILEPATH>--bits-per-voxel4seismic-zfpsgz2sgy<INPUTFILEPATH><OUTPUTFILEPATH>To see all options run the commandseismic-zfp sgy2sgz --helpConverting from ZGY to SGZseismic-zfpzgy2sgz<INPUTFILEPATH><OUTPUTFILEPATH>--bits-per-voxel4To see all options run the commandseismic-zfp zgy2sgz --helpContributingContributions 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 pytestPublicationsWade, David (2020):Seismic-ZFP: Fast and Efficient Compression and Decompression of Seismic Data, First EAGE Digitalization Conference and Exhibition, Nov 2020, Volume 2020, p.1-5Full-Text PDF(without EAGE formatting)EarthDoc Link(N.B. paywall protected)