Skip to content

Instantly share code, notes, and snippets.

@duncanmmacleod
Last active April 3, 2019 12:58
Show Gist options
  • Save duncanmmacleod/dc7a289f77febe7bd20bd3e70f8b993e to your computer and use it in GitHub Desktop.
Save duncanmmacleod/dc7a289f77febe7bd20bd3e70f8b993e to your computer and use it in GitHub Desktop.
Plot the Amplitude Spectral Density of the LIGO strain output around the time of GW150914
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# The MIT License (MIT)
# Copyright (c) 2019 Duncan Macleod
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
# OR OTHER DEALINGS IN THE SOFTWARE.
"""Plot the Amplitude Spectral Density for LIGO around the time of GW150914
"""
__author__ = "Duncan Macleod <duncan.macleod@ligo.org>"
__license__ = "MIT"
from matplotlib import (pyplot, rcParams)
from gwpy.plot import Plot
from gwpy.timeseries import TimeSeries
pyplot.style.use("dark_background")
rcParams.update({
"figure.subplot.left": .15,
"figure.subplot.right": .9,
"figure.subplot.bottom": .15,
"figure.subplot.top": .9,
})
# get data
lho = TimeSeries.fetch_open_data(
"H1",
1126257414,
1126261510,
sample_rate=16384,
)
llo = TimeSeries.fetch_open_data(
"L1",
1126257414,
1126261510,
sample_rate=16384,
)
# calculate ASDs
hasd = lho.asd(8)
lasd = llo.asd(8)
# make the plot
plot = Plot()
ax = plot.gca(xscale="log", yscale="log")
ax.plot(hasd, label="LIGO-Hanford", color="gwpy:ligo-hanford")
ax.plot(lasd, label="LIGO-Livingston", color="gwpy:ligo-livingston")
ax.set_xlim(10, 2048)
ax.set_xlabel("Frequency (Hz)")
ax.set_ylim(5e-24, 3e-21)
ax.set_ylabel(r"Strain noise (1/$\sqrt{\mathrm{Hz}}$)")
ax.set_xticks([10, 100, 1000])
ax.set_xticklabels(("10", "100", "1000"))
ax.legend(
loc="lower right",
bbox_to_anchor=(1., 1.),
borderaxespad=0,
frameon=False,
)
ax.grid(False)
ax.spines["top"].set_visible(False)
ax.spines["right"].set_visible(False)
plot.save("5-hl-gw150914-asd.png", dpi=1200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment