Could you help me understand some of the functions of the easyseedlink (https://docs.obspy.org/packages/autogen/obspy.clients.seedlink.easyseedlink.html) package?
As far as I understand the on_data() function is running on a loop after the call of run() function. How am I suppose to close() the connection? How can I also use the on_seedlink_error() and the on_terminate()? Could you provide me a very simple example like this one (https://docs.obspy.org/packages/autogen/obspy.clients.seedlink.easyseedlink.EasySeedLinkClient.html#obspy.clients.seedlink.easyseedlink.EasySeedLinkClient)?
Thank you in advance,
I'm guessing you have you seen the corresponding chapter in the tutorial
As far as I understand the on_data() function is running on a loop after
the call of run() function. How am I suppose to close() the connection?
As I see it there is currently no convenient way to break the loop from
the client. You do have access to the underlying SeedLinkConnection
object through client.conn though, so calling the connection's
terminate() method from another thread should also terminate the run()
loop and trigger the on_terminate() callback:
How can I also use the on_seedlink_error() and the on_terminate()? Could
you provide me a very simple example like this one
The two methods provide callbacks for when either the SLTERMINATE or the
SLERROR packets were received. You can check the source of the
EasySeedLinkClient class  to see that they get called without any
arguments. So here is an extended example:
def on_data(self, trace):
print('Terminated. Doing some kind of cleanup or reconnect...')
# inspect self.conn or self.conn.state or ...
Hope that helps,
Thank you Bernhard! I appreciate your help!
I tried the bellow code, but I got the error:
ERROR: obspy.clients.seedlink [184.108.40.206:18000]:response: DATA/FETCH/TIME command is not accepted
ERROR: obspy.clients.seedlink [220.127.116.11:18000]:negotiation with remote SeedLink failed: u'no stations accepted'
(check issue here: https://github.com/bonaime/seedlink_plotter/issues/25)
################## CODE #########################################
from obspy import UTCDateTime
import obspy.clients.seedlink.basic_client as sl
client = sl.Client(host, port=18000, timeout=60, debug=True)
t = UTCDateTime() - 5 #sec
st = client.get_waveforms(net,sta, "",cha, t, t + 3)
st = st.sort(reverse=True)
At GEOFON the time window requests are currently disabled. You can also notice the missing "window-extraction" when looking at the capabilities:
$ slinktool -i CAPABILITIES geofon.gfz-potsdam.de
<seedlink software="SeedLink v3.2 (2014.071)" organization="GEOFON" started="2016/07/15 12:59:08.5527">
If you need a time window t..t+3, would FDSNWS dataselect be a viable alternative?
I think you are experiencing the same issue I had 2 weeks ago (thread: "seedlink protocol 3.1 vs. 3.2 and obspy SLClient")
The short explanation is what you just got from Andres Heinloo, although strictly the server seems to be yours and not GEOFON's (judging from your email and the ip-address of the server)
Now, if the server is yours then it should be a (simple?) matter of enabling time window requests in the server settings.
The longer explanation is that obspy.clients.seedlink.basic_client is not meant to be used to retrieve data streams but rather specific finite chunks of data (see: http://docs.obspy.org/packages/autogen /obspy.clients.seedlink.basic_client.Client.html#obspy.clients.seedlink.basic_client.Client)
For realtime data streams you can either use the highlevel obspy.clients.seedlink.easyseedlink.EasySeedLinkClient or you can use the more basic obspy.clients.seedlink.slclient.SLClient which will give you greater control
Thank you both for your quick answers!
Andres, as far as I know, FDSNWS dataselect is disabled to the current server. I thought, though that FDSNWS was an alternative to the Arclink and not the Seedlink protocol?!
Peter, could you provide a sample code usage with this module (obspy.clients.seedlink.slclient.SLClient)?
Yes, but Seedlink is optimized for real-time transfer, not for time window requests.
In case you are trying to access archive data, this would not work with Seedlink anyway. Aren't you transferring the HP stations to Athens in real time already?
attached is some commented simplistic example code that accesses your server (let me know if attachments don't make it through and I'll send it to you directly given that you give me your email).
Note that the code assumes ObsPy 1.0 or later (for earlier versions you need to change slpack.get_trace() -> slpack.getTrace() and slc.slconn.set_sl_address -> slc.slconn.setSLAddress)
exampleSLClient.py (2.34 KB)
Is there a way to control the order of the returned traces objects -I'm referring to the on_data(trace) function-? Is it possible to retrieve a stream with all its traces in one call?
Thank you in advance,