.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/frequencyseries/variance.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_frequencyseries_variance.py: .. sectionauthor:: Duncan Macleod .. currentmodule:: gwpy.timeseries Generating a `SpectralVariance` histogram ######################################### The most common visualisation of the spectral content of a data series is via the power or amplitude spectral density calculations (PSD or ASD). However, these typically involve averaging of the data over a period, which can wash out transient noise (as is often desired). The `SpectralVariance` histogram provide by `gwpy.frequencyseries` allows us to look at the spectral sensitivity in a different manner, displaying which frequencies sit at which amplitude *most* of the time, but also highlighting excursions from normal behaviour. .. GENERATED FROM PYTHON SOURCE LINES 38-40 To demonstate this, we can load some data from the LIGO Livingston interferometer around the time of the GW151226 gravitational wave detection: .. GENERATED FROM PYTHON SOURCE LINES 40-44 .. code-block:: Python from gwpy.timeseries import TimeSeries llo = TimeSeries.fetch_open_data("L1", 1135136228, 1135140324) .. GENERATED FROM PYTHON SOURCE LINES 45-49 We can then call the :meth:`~gwpy.timeseries.TimeSeries.spectral_variance` method of the ``llo`` `~gwpy.timeseries.TimeSeries` by calculating an ASD every 5 seconds and counting the amount of time each frequency bin spends at each ASD value: .. GENERATED FROM PYTHON SOURCE LINES 49-60 .. code-block:: Python variance = llo.spectral_variance( 5, fftlength=2, overlap=1, log=True, low=1e-24, high=1e-19, nbins=100, ) .. GENERATED FROM PYTHON SOURCE LINES 61-62 We can then :meth:`~SpectralVariance.plot` the `SpectralVariance` .. GENERATED FROM PYTHON SOURCE LINES 62-73 .. code-block:: Python plot = variance.plot(yscale="log", norm="log", vmin=.5, cmap="plasma") ax = plot.gca() ax.grid() ax.set_xlim(20, 1500) ax.set_ylim(1e-24, 1e-20) ax.set_xlabel("Frequency [Hz]") ax.set_ylabel(r"[strain/$\sqrt{\mathrm{Hz}}$]") ax.set_title("LIGO-Livingston sensitivity variance") plot.show() .. image-sg:: /examples/frequencyseries/images/sphx_glr_variance_001.png :alt: LIGO-Livingston sensitivity variance :srcset: /examples/frequencyseries/images/sphx_glr_variance_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 74-77 From this we see that in general the sensitivity varies a few parts in 10:sup:`-23`, while many of the lines (narrow-band peaks in the spectrum) are much more stationary. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.735 seconds) .. _sphx_glr_download_examples_frequencyseries_variance.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: variance.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: variance.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: variance.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_