.. _gwpy-example-frequencyseries-hoff: .. sectionauthor:: Duncan Macleod .. currentmodule:: gwpy.frequencyseries Calculating and plotting a `FrequencySeries` ############################################ The LIGO Laboratory has publicly released the strain data around the time of the GW150914 gravitational-wave detection; we can use these to calculate and display the spectral sensitivity of each of the detectors at that time. 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: .. plot:: :context: reset :nofigs: :include-source: from gwpy.timeseries import TimeSeries lho = TimeSeries.fetch_open_data('H1', 1126259446, 1126259478) llo = TimeSeries.fetch_open_data('L1', 1126259446, 1126259478) We can then call the :meth:`~gwpy.timeseries.TimeSeries.asd` method to calculated the amplitude spectral density for each `~gwpy.timeseries.TimeSeries`: .. plot:: :context: :nofigs: :include-source: lhoasd = lho.asd(4, 2) lloasd = llo.asd(4, 2) We can then :meth:`~FrequencySeries.plot` the spectra using the 'standard' colour scheme: .. plot:: :context: :include-source: 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(10, 2000) ax.set_ylim(5e-24, 1e-21) ax.legend(frameon=False, bbox_to_anchor=(1., 1.), loc='lower right', ncol=2) plot.show()