Skip to content

Commit

Permalink
fdsn: docstrings and minimal test for fetching waveforms with response
Browse files Browse the repository at this point in the history
attached
  • Loading branch information
megies committed Jan 10, 2014
1 parent d2dacbf commit a2a63db
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
37 changes: 37 additions & 0 deletions obspy/fdsn/client.py
Expand Up @@ -455,6 +455,20 @@ def get_waveforms(self, network, station, location, channel, starttime,
IU.ADK.10.BHZ | 2010-02-27T06:30:00... | 40.0 Hz, 40 samples
IU.AFI.00.BHZ | 2010-02-27T06:30:00... | 20.0 Hz, 20 samples
IU.AFI.10.BHZ | 2010-02-27T06:30:00... | 40.0 Hz, 40 samples
>>> t = UTCDateTime("2012-12-14T10:36:01.6Z")
>>> st = client.get_waveforms("TA", "?42A", "*", "BHZ", t+300, t+400,
... attach_response=True)
>>> st.remove_response(output="VEL")
>>> st.plot()
.. plot::
from obspy.fdsn import Client
client = Client("IRIS")
st = client.get_waveforms("TA", "?42A", "*", "BHZ", t+300, t+400,
attach_response=True)
st.remove_response(output="VEL")
st.plot()
.. note::
Expand Down Expand Up @@ -611,6 +625,29 @@ def get_waveforms_bulk(self, bulk, quality=None, minimumlength=None,
GR.GRA1..BHZ | 2010-02-27T00:00:00... | 20.0 Hz, 40 samples
IU.ANMO.00.BHZ | 2010-02-27T00:00:00... | 20.0 Hz, 40 samples
IU.ANMO.10.BHZ | 2010-02-27T00:00:00... | 40.0 Hz, 80 samples
>>> t = UTCDateTime("2012-12-14T10:36:01.6Z")
>>> t1 = t + 300
>>> t2 = t + 400
>>> bulk = [("TA", "S42A", "*", "BHZ", t1, t2),
... ("TA", "W42A", "*", "BHZ", t1, t2),
... ("TA", "Z42A", "*", "BHZ", t1, t2)]
>>> st = client.get_waveforms_bulk(bulk, attach_response=True)
>>> st.remove_response(output="VEL")
>>> st.plot()
.. plot::
from obspy.fdsn import Client
client = Client("IRIS")
t = UTCDateTime("2012-12-14T10:36:01.6Z")
t1 = t + 300
t2 = t + 400
bulk = [("TA", "S42A", "*", "BHZ", t1, t2),
("TA", "W42A", "*", "BHZ", t1, t2),
("TA", "Z42A", "*", "BHZ", t1, t2)]
st = client.get_waveforms_bulk(bulk, attach_response=True)
st.remove_response(output="VEL")
st.plot()
.. note::
Expand Down
22 changes: 22 additions & 0 deletions obspy/fdsn/tests/test_client.py
Expand Up @@ -14,6 +14,7 @@
from obspy.fdsn.client import build_url, parse_simple_xml
from obspy.fdsn.header import DEFAULT_USER_AGENT, FDSNException
from obspy.core.util.base import NamedTemporaryFile
from obspy.station import Response
import os
from StringIO import StringIO
import sys
Expand Down Expand Up @@ -598,6 +599,27 @@ def test_bulk(self):
got = client.get_waveforms_bulk(StringIO(bulk2))
self.assertEqual(got, expected2, failmsg(got, expected2))

def test_get_waveform_attach_response(self):
"""
minimal test for automatic attaching of metadata
"""
client = self.client

bulk = ("TA A25A -- BHZ 2010-03-25T00:00:00 2010-03-25T00:00:04\n"
"IU ANMO * BH? 2010-03-25 2010-03-25T00:00:08\n"
"IU ANMO 10 HHZ 2010-05-25T00:00:00 2010-05-25T00:00:04\n"
"II KURK 00 BHN 2010-03-25T00:00:00 2010-03-25T00:00:04\n")
st = client.get_waveforms_bulk(bulk, attach_response=True)
for tr in st:
self.assertTrue(isinstance(tr.stats.get("response"), Response))

st = client.get_waveforms("IU", "ANMO", "00", "BHZ",
UTCDateTime("2010-02-27T06:30:00.000"),
UTCDateTime("2010-02-27T06:40:00.000"),
attach_response=True)
for tr in st:
self.assertTrue(isinstance(tr.stats.get("response"), Response))


def suite():
return unittest.makeSuite(ClientTestCase, 'test')
Expand Down

0 comments on commit a2a63db

Please sign in to comment.