3 # Copyright (C) 2012 Chad Hanna
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13 # Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 ### Plot the horizon distance as a function of time from PSDs computed from
21 ### gstlal_reference_psd
27 from matplotlib import pyplot
31 from glue.ligolw import utils as ligolw_utils
32 from gstlal import plotutil
33 from gstlal import reference_psd
36 print "USAGE gstlal_plot_psd output_name psd_file1 psd_file2 ..."
42 for f in sys.argv[2:]:
43 psds = lal.series.read_psd_xmldoc(ligolw_utils.load_filename(f, verbose = True, contenthandler = lal.series.PSDContentHandler))
44 for ifo, psd in psds.items():
46 times.setdefault(ifo, []).append(int(psd.epoch))
47 horizons.setdefault(ifo, []).append(reference_psd.HorizonDistance(10., 2048., psd.deltaF, 1.4, 1.4)(psd, 8.)[0])
49 pyplot.figure(figsize=(12,4))
51 minh, maxh = (float("inf"), 0)
52 mint = min([min(t) for t in times.values() if t])
54 if len(horizons[ifo]) > 0:
55 pyplot.semilogy((numpy.array(times[ifo]) - mint) / 1000., horizons[ifo], 'x', color = plotutil.colour_from_instruments([ifo]), label = ifo)
56 maxh = max(maxh, max(horizons[ifo]))
57 minh = min(minh, min(horizons[ifo]))
59 pyplot.xlabel('Time (ks) from GPS %d' % mint)
63 binvec = numpy.linspace(minh, maxh, 25)
65 if len(horizons[ifo]) > 0:
66 pyplot.hist(horizons[ifo], binvec, color = plotutil.colour_from_instruments([ifo]), alpha = 0.5, label = ifo)
69 pyplot.ylabel("Count")
70 pyplot.savefig(outname)