# Signal Visibility Reduction in Spectrograms Following Whitening Process (PyCBC)

**URL:** <https://ask.igwn.org/t/signal-visibility-reduction-in-spectrograms-following-whitening-process-pycbc/1021>\
**Category:** Data Analysis\
**Created:** [April 25, 2024, 3:25am UTC](https://ask.igwn.org/t/signal-visibility-reduction-in-spectrograms-following-whitening-process-pycbc/1021 "2024-04-25T03:25:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elahe](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@Elahe](https://ask.igwn.org/u/Elahe)\
**Post date:** [April 25, 2024, 3:25am UTC](https://ask.igwn.org/t/signal-visibility-reduction-in-spectrograms-following-whitening-process-pycbc/1021/1 "2024-04-25T03:25:40Z")

</div>

Dear all,

I am currently using PyCBC to simulate gravitational wave data and have encountered an output related to spectrogram that I would like to better understand.

Enclosed are three spectrogram images for your perusal:

1. The first image illustrates the spectrogram generated without the application of whitening or band-pass filtering, where the signal is clearly visible.
2. The subsequent images depict the results after implementing whitening and band-pass filtering processes, where, intriguingly, the signal seems to vanish.

I have utilized the noise data from the LIGO website, and I find it quite strange that the signal disappears after the whitening process. Could you please share your thoughts on this?

Best regards,  
Elahe

 ![without whitening+filtering](https://canada1.discourse-cdn.com/flex031/uploads/gwosc/original/1X/a8c67552e56fde9bbfeeb4828f13fd2af6ab5a2d.jpeg)  
 ![whitening](https://canada1.discourse-cdn.com/flex031/uploads/gwosc/original/1X/1657b747c1770c9c7069a0c83b7f7fc9e8b9b835.jpeg)  
 ![whitening+filtering](https://canada1.discourse-cdn.com/flex031/uploads/gwosc/original/1X/174c4cdd26f3256f5786cb28675972b4f7ccadfc.jpeg)

---

<div class="post-metadata">

**Author:** ![BarryG](https://avatars.discourse-cdn.com/v4/letter/b/9f8e36/32.png) [@BarryG](https://ask.igwn.org/u/BarryG)\
**Post date:** [April 27, 2024, 6:26am UTC](https://ask.igwn.org/t/signal-visibility-reduction-in-spectrograms-following-whitening-process-pycbc/1021/2 "2024-04-27T06:26:14Z")

</div>

Hi Elahe:  
It seems that you’re suffering from whitening.  
Can you tell us how do you perform the whitening? Since the motivation of whitening is to mitigate the effect of instrumental noise. So you should select a stationary segment near the data and then estimate your PSD on it, then perform the whitening on the data. (I suppose you’re whitening with the data contains the signal which will mitigate the signal itself)

BTW, if you’re using gwpy package, I mean gwpy timeseries, their q\_transform and spectrogram has a normalization( I’ve mentioned this in a thread about spectrogram) on the time-frequency plot which is pretty similar to the whitening of the data, so one might not be able to find much difference between them. A suggestion is write your own q-transform of spectrogram plot without applying the normalization strategy to see the differences.

---

<div class="post-metadata">

**Author:** ![Elahe](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@Elahe](https://ask.igwn.org/u/Elahe)\
**Post date:** [May 1, 2024, 8:22am UTC](https://ask.igwn.org/t/signal-visibility-reduction-in-spectrograms-following-whitening-process-pycbc/1021/3 "2024-05-01T08:22:19Z")

</div>

Hello Barry,

Thank you for your detailed explanation. Upon reviewing the code, I noticed that the amplitude of the generated signal is larger than that of the noise. I’m not sure where I might have made a mistake. Here is the code:

params = dict(  
wf\_approximant=“SEOBNRv4” ,  
mass\_1=36,  
mass\_2=29,  
luminosity\_distance = 400,  
f\_start=20,  
f\_ref=20,  
sample\_rate=2048  
)  
def strain\_T(params):  
hp, hc = get\_td\_waveform(  
approximant=params[‘wf\_approximant’],  
mass1=params[‘mass\_1’],  
mass2=params[‘mass\_2’],  
distance=params[‘luminosity\_distance’],  
f\_lower=params[‘f\_start’],  
f\_ref=params[‘f\_ref’],  
delta\_t=1.0 / params[‘sample\_rate’]  
)  
return hp, hc

hf=hp.to\_frequencyseries()  
freq=hf.sample\_frequencies  
flen=len(freq)  
delta\_f=hf.delta\_f  
low\_frequency\_cutoff=20  
delta\_t=1.0/2048

psd = pycbc.psd.aLIGODesignSensitivityP1200087(flen, delta\_f, low\_frequency\_cutoff)  
noise = pycbc.noise.noise\_from\_psd(len(hp.data), delta\_t, psd, seed=127)  
noise.start\_time=hp.start\_time  
data= hp+noise

 ![waveform](https://canada1.discourse-cdn.com/flex031/uploads/gwosc/original/1X/a7f8cef7f94cd308610691e7f23511f4521ceec8.jpeg)

Once this issue is resolved, I will proceed with applying the whitening process as you suggested.

---

<div class="post-metadata">

**Author:** ![BarryG](https://avatars.discourse-cdn.com/v4/letter/b/9f8e36/32.png) [@BarryG](https://ask.igwn.org/u/BarryG)\
**Post date:** [May 6, 2024, 4:31pm UTC](https://ask.igwn.org/t/signal-visibility-reduction-in-spectrograms-following-whitening-process-pycbc/1021/4 "2024-05-06T16:31:52Z")

</div>

It can be the problem of parameter selection.  
An idea is:

1. Obtain the PSD of the current noise
2. Use the noise PSD to calculate the current SNR
3. set new\_sig = sig/current\_SNR \* tartget\_SNR to obtain a signal with specified SNR

---

<div class="post-metadata">

**Author:** ![Elahe](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@Elahe](https://ask.igwn.org/u/Elahe)\
**Post date:** [May 8, 2024, 1:21am UTC](https://ask.igwn.org/t/signal-visibility-reduction-in-spectrograms-following-whitening-process-pycbc/1021/5 "2024-05-08T01:21:42Z")

</div>

Hi,

Yes, Thanks so much for your time and help.
