You are on page 1of 1

ObsPy: A Python toolbox for Seismology, a Data Center Perspective

Moritz Beyreuther (1), Robert Barsch (1), Lion Krischer (1), Tobias Megies (1), Yannik Behr (2), and Joachim Wassermann (1)
(1) Department of Earth and Environmental Sciences (geophys. Observatory), Ludwig Maximilians University, Munich, Germany
(2) School of Geography Environment and Earth Sciences, Victoria University, Wellington, New Zealand
Contact: moritz.beyreuther@geophysik.uni-muenchen.de

Abstract SeisHub ArcLink Fissures/DHI 5 ASCII via Seedlink


ObsPy: The Python toolbox for seismology (http://www.obspy.org) aims at filling the gap Often data providers (centers) need to send additional information from the seismological station
between interactive analysis and automatic data acquisition systems. Automatic batch analysis of ObsPy — Processing
to the data centers, e.g. log messages, weather information or battery status.
continuous data streams or feeding a so far unknown formatted data stream into an acquisition
system are two possible applications. The obspy.mseed module (based on libmseed written by Chad Trabant) allows to easily
convert any ASCII string to a MiniSEED file which can be continuously scanned by the
Python provides a platform independent, free and open source interpreter language including a seedlink mseed_scan plugin and thus can easily be transferred to the data center via Seedlink.
large collection of scientific open-source modules thus allowing rapid development of prototype code. 3 XML-SEED
1 import numpy as np
Especially for data centers and/or observatories the ObsPy XSEED module may be of special 2 from obspy . c o r e import read , Trace , Stream , UTCDateTime
ObsPy extends Python by providing the seismologist with basic seismological routines, e.g. 3
MiniSEED, SAC, GSE2 read and write support, various pickers, filters, instrument correction, interest. It allows to convert data from dataless SEED to XML-SEED and back. The XML-SEED 4 # Convert t o numpy c h a r a c t e r a r r a y
extended display routines... The data itself is stored in numpy.ndarrays allowing powerful numer- format is very verbose and easy extensible for internal purposes. For "public" distribution the 5 weather = np . f r o m s t r i n g ( """
6 0 0 . 0 0 0 0 0 . 0 ??? 4 . 7 9 7 . 7 1 0 1 5 . 0 0 . 0 010308 000000
ical array-programming modules like NumPy (http://numpy.scipy.org) or SciPy (http://scipy.org) resulting extended XML-SEED can always be converted back to the standard exchange format
7 0 0 . 0 0 0 2 0 . 0 ??? 4 . 7 9 7 . 7 1 0 1 5 . 0 0 . 0 010308 000001
to be used. dataless SEED (loosing the additionally fields). 8 0 0 . 0 0 0 5 0 . 0 ??? 4 . 7 9 7 . 7 1 0 1 5 . 0 0 . 0 010308 000002
9 0 0 . 0 0 0 8 0 . 0 ??? 4 . 7 9 7 . 7 1 0 1 5 . 4 0 . 0 010308 000003
10 0 0 . 0 0 1 1 0 . 0 ??? 4 . 7 9 7 . 7 1 0 1 5 . 0 0 . 0 010308 000004
That is the dataless SEED representation 11 0 0 . 0 0 1 3 0 . 0 ??? 4 . 7 9 7 . 7 1 0 1 5 . 0 0 . 0 010308 000005
12 . . .
000001V 0 1 0 0 0 9 4 0 2 . 3 1 2 1 9 7 0 , 0 0 1 , 0 0 : 0 0 : 0 0 . 0 0 0 0 ~ 2 0 3 8 , 0 0 1 , 0 0 : 0 0 : 0 0 . 0 0 0 0 ~
13 """ , dtype= ’ | S1 ’ )
2 0 0 9 , 0 3 7 , 0 4 : 3 2 : 4 1 . 0 0 0 0 ~ BayernNetz ~~0110032002RJOB 000003RJOB 000008
1 Unified Read and Write Support ...
14
15 # F i l l header a t t r i b u t e s
16 s t a t s = { ’ network ’ : ’BW’ , ’ s t a t i o n ’ : ’RJOB ’ , ’ l o c a t i o n ’ : ’ ’ ,
ObsPy provides unified access to read and write seismograms formated as GSE2, MiniSEED, can be translated to its XML-SEED representation 17 ’ c h a n n e l ’ : ’WLZ’ , ’ sampling_rate ’ : 1 . 0 }
SAC, SEISAN, Seismic Handler formats Q and ASCII. In this respect all data are saved into a 18 s t a t s [ ’ s t a r t t i m e ’ ] = UTCDateTime ( ) #t h e c u r r e n t time
<?xml v e r s i o n= ’ 1 . 0 ’ e n c o d i n g= ’ u t f −8 ’?>
19
stream object. <x seed v e r s i o n=" 1 . 0 ">
20 # Generate Stream o b s j e c t and w r i t e t o mseed
<volume_index_control_header>
21 s t = Stream ( [ Trace ( data=weather , header=s t a t s ) ] )
>>> from obspy . c o r e import read <v o l u m e _ i d e n t i f i e r b l o c k e t t e=" 010 ">
22 s t . w r i t e ( " weather . mseed" , format= ’MSEED ’ , e n c o d i n g =0, r e c l e n =256) #e n c o d i n g 0==ASCII
>>> s t = read ( " my_mseed_file " ) Simple MiniSEED to SAC Converter <version_of_format >2.4</ version_of_format>
>>> s t . w r i t e ( " my_sac_file " , format="SAC" ) <l o g i c a l _ r e c o r d _ l e n g t h >12</ l o g i c a l _ r e c o r d _ l e n g t h >
<beginning_time >1970−01−01T00 :00:00 </ beginning_time>
The stream object consists of multiple trace objects itself. Thus it is similar to a MiniSEED or <end_time >2038−01−01T00 :00:00 </ end_time>
<volume_time >2009−02−06T04 :32:41 </ volume_time>
GSE2 volume where multiple data records are stored in a single file. These separate data records <o r i g i n a t i n g _ o r g a n i z a t i o n >BayernNetz </ o r i g i n a t i n g _ o r g a n i z a t i o n >
are each one trace object. ...
The header attributes of the first trace (tr = st[0]) can be addressed by the tr.stats object 6 Key Development Features of ObsPy
(e.g. tr.stats.sampling_rate). The attribute tr.data contains the data as a numpy.ndarray by the following lines of code
• Test-driven development (TDD), currently 306 unit tests
object (array-programming). Thus the data can be further processed by standard Python, NumPy, >>> from obspy . x seed import P a r s e r
SciPy, matplotlib or ObsPy routines or easily passed via the python ctypes library to any shared >>> • Modular structure
>>> sp = P a r s e r ( " d a t a l e s s . s e e d .BW_RJOB" )
C or FORTRAN library. >>> sp . writeXSEED ( " d a t a l e s s . s e e d .BW_RJOB. xml" ) • Reliance of well-known third-party tools (numpy, scipy, matplotlib)
• Reusing well established existing code, e.g. libmseed, GSE_UTI
A response file can be written in a similar manner, just replace sp.writeXSEED by sp.writeRESP.
miniseed miniseed • Platform independence (32 and 64bit versions for Winows, Mac and Linux)
gse2 gse2
• Free, open source and available from the very beginning
ObsPy

sac sac
seisan sh-Q • Well documented
sh-Q sh-ascii 4 obspy.signal • Community web page http://www.obspy.org containing: documentation, tutorials, installa-
sh-ascii tion instructions, complete source code, ...
Basic signal processing routines are included
in obspy.signal, allowing data centers to 1 from obspy . s i g n a l import s e i s S i m , l o w p a s s
batch-process some usual processing steps 2 import m a t p l o t l i b . p y p l o t as p l t
3 ...

2 ArcLink, Fissures, Seishub


and to visualize them via the Python mat- 4 # Correct for frequency response 7 Further Readings
plotlib package for e.g. online access. 5 r e s = s e i s S i m ( t r . data ,
6 t r . s t a t s . sampling_rate ,
1500
RJOB 2009-08-24T00:20:03.000000Z 1. Ahern, Timothy K. ; Dost, Bernard: SEED Reference Manual - standard for the exchange of
The ArcLink module makes it possible to automatically access the data via ArcLink or for testing 1000
7 paz , inst_sim=one_hertz )
earthquake data - SEED format version 2.4. IRIS DMC, January 2009
8 # C o r r e c t f o r o v e r a l l s e n s i t i v i t y , nm/ s
the servers functionality. The following example shows how to retrieve data via ArcLink. 500
9 r e s ∗= 1 e9 / paz [ " s e n s i t i v i t y " ]
STS-2

0
10 # Apply l o w p a s s a t 10Hz
2. Barsch, Robert: Web-based technology for storage and processing of multi-component data in
>>> from obspy . c o r e import UTCDateTime 500
1000 11 r e s = l o w p a s s ( r e s , 10 , c o r n e r s =4, seismology, LMU Muenchen, Diss., 2009
>>> from obspy . a r c l i n k . c l i e n t import C l i e n t
15000 5 10 15 20 25 30 12 d f=t r . s t a t s . sampling_rate )
>>>
600 13 . . .
3. Beyreuther, Moritz ; Barsch, Robert ; Krischer, Lion ; Megies, Tobias ; Behr, Yannik ; Wasser-
>>> c l i e n t = C l i e n t ( "webdc . eu " , 18001)
1Hz CornerFrequency

400 14 p l t . p l o t ( sec , t r . data , "k" ) mann, Joachim: ObsPy: A Python Toolbox for Seismology. SRL Vol 81, Nr. 3, p 530 — 533,
>>> s t a r t = UTCDateTime ( "2009−08−20 0 4 : 0 3 : 1 2 " ) 200
15 . . . 2010
>>> s t = c l i e n t . getWaveform ( "BW" , "RJOB" , "" , "EH∗" , s t a r t − 3 , s t a r t + 15) 0
200
400 4. Tsuboi, S. ; Tromp, J. ; Komatitsch, D.: An XML-SEED Format for the Exchange of Synthetic
In a similar way ObsPy provides an interface to the database SeisHub (an in house development 6000 5 10 15
Time [s]
20 25 30 Seismograms. EOS Transactions of American Geophysical Union. SF31B-03, 2004
[1]) and to the FISSURES protocol (DHI) of IRIS.

You might also like