gstlal-inspiral  1.9.3
 All Classes Namespaces Files Functions
gstlal_inspiral_create_p_of_ifos_given_horizon_dag
1 #!/usr/bin/env python3
2 #
3 # Copyright (C) 2019 Leo Tsukdda
4 #
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.
9 #
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.
14 #
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.
18 
19 import os
20 from gstlal import dagparts
21 from gstlal.stats import inspiral_extrinsics, inspiral_lr
22 import argparse
23 
24 parser = argparse.ArgumentParser(description = 'generate a dt dphi covariance matrix and tree data to replace share/inspiral_dtdphi_pdf.h5')
25 parser.add_argument('--snr-thresh', type=float, default = inspiral_lr.LnLRDensity.snr_min, help = 'set the snr minimum to define found')
26 # parser.add_argument('--output-file', default = 'p_of_instruments_given_H_d.h5', help = 'set the output hdf5 file. Default extparams.h5')
27 parser.add_argument('--instruments', type=str, help='add instruments. Separate tham with comma, does not have to be alphabetical.', required = True)
28 args = parser.parse_args()
29 
30 instruments = "".join(sorted(args.instruments.split(",")))
31 
32 try:
33  os.mkdir("logs")
34 except:
35  pass
36 dag = dagparts.DAG("p_of_I_%s" % instruments)
37 
38 margJob = dagparts.DAGJob("gstlal_inspiral_create_p_of_ifos_given_horizon", condor_commands = {"request_memory":"4GB", "want_graceful_removal":"True", "kill_sig":"15", "accounting_group":"ligo.prod.o3.cbc.uber.gstlaloffline"})
39 addJob = dagparts.DAGJob("gstlal_inspiral_add_p_of_ifos_given_horizon", condor_commands = {"request_memory":"4GB", "want_graceful_removal":"True", "kill_sig":"15", "accounting_group":"ligo.prod.o3.cbc.uber.gstlaloffline"})
40 
41 
42 num = 41
43 margnodes = []
44 for start in range(0, 41**(len(instruments) / 2 - 1), num):
45  stop = start + num
46  margnodes.append(dagparts.DAGNode(margJob, dag, parent_nodes = [], opts = {"start":str(start), "stop":str(stop), "instruments": args.instruments}, output_files = {"output-file":"%s/%s_p_of_instruments_given_H_d_%d_%d.h5" % (margJob.output_path, "".join(instruments), start, stop)}))
47 
48 addJob_input = []
49 addJob_input.extend([n.output_files["output-file"] for n in margnodes])
50 addnode = dagparts.DAGNode(addJob, dag, parent_nodes = margnodes, opts = {"": args.instruments}, input_files = {"": addJob_input})
51 
52 dag.write_sub_files()
53 dag.write_dag()
54 dag.write_script()
55 dag.write_cache()
56