.. _gwpy-example-spectrogram-spectrogram2: .. sectionauthor:: Duncan Macleod .. currentmodule:: gwpy.timeseries Plotting an over-dense, short-duration `Spectrogram` #################################################### The normal `~TimeSeries.spectrogram` method uses non-overlapping intervals to calculate discrete PSDs for each stride. This is fine for long-duration data, but give poor resolution when studying short-duration phenomena. The `~TimeSeries.spectrogram2` method allows for highly-overlapping FFT calculations to over-sample the frequency content of the input `TimeSeries` to produce a much more feature-rich output. To demonstrate this, we can download some data associated with the gravitational-wave event GW510914: .. plot:: :nofigs: :include-source: :context: reset from gwpy.timeseries import TimeSeries lho = TimeSeries.fetch_open_data('H1', 1126259458, 1126259467, verbose=True) and can :meth:`~TimeSeries.highpass` and :meth:`~TimeSeries.whiten` the remove low-frequency noise and try and enhance low-amplitude signals across the middle of the frequency band: .. plot:: :nofigs: :include-source: :context: hp = lho.highpass(20) white = hp.whiten(4, 2).crop(1126259460, 1126259465) .. note:: We chose to :meth:`~TimeSeries.crop` out the leading and trailing 2 seconds of the the whitened data series here to remove any filtering artefacts that may have been introduced. Now we can call the `~TimeSeries.spectrogram2` method of `gwdata` to calculate our over-dense `~gwpy.spectrogram.Spectrogram`, using a 1/16-second FFT length and high overlap: .. plot:: :nofigs: :include-source: :context: specgram = white.spectrogram2(fftlength=1/16., overlap=15/256.) Finally, we make a plot: .. plot:: :include-source: :context: plot = specgram.plot(norm='log', cmap='viridis') ax = plot.gca() ax.set_ylim(0, 500) ax.set_title('LIGO-Hanford strain data around GW150914') ax.set_epoch(1126259462.427) ax.set_xlim(1126259462.427-.5, 1126259462.427+.5) plot.show() Here we can see the trace of a high-mass binary black hole system, referred to as GW150914. For more details on this signal, please see `Abbott et al. (2016) `_ (the joint LSC-Virgo publication announcing this detection).