.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/frequencyseries/hoff.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_hoff.py: .. sectionauthor:: Duncan Macleod .. currentmodule:: gwpy.frequencyseries Calculate and plot a `FrequencySeries` ###################################### One of the principal means of estimating the sensitivity of a gravitational-wave detector is to esimate it's amplitude spectral density (ASD). The ASD is a measurement of how a signal's amplitude varies across different frequencies. The ASD can be estimated directly from a `TimeSeries` using the :meth:`~gwpy.timeseries.TimeSeries.asd` method. .. GENERATED FROM PYTHON SOURCE LINES 37-42 Data access ----------- For this example we choose to estimate the ASD around |GW200115|_, one of the first observations of a neutron star-black hole binary. We can use the |gwosc-mod| Python package to query for the relevant GPS time: .. GENERATED FROM PYTHON SOURCE LINES 42-46 .. code-block:: Python from gwosc.datasets import event_gps gps = event_gps("GW200115") .. GENERATED FROM PYTHON SOURCE LINES 47-51 In order to generate a `FrequencySeries` we need to import the `~gwpy.timeseries.TimeSeries` and use :meth:`~gwpy.timeseries.TimeSeries.fetch_open_data` to download the strain records: .. GENERATED FROM PYTHON SOURCE LINES 51-56 .. code-block:: Python from gwpy.timeseries import TimeSeries lho = TimeSeries.fetch_open_data("H1", gps - 16, gps + 16) llo = TimeSeries.fetch_open_data("L1", gps - 16, gps + 16) .. GENERATED FROM PYTHON SOURCE LINES 57-62 Calculate the ASDs ------------------ We can then call the :meth:`~gwpy.timeseries.TimeSeries.asd` method to calculated the amplitude spectral density for each `~gwpy.timeseries.TimeSeries`: .. GENERATED FROM PYTHON SOURCE LINES 62-66 .. code-block:: Python lhoasd = lho.asd(4, 2) lloasd = llo.asd(4, 2) .. GENERATED FROM PYTHON SOURCE LINES 67-71 Visualisation ------------- We can then :meth:`~FrequencySeries.plot` the spectra using the 'standard' colour scheme: .. GENERATED FROM PYTHON SOURCE LINES 71-80 .. code-block:: Python plot = lhoasd.plot(label="LIGO-Hanford", color="gwpy:ligo-hanford") ax = plot.gca() ax.plot(lloasd, label="LIGO-Livingston", color="gwpy:ligo-livingston") ax.set_xlim(16, 1600) ax.set_ylim(1e-24, 1e-21) ax.set_ylabel(r"Strain ASD [1/$\sqrt{\mathrm{Hz}}]$") ax.legend(frameon=False, bbox_to_anchor=(1., 1.), loc="lower right", ncol=2) plot.show() .. image-sg:: /examples/frequencyseries/images/sphx_glr_hoff_001.png :alt: hoff :srcset: /examples/frequencyseries/images/sphx_glr_hoff_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.609 seconds) .. _sphx_glr_download_examples_frequencyseries_hoff.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: hoff.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: hoff.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: hoff.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_