Skip to main content

Fast stochastic determination of arrival time and initial polarity of seismic waveforms

Project description

SDATIP

PyPI version License: MIT

Fast Stochastic Determination of Arrival Time and Initial Polarity of Seismic Waveforms

A high-performance Python package for seismic waveform analysis that determines arrival time and initial polarity using Markov chain-based stochastic methods.

Performance

Metric Original SDATIP
100Hz, 10s waveform ~30 minutes ~55 seconds
Speedup - 30x faster

Installation

pip install sdatip

Or install from source:

git clone https://github.com/Chuan1937/SDATIP-Fast.git
cd SDATIP-Fast
pip install -e .

Quick Start

Process a Single Waveform

import numpy as np
import sdatip

# Your waveform data (1D numpy array)
data = np.random.randn(1000)

# Process the waveform
result = sdatip.process_waveform(
    name="STATION_A",
    data=data,
    output_dir="./output/"
)

# Get results
print(f"Arrival time: {result['results'][0]['arrival_time']:.3f}s")
print(f"Polarity (up): {result['results'][0]['polarity_up']:.3f}")

Process Multiple Waveforms

import sdatip

# Batch process all SAC files in a directory
results = sdatip.process_batch(
    input_dir="./data/",
    output_dir="./output/",
    num_workers=4,  # Use 4 CPU cores
    plot_enabled=False
)

Step-by-Step Processing

import sdatip

# Create waveform object
wf = sdatip.Waveform("station")
wf.importdata(data, delta=0.01)
wf.analyzedata()
wf.rmmean()
wf.interpolate(1)
wf.denseunique()
wf.denselong(hvcoefficient=2.5, mininsertco=200)
wf.extremearr()
wf.densebin()

# Build state model
state = wf.constructstate()
timeprobs, num_solutions = state.markovmatrix()
ampprob = state.ampprobcalculate()

# Estimate results
state.estimation(0)
print(f"Arrival: {state.arrivalestimate:.3f}s")
print(f"Polarity up: {state.polarityup:.3f}")

API Reference

process_waveform(name, data, output_dir, ...)

Process a single seismic waveform.

Parameter Type Default Description
name str required Station name
data np.ndarray required 1D amplitude array
output_dir str required Output directory
delta float 0.01 Sampling interval (s)
plot_enabled bool True Generate plots

process_batch(input_dir, output_dir, ...)

Process multiple waveforms in parallel.

Parameter Type Default Description
input_dir str required Input directory with SAC files
output_dir str required Output directory
num_workers int -1 CPU cores (-1 = all)
plot_enabled bool False Generate plots

Classes

  • Waveform(name) - Waveform preprocessing container
  • State(name) - Markov state model

Output Files

File Description
{station}.txt Text summary with arrival time and polarity
{station}.npz Main results (matrix, probabilities, thresholds)
{station}_timeprob_{i}.npz Time probability distribution
{station}_{i}.pdf Probability plot (if enabled)
{station}.eps Publication-ready plot (if enabled)

Algorithm

Based on: Pei, W., Zhuang, J. & Zhou, S. "Stochastic determination of arrival time and initial polarity of seismic waveform." Earth Planets Space 77, 36 (2025). https://doi.org/10.1186/s40623-025-02161-5

Validation

python benchmark_validate.py check

Citation

@article{pei2025stochastic,
  title={Stochastic determination of arrival time and initial polarity of seismic waveform},
  author={Pei, W. and Zhuang, J. and Zhou, S.},
  journal={Earth, Planets and Space},
  volume={77},
  pages={36},
  year={2025},
  doi={10.1186/s40623-025-02161-5}
}

License

MIT License

Star History

Star History Chart

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

sdatip-1.0.1.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

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

sdatip-1.0.1-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file sdatip-1.0.1.tar.gz.

File metadata

  • Download URL: sdatip-1.0.1.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for sdatip-1.0.1.tar.gz
Algorithm Hash digest
SHA256 abf89a9b87c9a37833347e2788e62421bd930dca18d521c6d24b00d43f2ff92b
MD5 0a733893100b17dc83e3f05229909d02
BLAKE2b-256 d9d07f6b62f9cd8a803ab060010e537aa843ef69b7df5394ff020661a39ec71b

See more details on using hashes here.

File details

Details for the file sdatip-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: sdatip-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for sdatip-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa34201fa02418a511f234a786a9a247080ed6b92a825d232d365688a4b6b73e
MD5 b204f03444b9a48bf2136a2c74b3ed53
BLAKE2b-256 c1941abcbe4fe1d3f14cd61f7d47f5ddea093ed2a06888a4a006ee9f24eef631

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