# RF, reading SAC downloaded via SOD

**URL:** https://discourse.obspy.org/t/rf-reading-sac-downloaded-via-sod/1138
**Category:** Related: rf
**Created:** [November 25, 2020, 10:26am UTC](https://discourse.obspy.org/t/rf-reading-sac-downloaded-via-sod/1138 "2020-11-25T10:26:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jritsema](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jritsema](https://discourse.obspy.org/u/jritsema)
#### Post date: [November 25, 2020, 10:26am UTC](https://discourse.obspy.org/t/rf-reading-sac-downloaded-via-sod/1138/1 "2020-11-25T10:26:51Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![trichter](https://discourse.obspy.org/user_avatar/discourse.obspy.org/trichter/32/226_2.png) [@trichter](https://discourse.obspy.org/u/trichter)
#### Post date: [November 25, 2020, 10:39am UTC](https://discourse.obspy.org/t/rf-reading-sac-downloaded-via-sod/1138/2 "2020-11-25T10:39:51Z")

</div>

Hi, welcome!

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

```python
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.

---

<div class="post-metadata">

### Author: ![jritsema](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jritsema](https://discourse.obspy.org/u/jritsema)
#### Post date: [November 25, 2020, 11:21am UTC](https://discourse.obspy.org/t/rf-reading-sac-downloaded-via-sod/1138/3 "2020-11-25T11:21:44Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![trichter](https://discourse.obspy.org/user_avatar/discourse.obspy.org/trichter/32/226_2.png) [@trichter](https://discourse.obspy.org/u/trichter)
#### Post date: [November 25, 2020, 1:38pm UTC](https://discourse.obspy.org/t/rf-reading-sac-downloaded-via-sod/1138/4 "2020-11-25T13:38:04Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jritsema](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jritsema](https://discourse.obspy.org/u/jritsema)
#### Post date: [November 25, 2020, 1:41pm UTC](https://discourse.obspy.org/t/rf-reading-sac-downloaded-via-sod/1138/5 "2020-11-25T13:41:06Z")

</div>

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