3 # Copyright (C) 2017,2018 Heather Fong and 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.
23 parser = argparse.ArgumentParser(description =
"Add mass models for prior weighting of templates")
24 parser.add_argument(
"--output", metavar=
'name', type=str, help=
'The output file name',
default =
"inspiral_mass_model.h5")
25 parser.add_argument(
"modelfiles", nargs =
"+")
26 options = parser.parse_args()
31 for fname in options.modelfiles:
32 f = h5py.File(fname,
"r")
33 if f[
"SNR"].shape[0] > SNRshape[0]:
34 SNRshape = f[
"SNR"].shape
35 if f[
"coefficients"].shape[2] > coeffshape[2]:
36 coeffshape = f[
"coefficients"].shape
39 coefficients = numpy.zeros(coeffshape)
40 SNR = numpy.zeros(SNRshape)
42 for fname in options.modelfiles:
43 f = h5py.File(fname,
"r")
45 coefficients[:,:,:f[
"coefficients"].shape[2]] += f[
"coefficients"]
48 f = h5py.File(options.output,
"w")
49 f.create_dataset(
"SNR", data = SNR)
50 f.create_dataset(
"coefficients", data = coefficients)