Skip to content
Snippets Groups Projects
Commit a36bbc25 authored by Leo Tsukada's avatar Leo Tsukada Committed by Divya Singh
Browse files

gstlal-inspiral/bin/gstlal_inspiral_coinc_extractor : add --start-time and...

gstlal-inspiral/bin/gstlal_inspiral_coinc_extractor : add --start-time and --end-time to limit the coinc's gps time to extract
parent dea8e73e
No related branches found
No related tags found
1 merge request!612Combined online-offline ranks
......@@ -43,6 +43,8 @@ def timesliderow(connection):
parser = OptionParser()
parser.add_option("--far-thresh", default=0.01, type="float", metavar="probability", help="Set the false alarm probability: default 0.01")
parser.add_option("--gps-times", metavar="GPS (comma separated)", help="Restrict times to this list. give as GPS1,GPS2,...GPSN. Assumes +- 1s")
parser.add_option("--start-time", metavar="GPS", help="Set the start gps time to query coinc events.")
parser.add_option("--end-time", metavar="GPS", help="Set the end gps time to query coinc events.")
options, filenames = parser.parse_args()
if len(filenames) != 1:
......@@ -51,18 +53,25 @@ if len(filenames) != 1:
db = sqlite3.connect(filenames[0])
if options.gps_times is None:
cids = list(db.cursor().execute('SELECT coinc_inspiral.coinc_event_id, coinc_inspiral.end_time, coinc_inspiral.ifos FROM coinc_inspiral JOIN coinc_event ON coinc_event.coinc_event_id == coinc_inspiral.coinc_event_id WHERE NOT EXISTS(SELECT * FROM time_slide WHERE time_slide.time_slide_id == coinc_event.time_slide_id AND time_slide.offset != 0) AND coinc_inspiral.combined_far <= ?', (options.far_thresh,)).fetchall())
else:
gpstime_condition = ""
if options.gps_times is not None:
gps_list = [int(t) for t in options.gps_times.split(',')]
# +1
gps_list.extend([t+1 for t in gps_list])
# -1
gps_list.extend([t-1 for t in gps_list])
print >> sys.stderr, gps_list
query = 'SELECT coinc_inspiral.coinc_event_id, coinc_inspiral.end_time, coinc_inspiral.ifos FROM coinc_inspiral JOIN coinc_event ON coinc_event.coinc_event_id == coinc_inspiral.coinc_event_id WHERE NOT EXISTS(SELECT * FROM time_slide WHERE time_slide.time_slide_id == coinc_event.time_slide_id AND time_slide.offset != 0) AND coinc_inspiral.combined_far <= ? AND coinc_inspiral.end_time IN (%s)' % (",".join(["%d" % t for t in sorted(gps_list)]),)
print >> sys.stderr, query
cids = list(db.cursor().execute(query, (options.far_thresh,)).fetchall())
print(gps_list, file=sys.stderr)
gpstime_condition += " AND coinc_inspiral.end_time IN (%s)" % (",".join(["%d" % t for t in sorted(gps_list)]),)
if options.start_time is not None:
gpstime_condition += " AND coinc_inspiral.end_time >= %s" % options.start_time
if options.end_time is not None:
gpstime_condition += " AND coinc_inspiral.end_time <= %s" % options.end_time
query = 'SELECT coinc_inspiral.coinc_event_id, coinc_inspiral.end_time, coinc_inspiral.ifos FROM coinc_inspiral JOIN coinc_event ON coinc_event.coinc_event_id == coinc_inspiral.coinc_event_id WHERE NOT EXISTS(SELECT * FROM time_slide WHERE time_slide.time_slide_id == coinc_event.time_slide_id AND time_slide.offset != 0) AND coinc_inspiral.combined_far <= ?%s' % gpstime_condition
print(query, file=sys.stderr)
cids = list(db.cursor().execute(query, (options.far_thresh,)).fetchall())
for (cid, time, ifos) in cids:
xmldocmain = ligolw.Document()
......@@ -129,4 +138,4 @@ for (cid, time, ifos) in cids:
sngl.append(fullrow)
process.set_end_time_now()
ligolw_utils.write_filename(xmldocmain, '%s-GSTLAL_AllSky-%d-0.xml.gz' % (ifos.replace(",",""), time), verbose=True)
\ No newline at end of file
ligolw_utils.write_filename(xmldocmain, '%s-GSTLAL_AllSky-%d-0.xml.gz' % (ifos.replace(",",""), time), verbose=True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment