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)
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() plot.show()
def test_inspiral_range(psd): """Test for :func:`gwpy.astro.inspiral_range_psd` """ r = astro.inspiral_range(psd, fmin=40) utils.assert_quantity_almost_equal(r, TEST_RESULTS['inspiral_range'])
def test_inspiral_range(self): r = astro.inspiral_range(self.psd, fmin=40) self.assertEqual(r.unit, units.Mpc) self.assertAlmostEqual(r.value, 19.63704209223392) return r
t_unit = 'seconds' sec_per_t_unit = 1.0 for i in range(0, num_points): times[i] = times[i] / sec_per_t_unit # Collect range data in arrays ranges = [] medians = [] stds = [] for i in range(0, len(channel_list)): ranges.append([]) for j in range(0, num_points): data = TimeSeries.read(frame_cache_list[i], "%s:%s" % (ifo, channel_list[i]), start = gps_start_time + j * stride, end = gps_start_time + j * stride + integration_time) PSD = data.psd(8, 4, method = 'lal_median') BNS_range = float(inspiral_range(PSD, fmin=10).value) ranges[i].append(BNS_range) medians.append(numpy.median(ranges[i])) stds.append(numpy.std(ranges[i])) # Make plots colors = ["blue", "green", "limegreen", "red", "yellow", "purple", "pink"] # Hopefully the user will not want to plot more than 7 datasets on one plot. plt.figure(figsize = (12, 8)) for i in range(0, len(channel_list)): plt.gcf().subplots_adjust(bottom=0.15) plt.plot(times, ranges[i], colors[i % 6], linewidth = 1.5, label = r'%s:%s [median = %0.1f Mpc, $\sigma$ = %0.1f Mpc]' % (ifo, channel_list[i].replace('_', '\_'), medians[i], stds[i])) if options.make_title: plt.title("%s binary neutron star inspiral range" % ifo) plt.ylabel('Angle-averaged range [Mpc]') plt.xlabel('Time [%s] from %s UTC' % (t_unit, time.strftime("%b %d %Y %H:%M:%S", time.gmtime(gps_start_time + 315964782)))) plt.ylim(range_min, range_max) plt.grid(True)
def test_inspiral_range(psd): """Test for :func:`gwpy.astro.inspiral_range_psd` """ r = astro.inspiral_range(psd, fmin=40) utils.assert_quantity_almost_equal(r, TEST_RESULTS['inspiral_range'])