.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/frequencyseries/percentiles.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_percentiles.py: .. sectionauthor:: Duncan Macleod .. currentmodule:: gwpy.timeseries Plotting an averaged ASD with percentiles. ########################################## As we have seen in :ref:`sphinx_glr_examples_frequency_hoff`, the Amplitude Spectral Density (ASD) is a key indicator of frequency-domain sensitivity for a gravitational-wave detector. However, the ASD doesn't allow you to see how much the sensitivity varies over time. One tool for that is the :ref:`spectrogram `, while another is simply to show percentiles of a number of ASD measurements. In this example we calculate the median ASD over 2048-seconds surrounding the GW178017 event, and also the 5th and 95th percentiles of the ASD, and plot them on a single figure. .. GENERATED FROM PYTHON SOURCE LINES 41-44 Data access ----------- First, as always, we get the data using :meth:`TimeSeries.fetch_open_data`: .. GENERATED FROM PYTHON SOURCE LINES 44-48 .. code-block:: Python from gwpy.timeseries import TimeSeries hoft = TimeSeries.fetch_open_data("H1", 1187007040, 1187009088) .. GENERATED FROM PYTHON SOURCE LINES 49-54 Calculate spectrogram --------------------- Next we calculate a :class:`~gwpy.spectrogram.Spectrogram` by calculating a number of ASDs, using the :meth:`~gwpy.timeseries.TimeSeries.spectrogram2` method: .. GENERATED FROM PYTHON SOURCE LINES 54-57 .. code-block:: Python sg = hoft.spectrogram2(fftlength=4, overlap=2, window="hann") ** (1 / 2.) .. GENERATED FROM PYTHON SOURCE LINES 58-59 From this we can trivially extract the median, 5th and 95th percentiles: .. GENERATED FROM PYTHON SOURCE LINES 59-64 .. code-block:: Python median = sg.percentile(50) low = sg.percentile(5) high = sg.percentile(95) .. GENERATED FROM PYTHON SOURCE LINES 65-69 Visualisation ------------- Finally, we can make plot, using :meth:`~gwpy.plot.Axes.plot_mmm` to display the 5th and 95th percentiles as a shaded region around the median: .. GENERATED FROM PYTHON SOURCE LINES 69-84 .. code-block:: Python from gwpy.plot import Plot plot = Plot() ax = plot.add_subplot( xscale="log", xlim=(10, 1500), xlabel="Frequency [Hz]", yscale="log", ylim=(3e-24, 2e-20), ylabel=r"Strain noise [1/$\sqrt{\mathrm{Hz}}$]", ) ax.plot_mmm(median, low, high, color="gwpy:ligo-hanford") ax.set_title("LIGO-Hanford strain noise variation around GW170817") plot.show() .. image-sg:: /examples/frequencyseries/images/sphx_glr_percentiles_001.png :alt: LIGO-Hanford strain noise variation around GW170817 :srcset: /examples/frequencyseries/images/sphx_glr_percentiles_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 85-88 Now we can see that the ASD varies by factors of a few across most of the frequency band, with notable exceptions, e.g. around the 60-Hz power line harmonics (60 Hz, 120 Hz, 180 Hz, ...) where the noise is very stable. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.843 seconds) .. _sphx_glr_download_examples_frequencyseries_percentiles.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: percentiles.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: percentiles.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: percentiles.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_