Fetching data via obspy.clients.arclink with unexpected gaps

Hi,
I’m trying to fetch event-based data via

obspy.clients.arclink.client.Client.get_waveforms

but the data are not continuous and has some gaps, which are tough to get an information about for >200 stations. When I order data for such event (from the time gap), I get the following error:

ArcLinkException                          Traceback (most recent call last)
<ipython-input-3-4ddf45f9cfb7> in <module>()
     33 #                st1.plot()
     34 #save the waveforms:
---> 35     client.save_waveforms('./%s/%s/%s.%s..%s.mseed' %(net,stn,net, stn, t_event), net, stn, '', '*', t_event - 60, t_event + 240, format='MSEED')
     36 #            client.save_waveforms('./%s/%s/%s.%s..%s.seed' %(net, stn, net, stn, comp), (net, stn, '','*' , t_event - 60, t_event + 240)

/home/anna/anaconda2/lib/python2.7/site-packages/obspy/clients/arclink/client.pyc in save_waveforms(self, filename, network, station, location, channel, starttime, endtime, format, compressed, route, unpack)
    564         rdata = [starttime, endtime, network, station, channel, location]
    565         # fetch waveform
--> 566         data = self._fetch(rtype, rdata, route=route)
    567         # check if data is still encrypted
    568         if data.startswith(b'Salted__'):

/home/anna/anaconda2/lib/python2.7/site-packages/obspy/clients/arclink/client.pyc in _fetch(self, request_type, request_data, route)
    259             self._reconnect()
    260             try:
--> 261                 return self._request(request_type, request_data)
    262             except ArcLinkException:
    263                 raise

/home/anna/anaconda2/lib/python2.7/site-packages/obspy/clients/arclink/client.pyc in _request(self, request_type, request_data)
    328             self._write_ln('PURGE %d' % req_id)
    329             self._bye()
--> 330             raise ArcLinkException('No data available')
    331         elif b'id="NODATA"' in xml_doc or b'id="ERROR"' in xml_doc:
    332             # cleanup

ArcLinkException: No data available

I’m wondering if it is possible to skip these “bad requests” and continue fetching data for the next events in the list?

My fetching command:

from obspy import UTCDateTime
from obspy.clients.arclink.client import Client
from obspy import read_events
from obspy.core.event import Origin
client = Client(’’, ‘eida.gfz-potsdam.de’, 18001)
comps=[‘HHE’,‘HHN’,‘HHZ’]

#for stninf in stninfo:
stn=‘SA01’
stlat=71.1111
stlon=025.8169
net=‘1G’

ts= read_events(’./catalogs_2012-2016/%s_%s_events’ % (net, stn))
for t in ts:
event_time=t.preferred_origin().time
t_event=UTCDateTime(event_time)
if t_event < UTCDateTime(‘2015-05-20’):
print(t_event)
#save the waveforms:
client.save_waveforms(’./%s/%s/%s.%s…%s.mseed’ %(net,stn,net, stn, t_event), net, stn, ‘’, ‘*’, t_event - 60, t_event + 240, format=‘MSEED’)


Thank you!
Anna


You cand handle it with python’s try / except statements. Something like this:

ts= read_events(’./catalogs_2012-2016/%s_%s_events’ % (net, stn))
for t in ts:
event_time=t.preferred_origin().time
t_event=UTCDateTime(event_time)
if t_event < UTCDateTime(‘2015-05-20’):
print(t_event)
#save the waveforms:

try:
client.save_waveforms(’./%s/%s/%s.%s…%s.mseed’ %(net,stn,net, stn, t_event), net, stn, ‘’, ‘*’, t_event - 60, t_event + 240, format=‘MSEED’

except Exception as e:

print(e)