Data availability via obspy.arclink

Hello,

Moritz Beyreuther got a request from colleagues from University Kiel -
as he has no time I'll try to answer this - the request itself is
written in German, however the answer may be interesting for all ObsPy
users.

So essentially the question was if there is a way to make sure waveform
data is available via the ArcLink protocol before requesting the actual
data. The answer is for now: NO.

The ArcLink inventory request delivers only a general hint about start
and end time (if any) of a station and/or network - which itself is
AFAIK not even connected to the underlying data sets - its just an entry
within a manually maintained database.

One side note - please don't use getStation anymore - this method is
marked as deprecated and will be removed in a future version. Please try
using getInventory directly, e.g.:

from obspy.arclink.client import Client
from obspy.core import UTCDateTime
t = UTCDateTime(2009,1,1)
c = Client()
inv = c.getInventory('BW', starttime=t, endtime=t+1)
inv.keys()

['BW.RTSH..EHE',
'BW.RMOA..EHE',
'BW.RWMO',
'BW.RWMO..SHZ',
'BW.RMOA..EHN',
'BW',
...

inv['BW.RWMO']

AttribDict({'remark': '', 'code': 'RWMO', 'elevation': 763.0,
'description': 'Wildenmoos, Bavaria', 'start': UTCDateTime(2006, 6, 4,
0, 0), 'restricted': False, 'archive_net': 'BW', 'longitude': 12.729887,
'affiliation': '', 'depth': 1.0, 'place': 'Wildenmoos, Bavaria',
'country': 'Germany', 'latitude': 47.744171999999999, 'end': None})

Hope it helps & best regards,
Robert

PS: For the second part I need some sample code in order to reproduce
your issue - just send it to the list or directly to me.

Sehr geehrter Herr Beyreuther,

wir arbeiten an einem Skript zum downloaden von MiniSeeds von der webdc.eu -
Seite (via arclink). Dabei lassen wir eine Schleife über die verfügbaren
Stationen laufen, die mit getStations erhalten werden können. Das Problem das
dabei auftritt, ist dass bei manchen Stationen keine Daten zur Verfügung
stehen (getWaveform) und das Programm abbricht. Unsere Frage ist nun: Gibt es
eine Möglichkeit die Datenverfügbarkeit für eine bestimmte Station zu einer
bestimmten Zeit (Datum) zu überprüfen? Wenn ja, wie? Kann man alternativ das
Abbrechen bei getWaveform verhindern?
In der Hoffnung, dass Sie uns weiter helfen können,

mit freundlichen Grüßen.

Larissa Seifert und Kai Olbert

- --

Dr. Robert Barsch
Department of Earth and Environmental Sciences, Geophysics
LMU Munich
Theresienstr. 41/IV
D-80333 Munich
Germany

Tel: +49 (0) 89 2180 4201
Fax: +49 (0) 89 2180 9942010
Mail: barsch@lmu.de

Just a short tip: If you want your program to continue even if an error
is raised and it would normally terminate, you can use the try/except
syntax to control what happens in that particular case.

Example:

try:
    bad_value = 1 / 0
except:
    print "Got an error but ignoring it"
    bad_value = 1
print bad_value

You should be more specific of course and only catch the exception you
really want to circumvent, like:

try:
    bad_value = 1 / 0
except ZeroDivisionError:
    print "Got a very specific error and ignoring it"
    bad_value = 1
print bad_value

For more information on these constructs see:
http://docs.python.org/tutorial/errors.html

Maybe you also want to have a look at the warnings module which is a
better way to handle the printing of such warning message as in the example.

Hope it helps,
Tobias

Robert Barsch wrote: