Skip to main content

A Python library for seismic data processing and visualization.

Project description

GridSeisPy

A Python library for seismic data processing and visualization, designed for efficiency and ease of use.

Features

  • Fast I/O: Efficiently read and write SEG-Y files.
  • Intuitive Slicing: Slice data by inline/crossline, time/depth, or along and between horizons (e.g., sgy.getInline(100), sgy[..., top:btm]).
  • Advanced Indexing: Supports numpy-style regional extraction using np.ogrid.
  • Horizon Arithmetic: Perform calculations directly on horizon objects (e.g., thickness = btm_horiz - top_horiz).
  • Grid & Coordinate Tools: Built-in utilities for grid and coordinate transformations.
  • Easy Visualization: Simple integration with Matplotlib to display results.

Installation

You can install GridSeisPy via pip:

pip install GridSeisPy

Complete Walkthrough

This example demonstrates the core workflow: creating a SEG-Y file from scratch, loading it, performing various slicing operations, and visualizing the results. This code is self-contained and runnable.

import numpy as np
import matplotlib.pyplot as plt
from GridSeisPy import SeisData, Horiz, BinField, TraceField
import os

# --- 1. Create a Demo SEG-Y File ---
# First, we'll programmatically create a seismic file to work with.
output_dir = "usage_output"
os.makedirs(output_dir, exist_ok=True)
sgy_path = os.path.join(output_dir, "demo_seismic.sgy")

n_il, n_xl, n_smp = 50, 60, 120
trace_cnt = n_il * n_xl

with SeisData(sgy_path, mode='w+') as sgy_writer:
    # Create and populate trace headers
    headers = np.zeros(trace_cnt, dtype=sgy_writer.config.trace_header_dtype)
    headers[TraceField.InlineID.name] = np.repeat(np.arange(100, 100 + n_il), n_xl)
    headers[TraceField.XlineID.name] = np.tile(np.arange(500, 500 + n_xl), n_il)
    headers[TraceField.SamplePoints.name] = n_smp
    headers[TraceField.SampleRate.name] = 2000  # 2ms

    # Create trace data
    data = np.array([np.sin(np.linspace(0, 2 * np.pi, n_smp)) * (i / trace_cnt) 
                     for i in range(trace_cnt)], dtype='f4')

    # Set binary header, then write everything to the file
    bh = sgy_writer.binary_header
    bh[BinField.SamplePoints.name] = n_smp
    bh[BinField.SampleRate.name] = 2000 # In microseconds for binary header
    sgy_writer.binary_header = bh  # Re-assign to trigger update
    
    sgy_writer.SetTraceMapping(set_trace_cnt=trace_cnt)
    sgy_writer.SetTraceHeader(np.arange(trace_cnt), headers)
    sgy_writer.SetTraceData(np.arange(trace_cnt), data)

print(f"Demo SEG-Y file created at: {sgy_path}")


# --- 2. Load Data and Create Horizons ---
sgy = SeisData(sgy_path).load()

# Create virtual horizons in memory
top_horiz = sgy.getSeiHoriz()
btm_horiz = sgy.getSeiHoriz()
xx, yy = np.meshgrid(np.linspace(0, 1, sgy.shape[1]), np.linspace(0, 1, sgy.shape[0]))
top_time = 40 + (np.sin(xx * 2 * np.pi) + np.cos(yy * 2 * np.pi)) * 10
btm_time = top_time + 20
top_horiz.elems['time'] = top_time.astype('i4')
btm_horiz.elems['time'] = btm_time.astype('i4')


# --- 3. Slicing and Advanced Operations ---
# a. Get a standard inline slice
inline_slice = sgy.getInline(sgy.arrInlines[sgy.shape[0] // 2])

# b. Get a slice between two horizons
data_between_horizons = sgy[..., top_horiz:btm_horiz]

# c. Perform horizon arithmetic to get time thickness
time_thickness = btm_horiz - top_horiz


# --- 4. Visualization ---
fig, axes = plt.subplots(1, 3, figsize=(18, 6))
fig.suptitle("GridSeisPy Feature Demonstration")

# Plot inline slice
axes[0].imshow(inline_slice.T, cmap='seismic', aspect='auto')
axes[0].set_title("Inline Slice")
axes[0].set_xlabel("Xline Index")
axes[0].set_ylabel("Time Sample")

# Plot a single trace from the data between horizons
trace = data_between_horizons[25, 30]
axes[1].plot(trace, np.arange(len(trace)))
axes[1].set_title("A Single Trace Between Horizons")
axes[1].invert_yaxis()

# Plot the time thickness map
im = axes[2].imshow(time_thickness.elems['time'], cmap='jet', aspect='auto')
axes[2].set_title("Time Thickness Map (ms)")
fig.colorbar(im, ax=axes[2])

plt.tight_layout()
plt.show()

## Future Plans

`GridSeisPy` is under active development. Here are some of the exciting features planned for the future:

*   **Easy Seismic Attribute Extraction**: We plan to add a comprehensive module for calculating various seismic attributes. The goal is to make extracting attributes like instantaneous frequency, phase, and amplitude as simple as a few lines of code.
*   **AI Integration**: A major focus will be on bridging the gap between seismic data and modern AI. We aim to provide seamless integration with popular deep learning frameworks (like PyTorch and TensorFlow) to facilitate research and application of AI in seismic interpretation.

## License

This project is licensed under the MIT License. 

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

gridseispy-0.1.1.tar.gz (25.8 kB view details)

Uploaded Source

Built Distribution

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

gridseispy-0.1.1-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file gridseispy-0.1.1.tar.gz.

File metadata

  • Download URL: gridseispy-0.1.1.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for gridseispy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d52b9fe3c1c4f61732c8c053cabb9ba082ad8e4e97a6c3880cf6c59483f974d5
MD5 257ce7234e6e50cc5a538f9f1a203097
BLAKE2b-256 df736293551b4615ecfbae37814fd509308dbb50e5c3aec01cd70cb2eebfe13d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gridseispy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 29.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for gridseispy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 779a25785971acec1e49e4050efd9b7088ef16e6154590d699551076fda7887f
MD5 7fd41bd3c52fa3645e2e258132f4f1c8
BLAKE2b-256 81804ed21f75ec35b0d5f2480e3b401d693f9cfbb587ef4c62a0c59d8e53aab4

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