.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/spectrogram/ratio.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_spectrogram_ratio.py: .. sectionauthor:: Duncan Macleod .. currentmodule:: gwpy.timeseries Plotting a normalised `~gwpy.spectrogram.Spectrogram` ##################################################### The :ref:`sphx_glr_examples_spectrogram_plot.py` example showed how to generate and display a `~gwpy.spectrogram.Spectrogram` of the LIGO-Hanford strain data around the |GW150914|_ event. However, because of the shape of the LIGO sensitivity curve, picking out features in the most sensitive frequency band (a few hundred Hertz) is very hard. We can normalise our `~gwpy.spectrogram.Spectrogram` to highligh those features. .. GENERATED FROM PYTHON SOURCE LINES 39-42 Again, we import the `TimeSeries` and call :meth:`TimeSeries.fetch_open_data` the download the strain data for the LIGO-Hanford interferometer .. GENERATED FROM PYTHON SOURCE LINES 42-49 .. code-block:: Python from gwpy.timeseries import TimeSeries data = TimeSeries.fetch_open_data( "H1", "Sep 14 2015 09:45", "Sep 14 2015 09:55", ) .. GENERATED FROM PYTHON SOURCE LINES 50-53 Next, we can calculate a `~gwpy.spectrogram.Spectrogram` using the :meth:`spectrogram` method of the `TimeSeries` over a 2-second stride with a 1-second FFT and # .5-second overlap (50%): .. GENERATED FROM PYTHON SOURCE LINES 53-55 .. code-block:: Python specgram = data.spectrogram(2, fftlength=1, overlap=.5) ** (1/2.) .. GENERATED FROM PYTHON SOURCE LINES 56-58 and can normalise it against the overall median ASD by calling the :meth:`~gwpy.spectrogram.Spectrogram.ratio` method: .. GENERATED FROM PYTHON SOURCE LINES 58-61 .. code-block:: Python normalised = specgram.ratio("median") .. GENERATED FROM PYTHON SOURCE LINES 62-64 Finally, we can make a plot using the :meth:`~gwpy.spectrogram.Spectrogram.plot` method .. GENERATED FROM PYTHON SOURCE LINES 64-71 .. code-block:: Python plot = normalised.plot(norm="log", vmin=.1, vmax=10, cmap="Spectral_r") ax = plot.gca() ax.set_yscale("log") ax.set_ylim(10, 2000) ax.colorbar(label="Relative amplitude") plot.show() .. image-sg:: /examples/spectrogram/images/sphx_glr_ratio_001.png :alt: ratio :srcset: /examples/spectrogram/images/sphx_glr_ratio_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 72-77 Even with a normalised spectrogram, the resolution is such that a signal as short as that of GW150914 is impossible to see. See :ref:`sphx_glr_examples_spectrogram_spectrogram2.py` for an example that uses a high-resolution spectrogram method to zoom in around the exact time of the signal. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.752 seconds) .. _sphx_glr_download_examples_spectrogram_ratio.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ratio.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ratio.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: ratio.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_