# QC receiver functions

**URL:** <https://discourse.obspy.org/t/qc-receiver-functions/1635>\
**Category:** Related: rf\
**Created:** [February 17, 2023, 9:39pm UTC](https://discourse.obspy.org/t/qc-receiver-functions/1635 "2023-02-17T21:39:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qian](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/q/b782af/32.png) [@Qian](https://discourse.obspy.org/u/Qian)\
**Post date:** [February 17, 2023, 9:39pm UTC](https://discourse.obspy.org/t/qc-receiver-functions/1635/1 "2023-02-17T21:39:08Z")

</div>

Hi Tom!  
As I see it is more convenient to do the QC right before deconvolution.  
For processing the RF, some of the lines of my code are:  
Script 1 example

```python
stream3c.rf()
stream3c.moveout()
stream.extend(stream3c) 

```

Since stream3c.rf() is doing the rotation and deconvolution, I don’t find a way to inset my signal-to-noise ratio in between.  
I was trying to do:  
Script 2 example

```python
stream3c.rotate(method='ZNE->LQT')
#[posible signal-to-noise ratio function] here
stream3c.deconvolve(method='time')
stream3c.moveout()

```

I just ran this script (script 2 example) without the Signal to noise ratio function and the inserted arguments, but I am not getting same results as the script 1 example.

Do you have some ideas to perform the QC before deconvolution?  
Many thanks in advance!

---

<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:** [February 18, 2023, 9:53pm UTC](https://discourse.obspy.org/t/qc-receiver-functions/1635/2 "2023-02-18T21:53:20Z")

</div>

Hi Qian!

You can look up the source code of `RFStream.rf()` [here](https://rf.readthedocs.io/en/latest/_modules/rf/rfstream.html#RFStream.rf). And yes, it is basically rotation and deconvolution, but also switching the polarity of the Q component.

I think for QC I used a signal-to-noise ratio of 2, but I guess a lot of different approaches are possible here.

I replaced the dots `...` in your post with back ticks. Code blocks then are nicely formatted.

---

<div class="post-metadata">

**Author:** ![Qian](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/q/b782af/32.png) [@Qian](https://discourse.obspy.org/u/Qian)\
**Post date:** [February 19, 2023, 11:09pm UTC](https://discourse.obspy.org/t/qc-receiver-functions/1635/3 "2023-02-19T23:09:17Z")

</div>

Thanks @trichter!

At the end the following code seems to work.

```python
    stream3c.rotate(method='ZNE->LQT') 
    for tr in stream3c: #sign change 
        if tr.stats.channel.endswith('Q'):
            tr.data = -tr.data
    stream3c.snr_compute() #signal to noise ratio function
    if stream3c[1].stats.SNR>6:
        stream3c.deconvolve(method='time', source_components='LZ') 
        stream3c.moveout()
        stream.extend(stream3c) 

```

Do you think that I am missing an important argument? Specially for the deconvolution. I just added method and source\_components=‘LZ’.  
There is one line that I skipped kwargs.setdefault(‘winsrc’, method).  
Do you think it is important?

Thanks again in advance!

---

<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:** [February 20, 2023, 7:51am UTC](https://discourse.obspy.org/t/qc-receiver-functions/1635/4 "2023-02-20T07:51:17Z")

</div>

Looks perfect. `winsrc` is not important in your case. It defines the time window for cutting the data of the source component and defaults to `'P'`, resp. `(-10, 30, 5)` for time deconvolution (starttime, endtime in seconds relative to onset, taper at both ends in seconds). `winsrc` should be changed for Srfs.

---

<div class="post-metadata">

**Author:** ![Qian](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/q/b782af/32.png) [@Qian](https://discourse.obspy.org/u/Qian)\
**Post date:** [February 20, 2023, 5:38pm UTC](https://discourse.obspy.org/t/qc-receiver-functions/1635/5 "2023-02-20T17:38:01Z")

</div>

Thank you so much Tom!!
