obspy.core - Core classes of ObsPy

This package contains common methods and classes for ObsPy. It includes the Stream, Trace, UTCDateTime, Stats classes and methods for reading seismogram files.

copyright:The ObsPy Development Team (devs@obspy.org)
license:GNU Lesser General Public License, Version 3 (http://www.gnu.org/copyleft/lesser.html)

Waveform Data


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.



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 http://examples.obspy.org) can be read by specifying their URL. For details see the documentation of read().

>>> 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
         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 the IPython notebooks mentioned in the ObsPy Tutorial for more detailed usage examples.


Classes & Functions

read Read waveform files into an ObsPy Stream object.
Trace An object containing data of a continuous series, such as a seismic trace.
Stats A container for additional header information of a ObsPy Trace object.
Stream List like object of multiple ObsPy Trace objects.
UTCDateTime A UTC-based datetime object.
readEvents Read event files into an ObsPy Catalog object.


trace Module for handling ObsPy Trace objects.
stream Module for handling ObsPy Stream objects.
utcdatetime Module containing a UTC-based datetime class.
event obspy.core.event - Classes for handling event metadata
ascii Simple ASCII time series formats
quakeml QuakeML read and write support.
util obspy.core.util - Various utilities for ObsPy
preview Tools for creating and merging previews.
json JSON write support


scripts.runtests A command-line program that runs all ObsPy tests.
scripts.reftekrescue Restore REFTEK data from raw binary data dumps.