Commit 22a3bd6f authored by Min-A Cho's avatar Min-A Cho
Browse files

Merge branch 'fix_coincidence_search' into 'master'

Allow search to specify pipelines to distinguish between SNEWS and Fermi/Swift external triggers

See merge request lscsoft/raven!17
parents d9bbfdaf ddcd9124
# Changelog
## 1.6 (unreleased)
- No changes yet.
## 1.6 (2018-09-24)
- Update ligo.raven.search query and search methods to allow pipeline
specification. Then, while searching for external triggers, we can
distinguish between SNEWS and Fermi/Swift triggers.
## 1.5 (2018-08-14)
......
......@@ -54,7 +54,7 @@ def Cacc(rho_sky):
# Functions implementing the actual coincidence search. #
#########################################################
def query(event_type, gpstime, tl, th, gracedb=None, group=None):
def query(event_type, gpstime, tl, th, gracedb=None, group=None, pipelines=None):
""" Query for coincident events of type event_type occurring within a window
of [tl, th] seconds around gpstime """
......@@ -74,7 +74,15 @@ def query(event_type, gpstime, tl, th, gracedb=None, group=None):
arg = '{0} {1} .. {2}'.format(event_type, start, end)
# Return list of graceids of coincident events.
try:
return list(gracedb.events(arg))
results = list(gracedb.events(arg))
if pipelines:
for event in results:
event_pipeline = event['pipeline']
if event_pipeline not in pipelines:
results.remove(event)
return results
else:
return results
except:
sys.stderr.write( "ERROR: Problem accessing GraCEDb while \
calling gracedb.events()" )
......@@ -101,7 +109,7 @@ def query(event_type, gpstime, tl, th, gracedb=None, group=None):
sys.exit(1)
def search(event, tl, th, gracedb=None, group=None):
def search(event, tl, th, gracedb=None, group=None, pipelines=None):
""" Perform a search for neighbors coincident in time within
a window [tl, th] seconds around an event """
......@@ -116,13 +124,16 @@ def search(event, tl, th, gracedb=None, group=None):
# Grab any and all neighboring events. Filter results depending on the group if specified.
neighbors = query(groups[event.neighbor_type], event.gpstime, tl, th,
gracedb=gracedb, group=group)
gracedb=gracedb, group=group, pipelines=pipelines)
# If no neighbors, report a null result.
if not neighbors:
if group:
message = "RAVEN: No %s %s candidates in window [%+d, %+d] \
seconds" % (types[event.neighbor_type], group, tl, th)
elif pipelines:
message = "RAVEN: No %s %s candidates in window [%+d, %+d] \
seconds" % (types[event.neighbor_type], pipelines, tl, th)
else:
message = "RAVEN: No %s candidates in window [%+d, %+d] \
seconds" % (types[event.neighbor_type], tl, th)
......@@ -142,7 +153,7 @@ def search(event, tl, th, gracedb=None, group=None):
gracedb_url = re.findall('(.*)api/', gracedb.service_url)[0]
if group:
message1 = "RAVEN: {0} {1} candidate found: \
<a href='{1}{2}".format(types[event.neighbor_type],
<a href='{2}{3}".format(types[event.neighbor_type],
group, gracedb_url, link1)
else:
message1 = "RAVEN: {0} candidate found: \
......@@ -156,8 +167,12 @@ def search(event, tl, th, gracedb=None, group=None):
except:
pass
message2 = "RAVEN: {0} event <a href='{1}{2}".format(
types[event.graceid[0]], gracedb_url, link2)
if pipelines:
message2 = "RAVEN: {0} {1} event <a href='{2}{3}".format(
types[event.graceid[0]], pipelines, gracedb_url, link2)
else:
message2 = "RAVEN: {0} event <a href='{1}{2}".format(
types[event.graceid[0]], gracedb_url, link2)
message2 += "%s'>%s</a> within window [%+d, %+d] seconds" % (
event.graceid, event.graceid, tl, th)
gracedb.writeLog(gid, message2, tagname="ext_coinc")
......
......@@ -27,7 +27,7 @@ from setuptools import setup, find_packages
setup(
name='ligo-raven',
version='1.5',
version='1.6',
url='http://gracedb.ligo.org',
author='Alex Urban',
author_email='alexander.urban@ligo.org',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment