RF, reading SAC downloaded via SOD

Fairly new to ObsPy; sorry a likely naive question, I have SAC files (network=US; station name=GLMI; components; BH1, BH2, BHZ) downloaded using SOD and want to calculate a receiver function using RF. Following the manual, I succeed to read:

from rf import read_rf, rfstats, RFStream
data = read_rf(‘US.GLMI.00.BH?.sac’)
stream = RFStream()

print('aa ', data[0].stats.sac.kstnm) returns:
aa GLMI

but the command:

stats = rfstats(station=station, event=event, phase=‘P’, dist_range=(30,90))

returns a NameError:


NameError Traceback (most recent call last)
in
----> 1 stats = rfstats(station=station, event=event, phase=‘P’, dist_range=(30,90))

NameError: name ‘station’ is not defined

I guess I do not understand RFStream and how to fill the “station” and “event” fields.

Thanks!

Hi, welcome!

If event and station info are already present in the SAC files,
please try the following code snippet

from rf import read_rf, rfstats
stream = read_rf('US.GLMI.00.BH?.sac')
print(stream)
print(stream[0].stats)
rfstats(stream)
print(stream[0].stats)

Your code does not define the variables station and event which are used in your call to rfstats.

Edit: read_rf already returns a RFStream object.

This works. Thanks for the help! As a side note, I did have to change EVDP in the SAC header because ObsPy’s TauP utility assumes km, not meters.

Interesting. If meters are standard for EVDP in SAC than rf should ideally take care of conversion to km on reading.

Not sure whether METERS are used consistently. DIST for example is given in KM.