def distance(a: TimeSeries, b: TimeSeries): am = a.mean() bm = b.mean() delta = bm - am ad = a + delta dist = np.zeros(len(a)) xf = 1000000 xfi = 1 / xf ad = a.copy() bd = b.copy() thresh = 10000000 for i in range(len(a)): dist[i] = 1 / np.linalg.norm(a[i] - b[i]) if dist[i] < -1E-6: ad[i] = am bd[i] = bm return dist, ad, bd
# and then calculating the PSD spectrogram: h1spec = h1.spectrogram(30, fftlength=4) l1spec = l1.spectrogram(30, fftlength=4) # To calculate the inspiral range variation, we need to create a # :class:`~gwpy.timeseries.TimeSeries` in which to store the values, then # loop over each PSD bin in the spectrogram, calculating the # :func:`gwpy.astro.inspiral_range` for each one: import numpy from gwpy.astro import inspiral_range h1range = TimeSeries(numpy.zeros(len(h1spec)), dt=h1spec.dt, t0=h1spec.t0, unit='Mpc') l1range = h1range.copy() for i in range(h1range.size): h1range[i] = inspiral_range(h1spec[i], fmin=10) l1range[i] = inspiral_range(l1spec[i], fmin=10) # We can now easily plot the timeseries to see the variation in LIGO # sensitivity over the hour or so including GW150914: plot = h1range.plot(label='LIGO-Hanford', color='gwpy:ligo-hanford', figsize=(12, 5)) ax = plot.gca() ax.plot(l1range, label='LIGO-Livingston', color='gwpy:ligo-livingston') ax.set_ylabel('Angle-averaged sensitive distance [Mpc]') ax.set_title('LIGO sensitivity to BNS around GW150914') ax.set_epoch(1126259462) # <- set 0 on plot to GW150914 ax.legend()