Commit 06cd1b2c authored by Brandon Piotrzkowski's avatar Brandon Piotrzkowski
Browse files

Modify coincidence far call

parent bb0179d6
......@@ -14,6 +14,9 @@ Changelog
- Update lalsuite to lalsuite==6.62.1.dev20191130 and unpin scipy.
- Change RAVEN to grab sky map from superevent. Block joint FAR calculation
for SNEWS coincidences.
0.9.0 (2019-11-23)
------------------
......
......@@ -14,24 +14,34 @@ log = get_task_logger(__name__)
@app.task(shared=False)
def calculate_coincidence_far(superevent_id, exttrig_id, preferred_id, group):
def calculate_coincidence_far(superevent, exttrig, group):
"""Compute temporal coincidence FAR for external trigger and superevent
coincidence by calling ligo.raven.search.calc_signif_gracedb.
Parameters
----------
gracedb_id: str
ID of the superevent trigger used by GraceDB
superevent: dict
superevent dictionary
exttrig: dict
external event dictionary
group: str
CBC or Burst; group of the preferred_event associated with the
gracedb_id superevent
"""
superevent_id = superevent['superevent_id']
exttrig_id = exttrig['graceid']
# Don't compute coinc FAR for SNEWS coincidences
if exttrig['pipeline'] == 'SNEWS':
return
# Try to grab superevent and external sky maps
try:
preferred_skymap = ligo_fermi_skymaps.get_preferred_skymap(
preferred_id)
se_skymap = ligo_fermi_skymaps.get_preferred_skymap(
superevent_id)
except ValueError:
preferred_skymap = None
se_skymap = None
try:
ext_skymap = gracedb.download('glg_healpix_all_bn_v00.fit',
exttrig_id)
......@@ -47,14 +57,13 @@ def calculate_coincidence_far(superevent_id, exttrig_id, preferred_id, group):
elif group == 'Burst':
tl, th = tl_burst, th_burst
ext_search = gracedb.get_search(exttrig_id)
if ext_skymap and preferred_skymap:
return calc_signif(ext_search,
if ext_skymap and se_skymap:
return calc_signif(exttrig['search'],
superevent_id, exttrig_id, tl, th,
incl_sky=True,
se_fitsfile=preferred_skymap)
se_fitsfile=se_skymap)
else:
return calc_signif(ext_search,
return calc_signif(exttrig['search'],
superevent_id, exttrig_id, tl, th,
incl_sky=False)
......@@ -175,21 +184,18 @@ def raven_pipeline(raven_search_results, gracedb_id, alert_object, gw_group):
if gracedb_id.startswith('E'):
superevent_id = result['superevent_id']
exttrig_id = gracedb_id
preferred_gwevent_id = result['preferred_event']
superevent = result
ext_event = alert_object
else:
superevent_id = gracedb_id
exttrig_id = result['graceid']
preferred_gwevent_id = alert_object['preferred_event']
superevent = alert_object
ext_event = result
canvas = (
gracedb.add_event_to_superevent.si(superevent_id, exttrig_id)
|
calculate_coincidence_far.si(superevent_id, exttrig_id,
preferred_gwevent_id, gw_group)
calculate_coincidence_far.si(superevent, ext_event, gw_group)
|
group(gracedb.create_label.si('EM_COINC', superevent_id),
gracedb.create_label.si('EM_COINC', exttrig_id))
......
......@@ -61,13 +61,14 @@ def test_raven_search(mock_raven_search, mock_se_cls, mock_exttrig_cls,
@pytest.mark.parametrize('group', ['CBC', 'Burst'])
@patch('gwcelery.tasks.gracedb.get_search', return_value='GRB')
@patch('gwcelery.tasks.raven.calc_signif')
def test_calculate_coincidence_far(
mock_calc_signif, mock_get_search, group):
raven.calculate_coincidence_far('S1234', 'E4321',
'G222', group)
mock_get_search.assert_called_once_with('E4321')
mock_calc_signif, group):
se = {'superevent_id': 'S1234'}
ext = {'graceid': 'E4321',
'pipeline': 'Fermi',
'search': 'GRB'}
raven.calculate_coincidence_far(se, ext, group)
if group == 'CBC':
tl, th = -5, 1
else:
......@@ -80,14 +81,14 @@ def test_calculate_coincidence_far(
@pytest.mark.parametrize('group', ['CBC', 'Burst']) # noqa: F811
@patch('gwcelery.tasks.ligo_fermi_skymaps.get_preferred_skymap',
return_value='bayestar.fits.gz')
@patch('gwcelery.tasks.gracedb.get_search', return_value='GRB')
@patch('gwcelery.tasks.raven.calc_signif')
def test_calculate_spacetime_coincidence_far(
mock_calc_signif, mock_get_search, mock_get_preferred_skymap,
group):
raven.calculate_coincidence_far(
'S1234', 'E4321', 'G222', group)
mock_get_search.assert_called_once_with('E4321')
mock_calc_signif, mock_get_preferred_skymap, group):
se = {'superevent_id': 'S1234'}
ext = {'graceid': 'E4321',
'pipeline': 'Fermi',
'search': 'GRB'}
raven.calculate_coincidence_far(se, ext, group)
if group == 'CBC':
tl, th = -5, 1
else:
......@@ -174,14 +175,12 @@ def test_raven_pipeline(mock_create_label,
elif graceid.startswith('E'):
result = raven.preferred_superevent(raven_search_results)[0]
label_calls.append(call('EM_COINC', result['superevent_id']))
coinc_calls.append(call(result['superevent_id'], graceid,
result['preferred_event'], group))
coinc_calls.append(call(result, alert_object, group))
label_calls.append(call('EM_COINC', graceid))
else:
for result in raven_search_results:
label_calls.append(call('EM_COINC', result['graceid']))
coinc_calls.append(call(graceid, result['graceid'],
alert_object['preferred_event'], group))
coinc_calls.append(call(alert_object, result, group))
label_calls.append(call('EM_COINC', graceid))
alert_calls = []
......
Supports Markdown
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