Agent skill

obspy-data-api

An overview of the core data API of ObsPy, a Python framework for processing seismological data. It is useful for parsing common seismological file formats, or manipulating custom data into standard objects for downstream use cases such as ObsPy's signal processing routines or SeisBench's modeling API.

Stars 897
Forks 232

Install this agent skill to your Project

npx add-skill https://github.com/benchflow-ai/skillsbench/tree/main/tasks/seismic-phase-picking/environment/skills/obspy-data-api

SKILL.md

ObsPy Data API

Waveform Data

Summary

Seismograms of various formats (e.g. SAC, MiniSEED, GSE2, SEISAN, Q, etc.) can be imported into a Stream object using the read() function.

Streams are list-like objects which contain multiple Trace objects, i.e. gap-less continuous time series and related header/meta information.

Each Trace object has the attribute data pointing to a NumPy ndarray of the actual time series and the attribute stats which contains all meta information in a dict-like Stats object. Both attributes starttime and endtime of the Stats object are UTCDateTime objects.

A multitude of helper methods are attached to Stream and Trace objects for handling and modifying the waveform data.

Stream and Trace Class Structure

Hierarchy: StreamTrace (multiple)

Trace - DATA:

  • data → NumPy array
  • stats:
    • network, station, location, channel — Determine physical location and instrument
    • starttime, sampling_rate, delta, endtime, npts — Interrelated

Trace - METHODS:

  • taper() — Tapers the data.
  • filter() — Filters the data.
  • resample() — Resamples the data in the frequency domain.
  • integrate() — Integrates the data with respect to time.
  • remove_response() — Deconvolves the instrument response.

Example

A Stream with an example seismogram can be created by calling read() without any arguments. Local files can be read by specifying the filename, files stored on http servers (e.g. at https://examples.obspy.org) can be read by specifying their URL.

python
>>> from obspy import read
>>> st = read()
>>> print(st)
3 Trace(s) in Stream:
BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z - ... | 100.0 Hz, 3000 samples
BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z - ... | 100.0 Hz, 3000 samples
BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z - ... | 100.0 Hz, 3000 samples
>>> tr = st[0]
>>> print(tr)
BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z - ... | 100.0 Hz, 3000 samples
>>> tr.data
array([ 0.        ,  0.00694644,  0.07597424, ...,  1.93449584,
        0.98196204,  0.44196924])
>>> print(tr.stats)
         network: BW
         station: RJOB
        location:
         channel: EHZ
       starttime: 2009-08-24T00:20:03.000000Z
         endtime: 2009-08-24T00:20:32.990000Z
   sampling_rate: 100.0
           delta: 0.01
            npts: 3000
           calib: 1.0
           ...
>>> tr.stats.starttime
UTCDateTime(2009, 8, 24, 0, 20, 3)

Event Metadata

Event metadata are handled in a hierarchy of classes closely modelled after the de-facto standard format QuakeML. See read_events() and Catalog.write() for supported formats.

Event Class Structure

Hierarchy: CatalogeventsEvent (multiple)

Event contains:

  • originsOrigin (multiple)
    • latitude, longitude, depth, time, ...
  • magnitudesMagnitude (multiple)
    • mag, magnitude_type, ...
  • picks
  • focal_mechanisms

Station Metadata

Station metadata are handled in a hierarchy of classes closely modelled after the de-facto standard format FDSN StationXML which was developed as a human readable XML replacement for Dataless SEED. See read_inventory() and Inventory.write() for supported formats.

Inventory Class Structure

Hierarchy: InventorynetworksNetworkstationsStationchannelsChannel

Network:

  • code, description, ...

Station:

  • code, latitude, longitude, elevation, start_date, end_date, ...

Channel:

  • code, location_code, latitude, longitude, elevation, depth, dip, azimuth, sample_rate, start_date, end_date, response, ...

Classes & Functions

Class/Function Description
read Read waveform files into an ObsPy Stream object.
Stream List-like object of multiple ObsPy Trace objects.
Trace An object containing data of a continuous series, such as a seismic trace.
Stats A container for additional header information of an ObsPy Trace object.
UTCDateTime A UTC-based datetime object.
read_events Read event files into an ObsPy Catalog object.
Catalog Container for Event objects.
Event Describes a seismic event which does not necessarily need to be a tectonic earthquake.
read_inventory Function to read inventory files.
Inventory The root object of the NetworkStationChannel hierarchy.

Modules

Module Description
obspy.core.trace Module for handling ObsPy Trace and Stats objects.
obspy.core.stream Module for handling ObsPy Stream objects.
obspy.core.utcdatetime Module containing a UTC-based datetime class.
obspy.core.event Module handling event metadata.
obspy.core.inventory Module for handling station metadata.
obspy.core.util Various utilities for ObsPy.
obspy.core.preview Tools for creating and merging previews.

Expand your agent's capabilities with these related and highly-rated skills.

benchflow-ai/skillsbench

csv-processing

Use this skill when reading sensor data from CSV files, writing simulation results to CSV, processing time-series data with pandas, or handling missing values in datasets.

897 232
Explore
benchflow-ai/skillsbench

pid-controller

Use this skill when implementing PID control loops for adaptive cruise control, vehicle speed regulation, throttle/brake management, or any feedback control system requiring proportional-integral-derivative control.

897 232
Explore
benchflow-ai/skillsbench

yaml-config

Use this skill when reading or writing YAML configuration files, loading vehicle parameters, or handling config file parsing with proper error handling.

897 232
Explore
benchflow-ai/skillsbench

simulation-metrics

Use this skill when calculating control system performance metrics such as rise time, overshoot percentage, steady-state error, or settling time for evaluating simulation results.

897 232
Explore
benchflow-ai/skillsbench

vehicle-dynamics

Use this skill when simulating vehicle motion, calculating safe following distances, time-to-collision, speed/position updates, or implementing vehicle state machines for cruise control modes.

897 232
Explore
benchflow-ai/skillsbench

web-interface-guidelines

Vercel's comprehensive UI guidelines for building accessible, performant web interfaces. Use this skill when reviewing or building UI components for compliance with best practices around accessibility, performance, animations, and visual stability.

897 232
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results