Using own script to import RS3D data and modify traces with ObsPy; order of channels?

Not sure if “developers” is the right category, let me know if not… Anyway, I got a small Python script to do custom plotting with ObsPy, the goal being to live-plot incoming RS3D data (RS is connected over local network). I know about the RSUDP client, which works nicely, but we’d like to do some seismic analysis with ObsPy on the traces that we extract from the shake. First I import some modules

import rsudp.raspberryshake as rs
from obspy.core.stream import Stream
import obspy as obs
from obspy import read
import matplotlib.pyplot as plt

after which I initialize the shake with rs.initRSlib(). Now, the current problem is that subsequently calling d1 = rs.getDATA() assigns only one channel’s data to d1. I thought I could fix that by calling rs.getDATA() three times in a row, each time assigning the output (a different channel/component) to a different variable: d1, d2, d3, however the order of channels is not the same every time I call this function. One time it may be Z, N, E, the other time it may be Z, E, N. Or more problematic, it even extracts the same component twice in three calls of rs.getDATA().
This may be unnecessary to mention, but just to be sure, the next steps are to extract a trace for each channel, which I can then plot with ObsPy.

tr1 = rs.make_trace(d1) 
tr2 = rs.make_trace(d2)
tr3 = rs.make_trace(d3)

Is there a robust way to extract the trace data for each component separately, every time I refresh the data import?

RSH.R1FFA.2023-10-13T07 41 36.logs.tar (1.1 MB)

1 Like

I have a 4D and I only live plot the EHZ channel. This is how I find the channel data I want to work with:

d = rs.getDATA()
if ('EHZ' in str(d)):
    t = rs.make_trace(d)
    ... *rest of code*

The if statement checks for the desired channel ID in the data returned from the getDATA() call.

–Steve
RS4D - RD29A

3 Likes

Hello jvmeul,

In addition to Steve’s great suggestion, I would also add a check for duplicates once you call rs.getDATA(). This to avoid what you said towards the end of your post by adopting a logic that goes along these lines:

  1. execute rs.getDATA()
  2. get the acquired channel list; then two options:
    3.1 If no duplicates are present, proceed with Steve’s advice
    3.2 If duplicates are present, then re-execute rs.getDATA()

Otherwise, if you have direct access to the Shake in your local network (via SSH), you could set up direct .mseed data download with paramiko, copy them to your local drive, and then read all the files with ObsPy, using its Read miniSEED function: obspy.io.mseed - MiniSEED read and write support for ObsPy — ObsPy 1.4.0 documentation for the entire folder structure (all channels) or for a single channel.

1 Like