Skip to content
Snippets Groups Projects
Commit a369b614 authored by ChiWai Chan's avatar ChiWai Chan
Browse files

gstlal_plot_psd_horizon: update this program to use the plots.horizon module to avoid duplication.

parent d287253a
No related branches found
No related tags found
1 merge request!114Plot horizon distance from ranking statistics
This commit is part of merge request !114. Comments created here will be created in the context of that merge request.
...@@ -22,13 +22,8 @@ ...@@ -22,13 +22,8 @@
from optparse import OptionParser from optparse import OptionParser
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot
import numpy
from gstlal.plots import util as plotutil from gstlal.plots import horizon
from gstlal.psd import read_psd, HorizonDistance
def parse_command_line(): def parse_command_line():
...@@ -44,35 +39,5 @@ def parse_command_line(): ...@@ -44,35 +39,5 @@ def parse_command_line():
options, filenames = parse_command_line() options, filenames = parse_command_line()
horizon_distance = horizon.HorizonDistance.from_psds(filenames)
horizons = {} horizon_distance.savefig(options.output)
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment