Skip to content
Snippets Groups Projects

Plot horizon distance from ranking statistics

Merged ChiWai Chan requested to merge plot_psd_horizon into master
1 unresolved thread
Files
11
@@ -22,13 +22,8 @@
from optparse import OptionParser
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot
import numpy
from gstlal.plots import util as plotutil
from gstlal.psd import read_psd, HorizonDistance
from gstlal.plots import horizon
def parse_command_line():
@@ -44,35 +39,5 @@ def parse_command_line():
options, filenames = parse_command_line()
horizons = {}
times = {}
for f in filenames:
psds = read_psd(f, verbose=True)
for ifo, psd in psds.items():
if psd is not None:
times.setdefault(ifo, []).append(int(psd.epoch))
horizons.setdefault(ifo, []).append(HorizonDistance(10., 2048., psd.deltaF, 1.4, 1.4)(psd, 8.)[0])
pyplot.figure(figsize=(12,4))
pyplot.subplot(121)
minh, maxh = (float("inf"), 0)
mint = min([min(t) for t in times.values() if t])
for ifo in horizons:
if len(horizons[ifo]) > 0:
pyplot.semilogy((numpy.array(times[ifo]) - mint) / 1000., horizons[ifo], 'x', color = plotutil.colour_from_instruments([ifo]), label = ifo)
maxh = max(maxh, max(horizons[ifo]))
minh = min(minh, min(horizons[ifo]))
#pyplot.legend()
pyplot.xlabel('Time (ks) from GPS %d' % mint)
pyplot.ylabel('Mpc')
pyplot.grid()
pyplot.subplot(122)
binvec = numpy.linspace(minh, maxh, 25)
for ifo in horizons:
if len(horizons[ifo]) > 0:
pyplot.hist(horizons[ifo], binvec, color = plotutil.colour_from_instruments([ifo]), alpha = 0.5, label = ifo)
pyplot.legend()
pyplot.xlabel("Mpc")
pyplot.ylabel("Count")
pyplot.savefig(options.output)
horizon_distance = horizon.HorizonDistance.from_psds(filenames)
horizon_distance.savefig(options.output)
Loading