ObsPy: A Python toolbox for Seismology, a Data ...

13 downloads 1333 Views 713KB Size Report
ObsPy: The Python toolbox for seismology (http://www.obspy.org) aims at filling the ... open-source modules thus allowing rapid development of prototype code.
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: [email protected]

Abstract

SeisHub

ArcLink

ObsPy: The Python toolbox for seismology (http://www.obspy.org) aims at filling the gap between interactive analysis and automatic data acquisition systems. Automatic batch analysis of continuous data streams or feeding a so far unknown formatted data stream into an acquisition system are two possible applications. Python provides a platform independent, free and open source interpreter language including a large collection of scientific open-source modules thus allowing rapid development of prototype code. ObsPy extends Python by providing the seismologist with basic seismological routines, e.g. MiniSEED, SAC, GSE2 read and write support, various pickers, filters, instrument correction, extended display routines... The data itself is stored in numpy.ndarrays allowing powerful numerical array-programming modules like NumPy (http://numpy.scipy.org) or SciPy (http://scipy.org) to be used.

Fissures/DHI

ObsPy — Processing

3

XML-SEED

Especially for data centers and/or observatories the ObsPy XSEED module may be of special interest. It allows to convert data from dataless SEED to XML-SEED and back. The XML-SEED format is very verbose and easy extensible for internal purposes. For "public" distribution the resulting extended XML-SEED can always be converted back to the standard exchange format dataless SEED (loosing the additionally fields).

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 ~ 2 0 0 9 , 0 3 7 , 0 4 : 3 2 : 4 1 . 0 0 0 0 ~ BayernNetz ~~0110032002RJOB 000003RJOB 000008 ...

Unified Read and Write Support

ObsPy provides unified access to read and write seismograms formated as GSE2, MiniSEED, SAC, SEISAN, Seismic Handler formats Q and ASCII. In this respect all data are saved into a stream object. >>> from obspy . c o r e import read >>> s t = read ( " my_mseed_file " ) >>> s t . w r i t e ( " my_sac_file " , format="SAC" )

can be translated to its XML-SEED representation 2.4 12 1970−01−01T00 :00:00 2038−01−01T00 :00:00 2009−02−06T04 :32:41 BayernNetz ...

Simple MiniSEED to SAC Converter

The stream object consists of multiple trace objects itself. Thus it is similar to a MiniSEED or GSE2 volume where multiple data records are stored in a single file. These separate data records are each one trace object. The header attributes of the first trace (tr = st[0]) can be addressed by the tr.stats object (e.g. tr.stats.sampling_rate). The attribute tr.data contains the data as a numpy.ndarray object (array-programming). Thus the data can be further processed by standard Python, NumPy, SciPy, matplotlib or ObsPy routines or easily passed via the python ctypes library to any shared C or FORTRAN library.

ObsPy

sac seisan sh-Q

>>> from obspy . x seed import P a r s e r >>> >>> sp = P a r s e r ( " d a t a l e s s . s e e d .BW_RJOB" ) >>> sp . writeXSEED ( " d a t a l e s s . s e e d .BW_RJOB. xml" )

• Free, open source and available from the very beginning • Well documented

4

obspy.signal

• Community web page http://www.obspy.org containing: documentation, tutorials, installation instructions, complete source code, ...

Basic signal processing routines are included in obspy.signal, allowing data centers to batch-process some usual processing steps and to visualize them via the Python matplotlib package for e.g. online access.

from obspy . c o r e import UTCDateTime from obspy . a r c l i n k . c l i e n t import C l i e n t c l i e n t = C l i e n t ( "webdc . eu " , 18001) s t a r t = UTCDateTime ( "2009−08−20 0 4 : 0 3 : 1 2 " ) s t = c l i e n t . getWaveform ( "BW" , "RJOB" , "" , "EH∗" , s t a r t − 3 , s t a r t + 15)

In a similar way ObsPy provides an interface to the database SeisHub (an in house development [1]) and to the FISSURES protocol (DHI) of IRIS.

1Hz CornerFrequency

>>> >>> >>> >>> >>> >>>

• Reusing well established existing code, e.g. libmseed, GSE_UTI • Platform independence (32 and 64bit versions for Winows, Mac and Linux)

STS-2

The ArcLink module makes it possible to automatically access the data via ArcLink or for testing the servers functionality. The following example shows how to retrieve data via ArcLink.

Key Development Features of ObsPy

• Reliance of well-known third-party tools (numpy, scipy, matplotlib)

sac sh-Q

ArcLink, Fissures, Seishub

6

• Modular structure

sh-ascii

2

1 import numpy as np 2 from obspy . c o r e import read , Trace , Stream , UTCDateTime 3 4 # Convert t o numpy c h a r a c t e r a r r a y 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 7 0 0 . 0 0 0 2 0 . 0 ??? 4 . 7 9 7 . 7 1 0 1 5 . 0 0 . 0 010308 000001 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 11 0 0 . 0 0 1 3 0 . 0 ??? 4 . 7 9 7 . 7 1 0 1 5 . 0 0 . 0 010308 000005 12 . . . 13 """ , dtype= ’ | S1 ’ ) 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 ’ : ’ ’ , 17 ’ c h a n n e l ’ : ’WLZ’ , ’ sampling_rate ’ : 1 . 0 } 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 19 20 # Generate Stream o b s j e c t and w r i t e t o mseed 21 s t = Stream ( [ Trace ( data=weather , header=s t a t s ) ] ) 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

• Test-driven development (TDD), currently 306 unit tests

miniseed gse2

sh-ascii

Often data providers (centers) need to send additional information from the seismological station to the data centers, e.g. log messages, weather information or battery status.

by the following lines of code

A response file can be written in a similar manner, just replace sp.writeXSEED by sp.writeRESP. miniseed gse2

ASCII via Seedlink

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 seedlink mseed_scan plugin and thus can easily be transferred to the data center via Seedlink.

That is the dataless SEED representation

1

5

1500 1000 500 0 500 1000 15000 600 400 200 0 200 400 6000

RJOB 2009-08-24T00:20:03.000000Z

5

5

10

10

15

15 Time [s]

20

20

25

25

30

30

1 from obspy . s i g n a l import s e i s S i m , l o w p a s s 2 import m a t p l o t l i b . p y p l o t as p l t 3 ... 4 # Correct for frequency response 5 r e s = s e i s S i m ( t r . data , 6 t r . s t a t s . sampling_rate , 7 paz , inst_sim=one_hertz ) 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 9 r e s ∗= 1 e9 / paz [ " s e n s i t i v i t y " ] 10 # Apply l o w p a s s a t 10Hz 11 r e s = l o w p a s s ( r e s , 10 , c o r n e r s =4, 12 d f=t r . s t a t s . sampling_rate ) 13 . . . 14 p l t . p l o t ( sec , t r . data , "k" ) 15 . . .

7

Further Readings

1. Ahern, Timothy K. ; Dost, Bernard: SEED Reference Manual - standard for the exchange of earthquake data - SEED format version 2.4. IRIS DMC, January 2009 2. Barsch, Robert: Web-based technology for storage and processing of multi-component data in seismology, LMU Muenchen, Diss., 2009 3. Beyreuther, Moritz ; Barsch, Robert ; Krischer, Lion ; Megies, Tobias ; Behr, Yannik ; Wassermann, Joachim: ObsPy: A Python Toolbox for Seismology. SRL Vol 81, Nr. 3, p 530 — 533, 2010 4. Tsuboi, S. ; Tromp, J. ; Komatitsch, D.: An XML-SEED Format for the Exchange of Synthetic Seismograms. EOS Transactions of American Geophysical Union. SF31B-03, 2004

Suggest Documents