3 # Copyright (C) 2011 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 # A legacy program to make spin aligned banks from an existing non spinning bank; DO NOT USE; instead consider lalapp_cbc_sbank or pycbc_geom_aligned_bank
27 from optparse
import OptionParser
28 from pylal
import spawaveform
29 from glue.ligolw
import ligolw
30 from glue.ligolw
import lsctables
31 from glue.ligolw
import utils
32 from glue.ligolw.utils
import process as ligolw_process
34 def parse_command_line():
35 parser = OptionParser()
36 parser.add_option(
"--output", metavar =
"file", default =
".", help =
"Set the name of the output file")
37 parser.add_option(
"--input", metavar =
"file", default =
".", help =
"Set the name of the input file")
38 parser.add_option(
"--spin1z", action=
"append", help=
"values of spin1z to populate, give multiple times: convention body 1 is the lighter body")
39 parser.add_option(
"--spin2z", action=
"append", help=
"values of spin2z to populate, give multiple times: convention body 1 is the lighter body")
40 parser.add_option(
"--approximant", help =
"override approximant with this value")
41 parser.add_option(
"-v",
"--verbose", action =
"store_true", help =
"Be verbose.")
42 options, filenames = parser.parse_args()
44 return options, filenames
46 options, filenames = parse_command_line()
48 xmldoc=utils.load_filename(options.input,
verbose = options.
verbose)
49 sngl_inspiral_table=lsctables.table.get_table(xmldoc, lsctables.SnglInspiralTable.tableName)
50 process_params_table = lsctables.table.get_table(xmldoc, lsctables.ProcessParamsTable.tableName)
51 tmpltbank_process_ids = lsctables.table.get_table(xmldoc, lsctables.ProcessTable.tableName).get_ids_by_program(
"tmpltbank")
52 procrow = ligolw_process.register_to_xmldoc(xmldoc,
"gstlal_add_spins_to_bank", options.__dict__)
54 if options.approximant is not None:
55 for row in process_params_table:
56 if row.process_id in tmpltbank_process_ids and row.param==
'--approximant':
57 row.value= options.approximant
58 row.process_id == procrow.process_id
61 for row in sngl_inspiral_table:
62 for spin1z in options.spin1z:
63 for spin2z in options.spin2z:
64 #FIXME populate the ending frequency
65 # swap masses to obey mass 1 is the lighter body
66 if row.mass1 > row.mass2:
67 row.mass1, row.mass2 = row.mass2, row.mass1
68 row.spin1z=float(spin1z)
69 row.spin2z=float(spin2z)
70 new_rows.append(copy.deepcopy(row))
72 sngl_inspiral_table[:] = new_rows
74 utils.write_filename(xmldoc, options.output,
verbose = options.
verbose)