Trying to download and save data from RS1D Acceleration

I’m currently using swarm.bat from the Raspberry Shake Website but when I read in the file, all I get is count on my RS1d. I tried using the obspy library and trying to read in the velocity that way from past forums and it works to gather old data, but I keep getting an error when I try to read in my current RS1D, which is data forwarding.

The code I have set is:

from obspy.clients.fdsn import Client
from obspy.core import UTCDateTime, Stream
rs = Client('RASPISHAKE')

# set the station name and download the response information
stn = 'RASPBERRYSHAKEID     ### <<< replace this with your station name ###
inv = rs.get_stations(network='AM', station=stn, level='RESP')

# set data start/end times
start = UTCDateTime(2023, 3, 7, 2, 40, 45) # (YYYY, m, d, H, M, S)
end = UTCDateTime(2023, 3, 7, 2, 42, 0) # (YYYY, m, d, H, M, S)

# set the FDSN server location and channel names
channels = ['ENZ'] # ENx = accelerometer channels; EHx or SHZ = geophone channels

# get waveforms and put them all into one Stream
stream = Stream()
for ch in channels:
    trace = rs.get_waveforms('AM', stn, '00', ch, start, end)
    stream += trace

# here you will plot raw counts for all four channels
stream.plot()

Also what does level mean and what should I put there?

If there’s any alternative way to read and download the velocity values, that would be great too.

1 Like

G’Day Brian,

Welcome aboard.

A cursory look at your code tells me it will only give you the raw waveform as is. To get velocity you need to remove the instrument response from the trace.

I would suggest adding something like the following code before the “stream += trace” line.


trace.merge(method=0, fill_value='latest')         #fill in any gaps in the data to prevent a crash
trace.detrend(type='demean')                       #demean the data
filt = [0.7, 0.7, 2, 2.1]   #bandpass filter between 0.7 and 2 Hz for example - adjust as you like
trace = trace.remove_response(inventory=inv,pre_filt=filt,output='VEL',water_level=60, plot=False) # convert to Velocity

Al.

1 Like

Hello brian17, and welcome to our community!

I have edited how your code was displayed to make it more readable.

As sheeny has suggested, the current code will output the basic raw data from your Shake, so to obtain velocity, you can easily utilize his code and then plot/operate on the resulting trace.

Thank you so much. I still get this error though:

FDSNNoDataException: No data available for request.
HTTP Status code: 204
Detailed response of server:

I assume it’s from this line and I’m inputting an improper level:
inv = rs.get_stations(network=‘AM’, station=stn, level=‘RESP’)

Is there a way to figure out what level means and how to find it?

Thanks

You’re welcome; no problem at all.

You should be able to find more information here, on the get_stations page of ObsPy: obspy.clients.fdsn.client.Client.get_stations — ObsPy 1.4.0 documentation

It is possible that you’ll have to change the level=‘RESP’ to level=response to acquire this data without issues if you have the latest ObsPy version installed (v1.3.1). I’ve tested this with my Shake, and it appears to be working:

from obspy.clients.fdsn import Client
from obspy.core import UTCDateTime, Stream
rs = Client('RASPISHAKE')

# set the station name and download the response information
stn = 'R1234`     ### <<< replace this with your station name ###
inv = rs.get_stations(network='AM', station=stn, level='response')

# set data start/end times
start = UTCDateTime(2023, 3, 7, 2, 40, 45) # (YYYY, m, d, H, M, S)
end = UTCDateTime(2023, 3, 7, 2, 42, 0) # (YYYY, m, d, H, M, S)

# set the FDSN server location and channel names
channels = ['EHZ'] # ENx = accelerometer channels; EHx or SHZ = geophone channels

# get waveforms and put them all into one Stream
stream = Stream()
for ch in channels:
    trace = rs.get_waveforms('AM', stn, '00', ch, start, end)
    stream += trace

# here you will plot raw counts for all four channels
stream.plot()

Thanks. I got it to work. Would velocity/acceleration be measured in micro g in this case and do we have to account for gravity?

1 Like

Hello Brian,

Perfect, that’s great to hear!

Velocity and Acceleration would be measured (as per ObsPy documentation: obspy.core.trace.Trace.remove_response — ObsPy 1.4.0 documentation) in m/s and m/s**2`, respectively.

If you want to obtain the acceleration in micro g, you will need to apply a conversion formula to the values you get after removing the response.

1 Like