Giter Club home page Giter Club logo

seedlink_plotter's People

Contributors

megies avatar sbonaime avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

seedlink_plotter's Issues

Bug with events

With this command line both on mac or RaspberryPi
seedlink-plotter --seedlink_server rtserver.ipgp.fr:18000 -s G_SSB:00BHZ -b 12h --events 7

I have this error

FDSNException: Bad request. If you think your request was valid please contact the developers.
Detailed response of server:

Error 400: unknown : Cannot send body with 204
Request:
/fdsnws/event/1/query?minmagnitude=7.0&endtime=2018-03-27T15%3A52%3A56.950000&starttime=2018-03-27T03%3A58%3A00.000000
Request Submitted:
2018-03-27T15:53:14.777101Z
Service version:
fdsnws-event: v 1.1.0

urlopen error timed out with get_event

After few ours of test, I get this error

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 530, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.7/threading.py", line 483, in run
    self.__target(*self.__args, **self.__kwargs)
  File "./seedlink_plotter.py", line 187, in run
    events = self.get_events()
  File "./seedlink_plotter.py", line 204, in get_events
    min_magnitude=self.args.events)
  File "/usr/local/lib/python2.7/site-packages/obspy-0.0.0_tar_zipball-py2.7-linux-x86_64.egg/obspy/neries/client.py", line 82, in wrapper
    v = f(*args, **new_kwargs)
  File "/usr/local/lib/python2.7/site-packages/obspy-0.0.0_tar_zipball-py2.7-linux-x86_64.egg/obspy/neries/client.py", line 280, in getEvents
    data = self._fetch("/services/event/search", **kwargs)
  File "/usr/local/lib/python2.7/site-packages/obspy-0.0.0_tar_zipball-py2.7-linux-x86_64.egg/obspy/neries/client.py", line 161, in _fetch
    response = urllib2.urlopen(remoteaddr, timeout=self.timeout)
  File "/usr/lib64/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib64/python2.7/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.7/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib64/python2.7/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.7/urllib2.py", line 1189, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib64/python2.7/urllib2.py", line 1164, in do_open
    raise URLError(err)
URLError: <urlopen error timed out>

Time problem if more than 15 stations

If I select more that 15 stations, it seems that the parameter "-b" is not taken into account.

example
seedlink-plotter -s "G_AIS:00BHZ,G_ATD:00BHZ,G_CAN:00BHZ,G_CCD:00BHZ,G_CLF:00BHZ,G_COYC:00BHZ,G_CRZF:00BHZ,G_DRV:00BHZ,G_DZM.OO.BHZ,G_ECH:00BHZ,G_FDF:00BHZ,G_FOMA:00BHZ,G_FUTU:00BHZ,G_HDC:00BHZ,G_INU:00BHZ,G_IVI:00BHZ,G_KIP:00BHZ,G_MBO:00BHZ,G_MPG_00.BHZ,G_NOUC:00BHZ,G_PAF:00BHZ,G_PEL:00BHZ,G_PPTF:00BHZ,G_RER:00BHZ,G_ROCAM:00BHZ,G_SANVU:00BHZ,G_SPB:00BHZ,G_SSB:00BHZ,G_TAM:00BHZ,G_TAOE:00BHZ,G_UNM:00BHZ,G_WUS:00BHZ" --x_position 200 --y_position 50 --x_size 800 --y_size 600 -b 24h --seedlink_server "rtserver.ipgp.fr:18000" --update_time 2s

singlechannel plot: ticklabels inside of axes?

I was considering moving the ticklabels for singlechannel plots inside, like we have for multichannel plot. That way we do not have problems with cut-off labels anymore and don't waste space outside of the axis. It also looks more like a full screen kiosk-type display when maximized..
What do you think @bonaime?

need to clear processing list of traces after trim() in plot_graph()

Hi Guys

Since I have not yet had the time to learn how github works I report on this here instead and let you sort out if this is worth fixing or not.

Problem:
Every time the trim() method of a Stream or Trace object is used an entry is added to the list Trace.stats.processing, thus if the seedlink_plotter is run 24/7 with an update time of 1s this list will eventually grow large.

Solution:
I therefore suggest to loop over the traces after each use of the trim() method invocation and pop the last entry of trace_i.stats.processing

regP

UserWarning in Multichannel

I have the following warning just after starting seedlink plotter

seedlink-plotter -s "G_IVI:00BHZ BHN, G_SSB:00BHZ"  --seedlink_server "rtserver.ipgp.fr:18000" --with_decoration -b 0.2
SLClient comes with ABSOLUTELY NO WARRANTY
/usr/local/lib/python2.7/site-packages/matplotlib/axes.py:2760: UserWarning: Attempting to set identical bottom==top results
in singular transformations; automatically expanding.
bottom=0.0, top=0.0
  + 'bottom=%s, top=%s') % (bottom, top))

It appears once after the first plot.

reconnect on interrupted connection to server

I noticed that when the server goes offline and comes back online again we still do net get the data again. Maybe we could prompt a reconnect to server when we end up with a completely empty stream (i.e. no data on any station anymore).

But.. low priority as I think for most use cases restarting the plotter in a cronjob at night makes most sense, just wanted to mention here.

Memory leaks

With long running multichannel plots I've experienced memory usage going up over time. I am not sure yet if it is a problem of the seedlink updating or the plotting, I've tried to debug this using objgraph but without success so far.. (the multiple threads make it a bit harder to debug..).

CPU load when monitoring many stations

Hi

Potentially this is a minor problem but as I stumbled across it I figured that I might as well report it here.

Running the seedlink_plotter for many streams I noted that the CPU usage quickly increased to 100% on my machine. There may of course many reasons for this but focusing on the data retrieval part I note that merging newly retrieved traces to the Stream object seems to account for most of the load. Looking deeper into the merge method of the stream object I suspect that this is due to the fact that trace list is regenerated every time the the merge method is invoked. If the stream object contains only few traces and this is not done very often this is not a problem, however for an application as the seedlink_plotter were the method may be called several times per second, adding one trace at the time, and the Stream object may contain many traces this adds an unnecessary overhead.

In the long term run perhaps adding a method to the Stream object that merges (or adds) a single trace to the list of traces is the desired solution and perhaps this should have been brought up as an issue on obspy instead (I report here instead as for now the issue seems more application specific and knowing that you are involved in the obspy development perhaps the suggestion if found useful eventually make its way in there).

My current (simplistic) workaround to the issue is to rip the core of the _cleanup method (used by merge(-1)) from the Stream object and make sure that only the traces with the same trace.id as the trace to merge in (if any) are touched. This reduces the CPU load on my machine from 100% to 10-20%

More exactly I came up with the following method that I added to the SeedlinkUpdater object

def addTrace(self,trace,misalignment_threshold=1e-2):
  """ 
  function add_trace() adds an obspy Trace object to an obspy Stream object
  normally this would be handled by the merge method of the Stream object, 
  however this iterates over all traces in the stream object which yields an 
  unneccesary large overhead in case of addition of a single Trace object to
  a Stream object that already contains a large number of Trace objects

  Core of this function is directly copied from the _cleanup method of the
  Stream object and stripped from large parts of the documentation

  ======= parameters =======
  :type  trace: `obspy.Trace`
  :param trace: Trace object to add
  ---
  :type  misalignment_threshold: float
  :param misalignment_threshold: Threshold value for sub-sample
        misalignments of sampling points of two traces that should be
        merged together (fraction of sampling interval, from 0 to 0.5).
  """
  ind = [i for i in range(len(self.stream.traces)) if self.stream.traces[i].id == trace.id]
  if not ind:
     # trace is not in stream, simply append it
     self.stream.traces.append(trace)
     return

  # extract the matching traces
  ind.sort(reverse=True)  # make sure items are poped from back first to not mess up index to items to pop
  trace_list = [self.stream.traces.pop(i) for i in ind]
  trace_list.append(trace)
  trace_list.sort(key=lambda i:i.stats.starttime)

  # merge the traces
  cur_trace = trace_list.pop(0)
  delta = cur_trace.stats.delta
  allowed_micro_shift = misalignment_threshold * delta
  # work through all traces of same id
  while trace_list:
     trace = trace_list.pop(0)
     gap = trace.stats.starttime - (cur_trace.stats.endtime + delta)
     if misalignment_threshold > 0 and gap <= allowed_micro_shift:
        # `gap` is smaller than allowed shift (or equal)
        misalignment = gap % delta
        if misalignment != 0:
           misalign_percentage = misalignment / delta
           if (misalign_percentage <= misalignment_threshold or misalign_percentage >= 1 - misalignment_threshold):
                 # now we align the sampling points of both traces
                 trace.stats.starttime = (cur_trace.stats.starttime+round((trace.stats.starttime - cur_trace.stats.starttime) / delta) * delta)
     # we have some common parts: check if consistent
     subsample_shift_percentage = (trace.stats.starttime.timestamp-cur_trace.stats.starttime.timestamp) % delta / delta
     subsample_shift_percentage = min(subsample_shift_percentage, 1 - subsample_shift_percentage)
     if (trace.stats.starttime <= cur_trace.stats.endtime and subsample_shift_percentage < misalignment_threshold):
        # check if common time slice [t1 --> t2] is equal:
        t1 = trace.stats.starttime
        t2 = min(cur_trace.stats.endtime, trace.stats.endtime)
        if np.array_equal(cur_trace.slice(t1, t2).data,trace.slice(t1, t2).data):
           # if consistent: add them together
           cur_trace += trace
        else:
           # if not consistent: leave them alone
           self.stream.traces.append(cur_trace)
           cur_trace = trace
     elif trace.stats.starttime == cur_trace.stats.endtime+cur_trace.stats.delta:
        # traces are perfectly adjacent: add them together
        cur_trace += trace
     else:
        # no common parts (gap) leave traces alone and add current to list
        self.stream.traces.append(cur_trace)
        cur_trace = trace
  self.stream.traces.append(cur_trace)

DATA/FETCH/TIME command is not accepted

Hi,
The stream I try, doesn't get plotted and in verbose mode, I get errors like above:

...response: DATA/FETCH/TIME command is not accepted
...negotiation with remote SeedLink failed: u'no stations accepted'
...network socket closed
...primary loop pass 0, state 0

Seedlink plotter kills my MacOs WindowServer !

I just reinstalled Seedlink plotter with

pip install https://github.com/bonaime/seedlink_plotter/archive/master.zip

Then when I try this command
seedlink-plotter --seedlink_server "rtserver.ipgp.fr:18000" -s "G_SSB:10HHZ" --line_plot -b 50 -v
I have a black screen and then the MacOs Login interface. seedlink-plotter just killed my WindowServer !

MacOs Mojave10.14.6

INFO: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:connected to: 'SeedLink v3.2 (2014.071)'
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:sending: STATION  SSB G
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:response: station is OK (selected)
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:sending: b'SELECT 10HHZ'
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:response: selector b'10HHZ' is OK
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:response: 1 selector(s) accepted
INFO: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:requesting specified time window
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:sending: b'TIME 2019,9,3,15,49,39'
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:response: DATA/FETCH/TIME command is OK
INFO: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:1 station(s) accepted
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:sending: END
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:primary loop pass 0, 2019-09-03 19:50:46.911 python[8014:401917] HIToolbox: received notification of WindowServer event port death.
2019-09-03 19:50:48.666 python[8014:401917] port matched the WindowServer port created in BindCGSToRunLoop
state 2
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:primary loop pass 0, state 2
INFO:root:0 Trace(s) in Stream:

ERROR:root:Empty stream for plotting
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:primary loop pass 0, state 2
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:primary loop pass 0, state 2
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:primary loop pass 0, state 2
DEBUG: obspy.clients.seedlink [rtserver.ipgp.fr:18000]:primary loop pass 0, state 2
```

Tcl-Tk and Yosemite on Macos

Hi,
I just upgraded to Yosemite with latest obspy dev version installed using homebrew.

With this simple code

seedlink-plotter --seedlink_server "rtserver.ipgp.fr:18000"  -s "G_RER:BHZ" -b 3600

I have the following error:

objc[87267]: Class TKApplication is implemented in both /usr/local/opt/tcl-tk/lib/libtk8.6.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[87267]: Class TKMenu is implemented in both /usr/local/opt/tcl-tk/lib/libtk8.6.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[87267]: Class TKContentView is implemented in both /usr/local/opt/tcl-tk/lib/libtk8.6.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
objc[87267]: Class TKWindow is implemented in both /usr/local/opt/tcl-tk/lib/libtk8.6.dylib and /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk. One of the two will be used. Which one is undefined.
Traceback (most recent call last):
  File "/usr/local/bin/seedlink-plotter", line 9, in <module>
    load_entry_point('seedlink-plotter==0.1.0', 'console_scripts', 'seedlink-plotter')()
  File "/usr/local/lib/python2.7/site-packages/seedlink_plotter/seedlink_plotter.py", line 476, in main
    trace_ids=ids)
  File "/usr/local/lib/python2.7/site-packages/seedlink_plotter/seedlink_plotter.py", line 59, in __init__
    canvas.show()
  File "/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 350, in draw
    tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
  File "/usr/local/lib/python2.7/site-packages/matplotlib/backends/tkagg.py", line 24, in blit
    tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array))
_tkinter.TclError

I am sure it is not linked with seedlink-plotter, but I would like to know what is the best way to solve this conflicting library problem. With the following code I have the same error

import Tkinter
from PIL import ImageTk
Tkinter.Tk()
ImageTk.PhotoImage(file='test_image.jpg')

Problem when plotting multiple channels of the same station

There is a bug when I try to plot at least two channels of the same station like

-s "G_FDF:00BHZ,G_FDF:00BHN"

The error is

Traceback (most recent call last):
  File "seedlink_plotter/seedlink_plotter.py", line 446, in <module>
    main()
  File "seedlink_plotter/seedlink_plotter.py", line 426, in main
    ids = cl.getTraceIDs()
  File "seedlink_plotter/seedlink_plotter.py", line 272, in getTraceIDs
    ids.append(".".join((net, sta, loc, cha)))
TypeError: sequence item 2: expected string, list found

pip install, matplotlib and Macos

I had problems using pip to install seedlink_plotter on my mac.
pip install https://github.com/bonaime/seedlink_plotter/archive/master.zip
The error was during the matplotlib compilation.

usr/X11/include/ft2build.h:56:38: error: freetype/config/ftheader.h: No such file or directory

I solved this issue by exporting two variables before doing the pip install:

export LDFLAGS="-L/usr/X11/lib"
export CFLAGS="-I/usr/X11/include -I/usr/X11/include/freetype2 -I/usr/X11/include/libpng12"

URLerror

Hello,

I tried one both examples in readme: e.g. seedlink-plotter -s "G_MBO:00BHZ" -b 10m --seedlink_server "rtserver.ipgp.fr:18000" --line_plot

And I get the following error:

Traceback (most recent call last):
  File "/Users/sph1r17/anaconda/bin/seedlink-plotter", line 11, in <module>
    load_entry_point('seedlink-plotter==0.1.0', 'console_scripts', 'seedlink-plotter')()
  File "/Users/sph1r17/anaconda/lib/python3.6/site-packages/pkg_resources/__init__.py", line 560, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Users/sph1r17/anaconda/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2648, in load_entry_point
    return ep.load()
  File "/Users/sph1r17/anaconda/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2302, in load
    return self.resolve()
  File "/Users/sph1r17/anaconda/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2308, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Users/sph1r17/anaconda/lib/python3.6/site-packages/seedlink_plotter/seedlink_plotter.py", line 420
    except URLError, error:

Drum plots with backtrace_time and x_scale not well choosen

If the user choose a backtrace_time which is not a divisible by x_scale, the plots seems to be not in real time. Maybe we should prevent the user to do so.

If backtrace_time % x_scale:
print 'backtrace_time should be a mutltiple of x_scale'
exit(0)

change host

Can I change the host:port(rtserver.ipgp.fr:18000) to rtserve.iris.washington.edu:18000,
seedlink-plotter -s "US_MSO:00BHZ" --x_position 200 --y_position 50 --x_size 800 --y_size 600 -b 30m --seedlink_server "rtserve.iris.washington.edu:18000" --update_time 2s
but no plot,i dont konw why.

Localisation bug

Today,
A very strange event appeared on my 4 seedlink_plotters : a 7.0m earthquake in North Algeria which does not exist.
Each morning I start those seedlink_plotters at 8:00 UTC. The earthquake origin is around 00:42, more than 7 hours before I started my programs.
After restarting seedlink_plotters, the event is gone.

capture d ecran 2016-01-14 a 14-01-16 09 57 20

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.