I would like to calculate a whitened spectrogram of the gravitational-wave strain signal to try and find some signals...
We can quickly fetch the data we want using the TimeSeries.fetch() method:
>>> from gwpy.timeseries import TimeSeries
>>> gwdata = TimeSeries.fetch('H1:LDAS-STRAIN', 'September 16 2010 06:40', 'September 16 2010 06:50')
>>> gwdata.unit = 'strain'
We can then generate a Spectrogram by calling the spectrogram() method of the existing TimeSeries, taking a square root to return an amplitude spectral density spectrogram, rather than a power spectral density spectrogram
>>> specgram = gwdata.spectrogram(5, fftlength=2, overlap=1) ** (1/2.)
and can whiten it by normalising with the median in each frequency bin using the ratio() method:
>>> medratio = specgram.ratio('median')
Not we can plot it:
>>> plot = medratio.plot(norm='log', vmin=0.1, vmax=10)
>>> plot.set_ylim(40, 4096)
>>> plot.add_colorbar(label='Amplitude relative to median')
>>> plot.show()
(Source code, png)