How to convert SEG-Y to Zarr v3 in Python

SDIP converts SEG-Y to MDIO v1 on Zarr v3, a chunked, cloud-native array format that zarr, xarray, dask and TensorStore open directly. This guide goes from install to a store you can train on, with the certificate that says it still holds exactly what the SEG-Y held.

On this page

Why convert at all

A half-inch magnetic tape reel with a length of tape unspooling from it.
SEG-Y was designed for this. Illustration generated for this site, not a photograph of a survey tape.

Seismic data lives in SEG-Y, a format designed for magnetic tape. Machine learning consumes arrays: chunked, randomly addressable, read in parallel from object storage by many workers at once. SEG-Y cannot serve that.

  • It is a sequential layout: traces written end to end, each preceded by a 240-byte header.
  • There is no chunking and no random access. Reading an inline means seeking across the whole file.
  • There is no schema a data loader can address. Header meaning is a per-vendor convention.
  • It does not sit well in object storage. A single multi-gigabyte blob is not a parallel read.

So the data has to be converted, and that conversion is where the trouble is. A header field dropped because a parser never named it, a sample altered because a decode was not exactly invertible, a trace mislabelled because a grid was regularised. Plenty of tools convert SEG-Y. What has been missing is the receipt.

SEG-Y vs MDIO / Zarr v3 for machine learning

PropertySEG-YMDIO v1 / Zarr v3
Designed forMagnetic tape, sequentialChunked N-dimensional arrays
Random accessNo. Seek across the fileYes. Read one chunk
Parallel readsEffectively noYes, chunk-level concurrency
Cloud and object storageOne large opaque blobNative. Each chunk is an object
Reads into NumPyNeeds a SEG-Y parserDirectly, through zarr or xarray
dask and out-of-coreNoYes
Readers outside PythonFormat-specific librariesTensorStore (C++), any Zarr v3 reader
Schema for headersPer-vendor conventionNamed, typed fields on the store
CompressionRarelyLossless codecs, per chunk
Open standardYes, an SEG technical standardYes, Zarr v3 and MDIO v1

SDIP takes you from the left column to the right one without changing a single measured value, and proves it.

Install

SDIP requires Python 3.12 to 3.13. There are three ways to get it.

Container

Nothing to install but Docker. The image is multi-arch (linux/amd64, linux/arm64), runs as non-root and carries the pinned decoder. Pin the exact version for anything whose output you intend to keep.

Verify a store with the 1.7.0 image
docker run --rm -v "$PWD:/work" ghcr.io/zahidaramai/sdip:1.7.0 \
    verify /work/survey.sgy /work/survey.mdio

From source

Clone and sync with uv
git clone https://github.com/zahidaramai/sdip && cd sdip
uv sync --all-extras --dev

uv run sdip doctor          # environment sanity; runs first, always

sdip doctor checks the Python version, the binding upstream pins, barred packages and environment variables, runtime licences and the working tree. If it fails, nothing else runs.

As a package

Install from the tagged release
pip install git+https://github.com/zahidaramai/sdip@v1.7.0

A wheel and sdist are attached to every release. SDIP is not on PyPI, and that is a decision, not an omission.

Convert and certify

The full chain, convert, verify and certify, is one command.

Convert, verify and certify
uv run sdip certify survey.sgy survey.mdio \
    --rss-ceiling-gib 8.0 \
    --wall-ceiling-s 1500

That ingests the SEG-Y, runs all five planes of equivalence, exports back to SEG-Y and compares the whole file by SHA-256, checks the store opens with stock zarr and xarray with MDIO uninstalled, runs the negative controls and writes the certificate. What the certificate records is explained on the certificate page.

To convert only, or to verify a store you already have:

Convert only
uv run sdip ingest survey.sgy survey.mdio --revision 1 --template PostStack3DTime
Verify an existing store
uv run sdip verify survey.sgy survey.mdio

When you call ingestion from a Python script, put it behind if __name__ == "__main__":. MDIO's header parser uses a spawn multiprocessing context, and without the guard the child process re-executes your script.

Load the converted data in Python

The output is plain Zarr v3. Neither SDIP nor MDIO is needed to read it. Use zarr 3.2.0 or later: MDIO stores the headers array with a struct data type that older releases cannot read.

With xarray
import xarray as xr

ds = xr.open_zarr("survey.mdio", consolidated=False)
print(ds)
# data vars:   amplitude, headers, headers_raw_uint8, trace_mask, ...
# coords:      inline, crossline, time, cdp_x, cdp_y

volume = ds["amplitude"]  # dims ('inline', 'crossline', 'time'), lazy + dask-backed
inline_42 = volume.sel(inline=42).values  # label-based, straight to NumPy
With zarr
import zarr

store = zarr.open_group("survey.mdio", mode="r")
amplitude = store["amplitude"]  # samples, (inline, crossline, time), float32
headers = store["headers"]  # structured array, 97 named trace-header fields
mask = store["trace_mask"][...]  # which traces are live
raw_bytes = store["headers_raw_uint8"]  # all 240 header bytes per trace, verbatim

tile = amplitude[100:132, 200:232, :]  # chunk-level random access

Into a training loop. The arrays are NumPy-compatible and chunk-addressable, so a PyTorch Dataset or a tf.data pipeline is a thin wrapper: slice the region you want per item and let Zarr fetch only the chunks it touches. SDIP deliberately ships no data loader of its own.

From C++ or another language. The core arrays read byte-identically through TensorStore. Every array and key a store holds is listed in the store contract.

What is supported

SDIP is deliberately narrow. Where a format, geometry or backend has not been measured, it refuses with a named reason and does not convert it anyway.

SEG-Y revisionsBase specs for rev 0, 1, 2 and 2.1. Certified end to end on rev 1.
GeometryPoststack 3-D (PostStack3DTime). Other templates come from MDIO’s registry.
Sample formatsAll 11 codes swept and classified. 5 decode exactly. For the 6 that can alter a value, ibm32 among them, EQUIVALENT requires a byte-identical whole-file round trip.
Trace headersGap-free spec, 97 named fields, all 240 bytes covered.
OutputMDIO v1.2.1 on Zarr v3, lossless codecs only.
StorageLocal filesystem measured. Cloud object stores are an open debt.
Source sizeRefused by default above 40.1 GiB. Declare another limit with --envelope-gib.

SDIP has issued a certificate at survey scale: 494,565,408 bytes and 116,532 traces, SEG-Y rev 1, poststack 3-D, every check passing, from a clean working tree. The source of that measurement and its licence are attributed in the repository's NOTICE.

Commands

sdip doctorEnvironment sanity. If it fails, nothing else runs.
sdip spec buildBuild a gap-free trace-header specification.
sdip ingestSEG-Y to MDIO / Zarr v3.
sdip verifyRun the Equivalence Engine against an existing store.
sdip exportMDIO back to SEG-Y.
sdip certifyThe full chain, ending in a certificate.
sdip receiptA read-only header receipt for a source and, optionally, its store.

Exit status is the same for every command: 0 pass, 1 fail or refused input, 2 usage or environment, 3 an internal defect in SDIP and never a verdict about your data.

Questions

Does SDIP modify or process my seismic data?

No. There is no filtering, scaling, resampling, regridding, muting, interpolation or denoising anywhere in it. It is an identity map: the format changes, the values do not, and the certificate is the proof.

Do I need SDIP or MDIO installed to read the output?

No. The output is standard Zarr v3. It opens with stock zarr (3.2.0 or later) and xarray, and the core arrays read from C++ through TensorStore. That the store opens with MDIO uninstalled is a gate the engine enforces on every certified run.

Is the conversion lossless? Can I get my original SEG-Y back?

Yes. sdip export writes MDIO back to SEG-Y, and sdip certify compares the round-tripped file to the source by SHA-256 over the whole file. Compression uses lossless codecs only.

What about ibm32 and the decode to float32?

MDIO stores samples as float32, so the decode is always from the source format to float32. Six source formats can alter a value that way, ibm32 among them. SDIP declares the transform on the certificate and grants EQUIVALENT only when the whole-file round trip is byte-identical. No round trip, no verdict.

Why MDIO / Zarr v3 and not HDF5 or a custom format?

Because it is an open standard nobody owns, it is chunked and cloud-native by design, and it is already what the scientific Python stack reads. SDIP does not invent a format. It adopts MDIO v1 and pins its upstream dependencies exactly.

How do I use the converted data with PyTorch or TensorFlow?

Read it with zarr or xarray and slice per sample. The arrays are NumPy-compatible and chunk-addressable, so a Dataset wrapper is a few lines. SDIP ships no loader of its own on purpose: a standard store works with the one you already have.

Which SEG-Y revisions and geometries work?

Base specs exist for rev 0, 1, 2 and 2.1, and the chain is certified end to end on rev 1 with poststack 3-D geometry. Where something has not been measured, SDIP refuses with a named reason and does not guess.

What happens if the conversion is not equivalent?

The certificate says NON-EQUIVALENT and names the plane that failed and where. Four planes out of five is a failure, not a pass.

Is it production-ready?

It is early and honest about it. Everything measured is in DECISIONS.md, and everything unmeasured is in OPEN_DEBTS.md with the experiment that would close it.