Python and obspy examples

You may use Obspy library to natively handle seismic data into your Python scripts.

# this will download 1 hour of data from a FR network station, and display a wafeform plotfrom obspy.fdsn import Client
from obspy import UTCDateTime
client = Client("RESIF")
t = UTCDateTime("2014-01-28T00:00:00.000")
stream = client.get_waveforms("FR", "OGDI", "00", "HHZ", t, t + 60 * 60)
stream.plot()

 

# this will show an inventory for FR network

from obspy.fdsn import Client
client = Client("RESIF")
inventory = client.get_stations(network='FR',level='channel')
inventory.get_contents()

You may also request webservices with one of the numerous Python grabber library [5] Unlike Obspy, these libraries are seismic-data agnostic (like wget is):

# this will make a wget-like request and write resulting file on local disk

import urllib2
request = urllib2.Request('http://ws.resif.fr/fdsnws/dataselect/1/query?network=FR&station=OGDI&channel=HHZ&starttime=2014-01-10T00:00:00&endtime=2014-01-11T00:00:00')
response = urllib2.urlopen(request)
newfile = open('./mydata.mseed', 'w')
newfile.write ( response.read() )

Technically, restricted access works with HTTP digest authentication. Any HTTP client implementing this technology should be able to request restricted-access data.

 

Search