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.
22 from matplotlib
import pyplot
24 from glue.ligolw
import ligolw
25 from glue.ligolw
import array
26 from glue.ligolw
import param
27 array.use_in(ligolw.LIGOLWContentHandler)
28 param.use_in(ligolw.LIGOLWContentHandler)
29 from glue.ligolw
import utils
30 from pylal
import series as lalseries
31 from gstlal
import reference_psd
34 # A program to plot reference psds; see gstlal_plot_psd for more info
36 # A program to plot a psd such as one generated by gstlal_reference_psd
40 # gstlal_plot_psd OUTPUT-NAME PSD-FILE-1 PSD-FILE-2
44 # gstlal_plot_psd psd.png psd.xml.gz
48 print
"USAGE gstlal_plot_psd OUTPUT-NAME PSD-FILE-1 PSD-FILE-2 ..."
55 for fname in sys.argv[2:]:
56 psds = lalseries.read_psd_xmldoc(utils.load_filename(fname, verbose = True, contenthandler = ligolw.LIGOLWContentHandler))
57 for k,v in psds.items():
58 # compute horizon up to 90% of nyquist to avoid roll off
59 h = reference_psd.horizon_distance(v, 1.4, 1.4, 8, 10, len(v.data) * v.deltaF * 0.90)
60 if len(sys.argv[2:]) > 1:
64 minpsd.append(min(v.data))
65 pyplot.loglog(v.deltaF * numpy.arange(len(v.data)), v.data, label =
'%s %s: %0.f Mpc' % (flabel, k, h), alpha=0.75)
66 pyplot.xlabel(
'Frequency (Hz)')
67 pyplot.ylabel(
'Strain^2/Hz')
70 pyplot.ylim([min(minpsd), min(minpsd)*1e10])
71 pyplot.savefig(outname)