This repository contains a set of custom MATLAB scripts for sorting and converting seismic data gathered in SEG-Y format. The workflows are designed to avoid reliance on external libraries and instead directly manipulate binary data. These tools are useful for converting between common seismic gather types: shot gathers, CMP gathers, and offset gathers.
.
├── 09YCEW180-shot-gather/ # Input shot gather
├── 09YCEW180-SCAMP1-gdm1700m-5s2ms.sgy # Input shot gather (Put it here and combined to one file)
├── 09YCEW180-cmp-gather/ # Output CMP gathers (automatically generated multiple files)
├── 09YCEW180-offset-gather/ # Output offset gathers (automatically generated generated multiple files)
├── cmp2offset.m # Convert CMP gathers to separate Offset gathers
├── cmp2shot.m # Convert CMP gathers to one Shot file
├── offset2cmp.m # Convert Offset gathers to separate CMP gathers
├── offset2shot.m # Convert Offset gathers to one Shot file
├── shot2cmp.m # Convert the Shot gather to separate CMP gathers
├── shot2offset.m # Convert the Shot gather to separate Offset gathers
└── LICENSE # License for this repository
Reads the input shot gather and converts them into common midpoint (CMP) gathers by reading the CMP byte in trace headers. Alternatively, we can calculate CMP coordinates from source and receiver positions.
Groups traces from the input shot gather into common-offset gathers based on calculated source-receiver distance.
Reorganizes CMP-gathered traces back into the shot file.
Converts CMP gathers into offset gathers based on calculated offsets between sources and receivers. The offset bin size is 50 m.
Converts offset gathers back into CMP gathers. Useful for visualizing CMP-stacked data after processing.
Reconstructs shot gathers from offset-based sorting.
- 09YCEW180-SCAMP1-gdm1700m-5s2ms.sgy: A sample seismic dataset containing SEG-Y data simulating scattering interference in the near surface.
This dataset contains pre-processed seismic data acquired along 2D seismic lines from the 09YCEW180 survey. The files are organized into various gather types such as CMP, Shot, and Offset gathers.
| Field | Byte Range | Description |
|---|---|---|
| FFID (Shot) | 9–12 | Shot number (FFID) |
| Channel No. | 13–16 | Receiver channel number |
| CMP No. | 21–24 | Common Midpoint (CMP) number |
| Source X | 73–76 | Source X coordinate |
| Source Y | 77–80 | Source Y coordinate |
| Receiver X | 81–84 | Receiver X coordinate |
| Receiver Y | 85–88 | Receiver Y coordinate |
| CMP X | 181–184 | CMP X coordinate |
| CMP Y | 185–188 | CMP Y coordinate |
- Acquisition Type: 2D seismic lines (not extracted from a 3D volume)
- Receiver Layout: Two receiver lines per shot
- ✅ Statics Correction: Performed
- ✅ Amplitude Compensation: Performed
- ❌ Dynamic Correction (NMO/DMO): Not performed
Each output gather is stored in its own directory:
09YCEW180-cmp-gather/– CMP gathers09YCEW180-offset-gather/– Offset gathers09YCEW180-shot-gather/– Shot gathers
A .placeholder file is created in each folder to maintain structure in version-controlled environments.
-
Extract your raw SEG-Y data (e.g.,
09YCEW180-SCAMP1-gdm1700m-5s2ms.sgy) and place it in the corresponding folder (e.g.,09YCEW180-shot-gather). -
Run the appropriate script depending on your desired conversion workflow in MATLAB. For example:
shot2offset offset2shot
-
This process not only converts shot gathers to offset gathers and then back, but also reorganizes the traces in ascending shot order based on FFID (Field File Identification). This is especially useful if your original file is disordered or contains a cluttered shot sequence—as is the case with
09YCEW180-SCAMP1-gdm1700m-5s2ms.sgy. -
The reconstructed SEG-Y file will be saved in a new folder (e.g.,
09YCEW180-shot-gather/) with clean, sequential FFID sorting.
Each script reads binary headers manually, calculates required attributes (CMP, offset, etc.), and sorts traces accordingly without relying on third-party packages.
- All scripts are implemented using raw binary reading (
fread) and do not require the Seismic Toolbox or other packages. - Headers are manually parsed using byte offsets from the SEG-Y standard. The original offset bytes in trace headers are not correct.
- Output is typically saved as
.sgyfiles with the same formatting as the input.
This project is licensed under the terms of the included LICENSE file.