Seismological data analysis with ObsPy — FDSN waveform download, response removal, phase picking, moment tensor inversion, and seismicity mapping.
A comprehensive skill for seismological data acquisition, processing, and analysis using the ObsPy framework. Covers FDSN waveform retrieval, instrument response removal, P/S phase arrival picking, basic moment tensor inversion, and seismicity visualisation.
Use this skill when you need to:
This skill is not appropriate for:
ObsPy organises seismic data in three nested containers:
| Class | Contains | Analogy |
|---|---|---|
Stream | list of Trace objects | a multi-channel recording session |
Trace | 1-D NumPy array + Stats | a single channel |
Stats | dict-like metadata | network, station, channel, start time, sampling rate |
The SEED channel code (e.g., BHZ) encodes band (B = broad-band),
instrument (H = high-gain seismometer), and orientation (Z = vertical).
The International Federation of Digital Seismograph Networks (FDSN) standardises three web service endpoints:
ObsPy's Client class wraps all three. Major nodes: "IRIS", "GEOFON",
"ORFEUS", "ETH", "NCEDC".
Raw seismometer output is in digital counts. The instrument response (poles,
zeros, sensitivity) converts counts to ground motion. Removing it via spectral
division yields velocity [m/s], displacement [m], or acceleration [m/s²]
records. ObsPy reads response from StationXML and applies it with
Trace.remove_response().
Seismic phase picking identifies the onset time of P (compressional) and S (shear)
waves. Classical approaches use the STA/LTA (short-term average / long-term
average) ratio: a sudden energy increase produces a ratio spike. The obspy.signal
module provides classic_sta_lta and recursive_sta_lta.
A seismic moment tensor is a 3×3 symmetric matrix describing the equivalent
force system of an earthquake. The scalar seismic moment M_0 and moment
magnitude M_w = (2/3)(log10(M_0) - 9.1) are derived from it. Full waveform
inversion (e.g., time-domain L2 misfit minimisation) fits synthetic seismograms
to observed data to recover the tensor.
Earthquake catalogues are typically distributed as QuakeML or CSV files with origin time, latitude, longitude, depth, and magnitude. Matplotlib with a Cartopy or Basemap projection renders these as geographic scatter plots, colour- coded by depth and scaled by magnitude.
pip install "obspy>=1.4.0" "scipy>=1.11" "matplotlib>=3.7" \
"numpy>=1.24" "pandas>=2.0"
On conda (recommended for ObsPy to resolve C-extension dependencies):
conda install -c conda-forge obspy scipy matplotlib numpy pandas
Verify the installation:
python -c "import obspy; print(obspy.__version__)"
conda install -c conda-forge cartopy
FDSN data centres are open for most uses. If you access restricted data (embargoed networks), store credentials securely:
export FDSN_USER="<your-username>"
export FDSN_PASSWORD=$(cat ~/.fdsn_passwd) # read from file, never hardcode
Access in Python:
import os
from obspy.clients.fdsn import Client
user = os.getenv("FDSN_USER", "")
password = os.getenv("FDSN_PASSWORD", "")
if user:
client = Client("IRIS", user=user, password=password)