.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/timeseries/qscan.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_timeseries_qscan.py: .. sectionauthor:: Duncan Macleod .. currentmodule:: gwpy.timeseries Generate the Q-transform of a `TimeSeries` ########################################## One of the most useful tools for filtering and visualising short-duration features in a `TimeSeries` is the `Q-transform `_. This is regularly used by the Detector Characterization working groups of the LIGO Scientific Collaboration and the Virgo Collaboration to produce high-resolution time-frequency maps of transient noise (glitches) and potential gravitational-wave signals. This algorithm was used to visualise the first ever gravitational-wave detection GW150914, so we can reproduce `that result (bottom panel of figure 1) `_ here. .. GENERATED FROM PYTHON SOURCE LINES 40-42 First, we need to download the `TimeSeries` record for the H1 strain measurement from |GWOSC|_: .. GENERATED FROM PYTHON SOURCE LINES 42-46 .. code-block:: Python from gwpy.timeseries import TimeSeries data = TimeSeries.fetch_open_data("H1", 1126259446, 1126259478) .. GENERATED FROM PYTHON SOURCE LINES 47-48 Next, we generate the `~TimeSeries.q_transform` of these data: .. GENERATED FROM PYTHON SOURCE LINES 48-50 .. code-block:: Python qspecgram = data.q_transform(outseg=(1126259462.2, 1126259462.5)) .. GENERATED FROM PYTHON SOURCE LINES 51-57 .. note:: We can save memory by focusing on a specific window around the interesting time. The ``outseg`` keyword argument returns a `Spectrogram` that is only as long as we need it to be. Now, we can plot the resulting `~gwpy.spectrogram.Spectrogram`: .. GENERATED FROM PYTHON SOURCE LINES 57-68 .. code-block:: Python plot = qspecgram.plot(figsize=[8, 4]) ax = plot.gca() ax.set_xscale("seconds") ax.set_yscale("log") ax.set_ylim(20, 500) ax.set_ylabel("Frequency [Hz]") ax.grid(True, axis="y", which="both") ax.colorbar(cmap="viridis", label="Normalized energy") plot.show() .. image-sg:: /examples/timeseries/images/sphx_glr_qscan_001.png :alt: qscan :srcset: /examples/timeseries/images/sphx_glr_qscan_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 69-72 Here we can clearly see the trace of a compact binary coalescence, specifically a binary black hole merger! For more details on this historic result, please see |GW150914|_. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.076 seconds) .. _sphx_glr_download_examples_timeseries_qscan.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: qscan.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: qscan.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: qscan.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_