rsudp.c_plot (plot data)


An event recorded on a vertical geophone by rsudp and saved by the plotting module.

class rsudp.c_plot.Plot(q, cha='all', seconds=30, spectrogram=True, fullscreen=False, kiosk=False, deconv=False, screencap=False, alert=True)

GUI plotting algorithm, compatible with both Qt5 and TkAgg backends (see matplotlib.use()). This module can plot seismogram data from a list of 1-4 Shake channels, and calculate and display a spectrogram beneath each.

By default the plotted “duration” in seconds is 30. The plot will refresh at most once per second, but slower processors may take longer. The longer the duration, the more processor power it will take to refresh the plot, especially when the spectrogram is enabled. To disable the spectrogram, set “spectrogram” to false in the settings file. To put the plot into fullscreen window mode, set “fullscreen” to true. To put the plot into kiosk mode, set “kiosk” to true.

  • cha (str or list) – channels to plot. Defaults to “all” but can be passed a list of channel names as strings.

  • seconds (int) – number of seconds to plot. Defaults to 30.

  • spectrogram (bool) – whether to plot the spectrogram. Defaults to True.

  • fullscreen (bool) – whether to plot in a fullscreen window. Defaults to False.

  • kiosk (bool) – whether to plot in kiosk mode (true fullscreen). Defaults to False.

  • deconv (str or bool) – whether to deconvolve the signal. Defaults to False.

  • screencap (bool) – whether or not to save screenshots of events. Defaults to False.

  • alert (bool) – whether to draw the number of events at startup. Defaults to True.

  • q (queue.Queue) – queue of data and messages sent by rsudp.c_consumer.Consumer


ImportError – if the module cannot import either of the Matplotlib Qt5 or TkAgg backends


Send the streams to the central library deconvolve function.


Let some time elapse in order for the plot canvas to draw properly. Must be separate from update_plot() to avoid a broadcast error early in plotting.


Get data from the queue and test for whether it has certain strings. ALARM and TERM both trigger specific behavior. ALARM messages cause the event counter to increment, and if screencap==True then aplot image will be saved when the event is self.save_pct of the way across the plot.


Handles a plot close event. This will trigger a full shutdown of all other processes related to rsudp.


Handles a plot window resize event. This will allow the plot to resize dynamically.

mainloop(i, u)

The main loop in the

  • i (int) – number of plot events without clearing the linecache

  • u (int) – queue blocking counter


number of plot events without clearing the linecache and queue blocking counter

Return type

int, int


Get a queue object and increment the queue counter. This is a way to figure out how many channels have arrived in the queue.


u (int) – queue blocking counter


queue blocking counter

Return type



The heart of the plotting routine.

Begins by updating the queue to populate a object, then setting up the main plot. The first time through the main loop, the plot is not drawn. After that, the plot is drawn every time all channels are updated. Any plots containing a spectrogram and more than 1 channel are drawn at most every second (1000 ms). All other plots are drawn at most every quarter second (250 ms).

savefig(event_time=UTCDateTime(2020, 4, 28, 0, 15, 13, 221122), event_time_str='2020-04-28-001513')

Saves the figure and puts an IMGPATH message on the master queue. This message can be used to upload the image to various services.


Get samples per second from the main library.


Sets up the plot. Quite a lot of stuff happens in this function. Matplotlib backends are not threadsafe, so things are a little weird. See code comments for details.


Redraw the plot with new data. Called on every nth loop after the plot is set up, where n is the number of channels times the data packet arrival rate in Hz. This has the effect of making the plot update once per second.

Back to top ↑