[obspy-users] Fetching data via obspy.clients.arclink with unexpected gaps

Juan Santiago Velásquez jsvelasquez at sgc.gov.co
Thu Mar 16 23:58:23 CET 2017


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)


Juan Santiago Velásquez

[image: SERVICIO GEOLÓGICO COLOMBIANO] [image: |] [image: |]
Diag. 53 N.° 34-53,
Bogotá, Colombia,
+(571) 2200 200Ext. [image: f]/ServicioGeologicoColombiano
<https://www.facebook.com/pages/Servicio-Geol%C3%B3gico-Colombiano/344228072328140>
[image: t]@sgcol <https://twitter.com/sgcol>
[image: y]youtube <https://www.youtube.com/channel/UCkwTkQ5dmO16fPPnhE3SrMg>

2017-03-16 7:36 GMT-05:00 Anna Makushkina <makushkina at ign.ku.dk>:

> 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('makushkina at ign.ku.dk <makushkina at ign.ku.dk>',
> 'eida.gfz-potsdam.de <http://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
>
>
> _______________________________________________
> obspy-users mailing list
> obspy-users at lists.swapbytes.de
> http://lists.swapbytes.de/mailman/listinfo/obspy-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.swapbytes.de/pipermail/obspy-users/attachments/20170316/e142f1e3/attachment-0001.html>


More information about the obspy-users mailing list