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.
19 ### A program to plot the contents of a gstlal_svd_bank file by reconstructing the waveforms
25 from gstlal
import svd_bank
30 form = cgi.FieldStorage()
34 from matplotlib
import pyplot
36 from ligo.lw
import lsctables
38 print(
'Expires: Mon, 26 Jul 1997 05:00:00 GMT', file=sys.stdout)
39 print('Content-type: text/html\r\n', file=sys.stdout)
44 <meta http-equiv="Pragma" content="no-cache">
45 <meta http-equiv="Expires" content="-1">
46 <meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
48 <body bgcolor=
#E0E0E0>
53 <font size=10>SVD BANK</font><br>
57 for bank in svd_bank.read_banks(form.getlist("url
")[0], svd_bank.DefaultContentHandler):
59 # get the template number
60 tmps = bank.bank_fragments[0].mix_matrix.shape[1] / 2
61 row = bank.sngl_inspiral_table
64 mc, s1z, s2z = row[n].mchirp, row[n].spin1z, row[n].spin2z
66 pyplot.figure(figsize=(18,6))
71 for frag in bank.bank_fragments:
73 s = frag.singular_values
74 u = frag.orthogonal_template_bank
76 t = numpy.linspace(-frag.end, -frag.start, h.shape[1])
77 pyplot.plot(t, h[2 * n,:] * frag.rate**.5)
78 pyplot.plot(t, h[2 * n + 1,:] * frag.rate**.5)
79 maxrate = max(maxrate, frag.rate)
80 mint = min(t[0], mint)
81 pyplot.xlabel('time (s) mc:%.2f s1z:%.2f s2z:%.2f' % (mc, s1z, s2z))
82 #pyplot.xlim([-.25, 0])
85 pyplot.xlabel('samples')
86 l = len(bank.autocorrelation_bank[n,:])
87 ts = l / float(maxrate)
88 t = numpy.linspace(-ts, 0, l)
89 pyplot.plot(numpy.real(bank.autocorrelation_bank[n,:]))
90 pyplot.plot(numpy.imag(bank.autocorrelation_bank[n,:]))
91 pyplot.savefig(sys.stdout, format="svg
")
95 print("</body></html>
")