.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/frequencyseries/coherence.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_coherence.py: .. currentmodule:: gwpy.timeseries .. sectionauthor:: Duncan Macleod Calculate the coherence between two channels ############################################ The `coherence `_ between two channels is a measure of the frequency-domain correlation between their time-series data. In LIGO, the coherence is a crucial indicator of how noise sources couple into the main differential arm-length readout. Here we use use the :meth:`TimeSeries.coherence` method to highlight coupling of motion of a beam periscope attached to the main laser table into the strain output of the LIGO-Hanford interferometer. These data are available as part of the |GWOSC_AUX_RELEASE|_. .. GENERATED FROM PYTHON SOURCE LINES 40-43 Data access ----------- First, we import the `TimeSeriesDict` .. GENERATED FROM PYTHON SOURCE LINES 43-46 .. code-block:: Python from gwpy.timeseries import TimeSeriesDict .. GENERATED FROM PYTHON SOURCE LINES 47-50 and then :meth:`~TimeSeriesDict.get` the data for the differential-arm length servo control loop error signal (``H1:LSC-DARM_IN1_DQ``) and the PSL periscope accelerometer (``H1:PEM-CS_ACC_PSL_PERISCOPE_X_DQ``): .. GENERATED FROM PYTHON SOURCE LINES 50-60 .. code-block:: Python data = TimeSeriesDict.get( ["H1:LSC-DARM_IN1_DQ", "H1:PEM-CS_ACC_PSL_PERISCOPE_X_DQ"], 1186741560, 1186742160, host="nds.gwosc.org", ) darm = data["H1:LSC-DARM_IN1_DQ"] acc = data["H1:PEM-CS_ACC_PSL_PERISCOPE_X_DQ"] .. rst-class:: sphx-glr-script-out .. code-block:: none /home/duncan.macleod/gwpy-nightly-build/conda/envs/gwpy-nightly-3.11/lib/python3.11/site-packages/igwn_auth_utils/requests.py:46: DeprecationWarning: Support for identity-based X.509 credentials for LIGO.ORG is being dropped. Calls to this utility will stop working on/around 20 May 2025. For details on this change please see https://computing.docs.ligo.org/guide/compsoft/roadmap/LVK/x509_retirement/ If you have questions about this message, or its implications, please consider opening an IGWN Computing Help Desk ticket: https://git.ligo.org/computing/helpdesk/-/issues/new return func(*args, **kwargs) .. GENERATED FROM PYTHON SOURCE LINES 61-66 Calculating coherence --------------------- We can then calculate the :meth:`~TimeSeries.coherence` of one `TimeSeries` with respect to the other, using an 2-second Fourier transform length, with a 1-second (50%) overlap: .. GENERATED FROM PYTHON SOURCE LINES 66-69 .. code-block:: Python coh = darm.coherence(acc, fftlength=2, overlap=1) .. GENERATED FROM PYTHON SOURCE LINES 70-74 Visualisation ------------- Finally, we can :meth:`~gwpy.frequencyseries.FrequencySeries.plot` the resulting data: .. GENERATED FROM PYTHON SOURCE LINES 74-84 .. code-block:: Python plot = coh.plot( xlabel="Frequency [Hz]", xscale="log", ylabel="Coherence", yscale="linear", ylim=(0, 1), ) plot.show() .. image-sg:: /examples/frequencyseries/images/sphx_glr_coherence_001.png :alt: coherence :srcset: /examples/frequencyseries/images/sphx_glr_coherence_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 85-90 We can clearly see the correlation between the periscope motion and the differential-arm length servo control loop error signal between 100 Hz and 1000 Hz. Such physical couplings can interfere, mask, or even mimic a gravitational wave signal inferred from the differential arm length motion. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 4.332 seconds) .. _sphx_glr_download_examples_frequencyseries_coherence.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: coherence.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: coherence.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: coherence.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_