# plot range integrand # B. Swinkels, 2018-06-25 from __future__ import division import numpy as np import matplotlib.pyplot as plt from scipy.integrate import cumtrapz import astropy.units as u from gwpy.astro import inspiral_range_psd from gwpy.time import to_gps from gwpy.frequencyseries import FrequencySeries from gwpy.timeseries import TimeSeries chan = 'Hrec_hoft_20000Hz' # start = to_gps('2018-06-06 5:00:00') start = 1213654118 dur = 400 twin = 10 # gives frequency resolutionof of 1/twin for fft # binary masses in solar masses m1 = m2 = 1.4 # m1 = m2 = 10 # m1 = m2 = 30 def read_virgo_timeseries(source, channel, gstart, gstop_or_dur): """quick and dirty function to read virgo data as timeseries. this should one day be included in gwpy""" from virgotools import getChannel with getChannel(source, channel, gstart, gstop_or_dur) as data: return TimeSeries(data.data, unit=data.unit, t0=gstart, dt=data.dt, channel=channel) meas = read_virgo_timeseries('raw', chan, start, start + dur) meas_psd = meas.psd(twin) meas_psd[meas_psd.frequencies < 8 * u.Hz] = np.inf # get nominal curves from observing scenario doc https://dcc.ligo.org/LIGO-P1200087 # mid range, 60-85 Mpc data = np.loadtxt('fig1_adv_sensitivity.txt') fnom = data[:, 0] nom_low = data[:, 2] nom_high = data[:, 3] nom_low_psd = FrequencySeries(nom_low**2, frequencies=fnom) nom_high_psd = FrequencySeries(nom_high**2, frequencies=fnom) integrand = inspiral_range_psd(meas_psd, mass1=m1, mass2=m2) integrand_low = inspiral_range_psd(nom_low_psd, mass1=m1, mass2=m2) integrand_high = inspiral_range_psd(nom_high_psd, mass1=m1, mass2=m2) # cumulutative range in Mpc**2 cum = cumtrapz(integrand.value, integrand.frequencies, initial=0) cum_low = cumtrapz(integrand_low.value, integrand_low.frequencies, initial=0) cum_high = cumtrapz(integrand_high.value, integrand_high.frequencies, initial=0) range = cum[-1]**0.5 range_low = cum_low[-1]**0.5 range_high = cum_high[-1]**0.5 fig, (ax1) = plt.subplots(1, 1, sharex=True) # , ax2) ax1.plot(integrand.frequencies, integrand.value, integrand_low.frequencies, integrand_low.value, integrand_high.frequencies, integrand_high.value) ax1.set_xlabel('Frequency [Hz]') ax1.set_ylabel(r'Integrand $\left[\mathrm{Mpc}^2 / \mathrm{Hz}\right]$') ax1.ylim = 0, 50 ax1.legend(['Measured (%.1f Mpc)' % range, 'Obs. Scen. low (%.1f Mpc)' % range_low, 'Obs. Scen. high (%.1f Mpc)' % range_high], fontsize=20) ax1.set_title(r'Range integrand for $%.1f \times %.1f M_\odot$ at gps = %d' % (m1, m2, start)) ''' # somewhat misleading cumulative plot of where we gain the Mpc**2, but plotted as Mpc ax2.plot(integrand.frequencies, cum / range, integrand_low.frequencies, cum_low / range_low, integrand_high.frequencies, cum_high / range_high) ax2.set_ylabel('Cumulative range (Mpc)') ax2.ylim = 0, 65 ''' plt.xlim((0, 400)) plt.show()