Skip to content
Snippets Groups Projects
Commit 6157a88f authored by Cody Messick's avatar Cody Messick
Browse files

Fix unit tests, add lvalert event creation example

parent 19ffe6ae
No related branches found
No related tags found
No related merge requests found
{
"uid": "M394156",
"alert_type": "new",
"data": {
"submitter": "emfollow",
"created": "2022-06-10 19:28:01 UTC",
"group": "CBC",
"graceid": "M394156",
"pipeline": "gstlal",
"gpstime": 1338924113.077977,
"reporting_latency": 386.609921,
"instruments": "H1,L1",
"nevents": 2,
"offline": false,
"search": "MDC",
"far": 9.110699364861297e-14,
"far_is_upper_limit": false,
"likelihood": 48.88470950641089,
"labels": [],
"extra_attributes": {
"CoincInspiral": {
"ifos": "H1,L1",
"end_time": 1338924113,
"end_time_ns": 77976986,
"mass": 3.08060097694397,
"mchirp": 1.340165257453918,
"minimum_duration": null,
"snr": 15.1563299467438,
"false_alarm_rate": 2.528806224914281e-07,
"combined_far": 9.110699364861297e-14
},
"SingleInspiral": [
{
"spin1z": 0.0,
"tau4": 0.086826026,
"alpha4": 0.0,
"kappa": 0.0,
"search": "tmpltbank",
"tau2": 3.228421,
"alpha5": 0.0,
"chisq_dof": 1,
"spin2x": 0.0,
"end_time": 1338924113,
"ttotal": 75.860817,
"psi0": 1497321.0,
"bank_chisq_dof": 0,
"spin1x": 0.0,
"cont_chisq": 0.0,
"sigmasq": 5690127.794891652,
"Gamma9": 0.0,
"alpha3": 0.0,
"Gamma5": 350.55511,
"end_time_gmst": 51644.80787236235,
"spin2y": 0.0,
"alpha": 0.0,
"event_duration": 0.0,
"template_duration": 75.86827910135217,
"end_time_ns": 74495314,
"cont_chisq_dof": 0,
"eff_distance": 262.37006,
"eta": 0.24976879,
"bank_chisq": 0.0,
"psi3": -3587.729,
"Gamma3": 155.69308,
"alpha1": 0.0,
"Gamma0": 246044.5,
"tau5": 0.0,
"mchirp": 1.3401653,
"mtotal": 3.080601,
"impulse_time": 0,
"coa_phase": 0.17532051,
"f_final": 2047.0,
"Gamma4": -217.3298,
"ifo": "L1",
"tau0": 74.326508,
"spin2z": 0.0,
"Gamma8": 0.0,
"mass2": 1.493459,
"Gamma1": 16.0,
"snr": 9.0917339,
"amplitude": 0.0,
"Gamma6": 0.0,
"spin1y": 0.0,
"beta": 0.0,
"tau3": 1.780937,
"alpha2": 0.0,
"impulse_time_ns": 0,
"mass1": 1.587142,
"chisq": 1.296196,
"channel": "GAUSSIAN_PLUS_INJECTIONS",
"chi": 0.0,
"rsqveto_duration": 0.0,
"Gamma2": 6874.4478,
"alpha6": 0.0,
"Gamma7": 0.0
},
{
"spin1z": 0.0,
"tau4": 0.086826026,
"alpha4": 0.0,
"kappa": 0.0,
"search": "tmpltbank",
"tau2": 3.228421,
"alpha5": 0.0,
"chisq_dof": 1,
"spin2x": 0.0,
"end_time": 1338924113,
"ttotal": 75.860817,
"psi0": 1497321.0,
"bank_chisq_dof": 0,
"spin1x": 0.0,
"cont_chisq": 0.0,
"sigmasq": 5685633.996472067,
"Gamma9": 0.0,
"alpha3": 0.0,
"Gamma5": 350.55511,
"end_time_gmst": 51644.80787261624,
"spin2y": 0.0,
"alpha": 0.0,
"event_duration": 0.0,
"template_duration": 75.86827910135217,
"end_time_ns": 77976986,
"cont_chisq_dof": 0,
"eff_distance": 196.6301,
"eta": 0.24976879,
"bank_chisq": 0.0,
"psi3": -3587.729,
"Gamma3": 155.69308,
"alpha1": 0.0,
"Gamma0": 246044.5,
"tau5": 0.0,
"mchirp": 1.3401653,
"mtotal": 3.080601,
"impulse_time": 0,
"coa_phase": -2.3101556,
"f_final": 2047.0,
"Gamma4": -217.3298,
"ifo": "H1",
"tau0": 74.326508,
"spin2z": 0.0,
"Gamma8": 0.0,
"mass2": 1.493459,
"Gamma1": 16.0,
"snr": 12.126612,
"amplitude": 0.0,
"Gamma6": 0.0,
"spin1y": 0.0,
"beta": 0.0,
"tau3": 1.780937,
"alpha2": 0.0,
"impulse_time_ns": 0,
"mass1": 1.587142,
"chisq": 0.74225748,
"channel": "GAUSSIAN_PLUS_INJECTIONS",
"chi": 0.0,
"rsqveto_duration": 0.0,
"Gamma2": 6874.4478,
"alpha6": 0.0,
"Gamma7": 0.0
}
]
},
"superevent": null,
"superevent_neighbours": {},
"links": {
"neighbors": "https://gracedb.ligo.org/api/events/M394156/neighbors/",
"log": "https://gracedb.ligo.org/api/events/M394156/log/",
"emobservations": "https://gracedb.ligo.org/api/events/M394156/emobservation/",
"files": "https://gracedb.ligo.org/api/events/M394156/files/",
"labels": "https://gracedb.ligo.org/api/events/M394156/labels/",
"self": "https://gracedb.ligo.org/api/events/M394156",
"tags": "https://gracedb.ligo.org/api/events/M394156/tag/"
}
},
"object": {
"submitter": "emfollow",
"created": "2022-06-10 19:28:01 UTC",
"group": "CBC",
"graceid": "M394156",
"pipeline": "gstlal",
"gpstime": 1338924113.077977,
"reporting_latency": 386.609921,
"instruments": "H1,L1",
"nevents": 2,
"offline": false,
"search": "MDC",
"far": 9.110699364861297e-14,
"far_is_upper_limit": false,
"likelihood": 48.88470950641089,
"labels": [],
"extra_attributes": {
"CoincInspiral": {
"ifos": "H1,L1",
"end_time": 1338924113,
"end_time_ns": 77976986,
"mass": 3.08060097694397,
"mchirp": 1.340165257453918,
"minimum_duration": null,
"snr": 15.1563299467438,
"false_alarm_rate": 2.528806224914281e-07,
"combined_far": 9.110699364861297e-14
},
"SingleInspiral": [
{
"spin1z": 0.0,
"tau4": 0.086826026,
"alpha4": 0.0,
"kappa": 0.0,
"search": "tmpltbank",
"tau2": 3.228421,
"alpha5": 0.0,
"chisq_dof": 1,
"spin2x": 0.0,
"end_time": 1338924113,
"ttotal": 75.860817,
"psi0": 1497321.0,
"bank_chisq_dof": 0,
"spin1x": 0.0,
"cont_chisq": 0.0,
"sigmasq": 5690127.794891652,
"Gamma9": 0.0,
"alpha3": 0.0,
"Gamma5": 350.55511,
"end_time_gmst": 51644.80787236235,
"spin2y": 0.0,
"alpha": 0.0,
"event_duration": 0.0,
"template_duration": 75.86827910135217,
"end_time_ns": 74495314,
"cont_chisq_dof": 0,
"eff_distance": 262.37006,
"eta": 0.24976879,
"bank_chisq": 0.0,
"psi3": -3587.729,
"Gamma3": 155.69308,
"alpha1": 0.0,
"Gamma0": 246044.5,
"tau5": 0.0,
"mchirp": 1.3401653,
"mtotal": 3.080601,
"impulse_time": 0,
"coa_phase": 0.17532051,
"f_final": 2047.0,
"Gamma4": -217.3298,
"ifo": "L1",
"tau0": 74.326508,
"spin2z": 0.0,
"Gamma8": 0.0,
"mass2": 1.493459,
"Gamma1": 16.0,
"snr": 9.0917339,
"amplitude": 0.0,
"Gamma6": 0.0,
"spin1y": 0.0,
"beta": 0.0,
"tau3": 1.780937,
"alpha2": 0.0,
"impulse_time_ns": 0,
"mass1": 1.587142,
"chisq": 1.296196,
"channel": "GAUSSIAN_PLUS_INJECTIONS",
"chi": 0.0,
"rsqveto_duration": 0.0,
"Gamma2": 6874.4478,
"alpha6": 0.0,
"Gamma7": 0.0
},
{
"spin1z": 0.0,
"tau4": 0.086826026,
"alpha4": 0.0,
"kappa": 0.0,
"search": "tmpltbank",
"tau2": 3.228421,
"alpha5": 0.0,
"chisq_dof": 1,
"spin2x": 0.0,
"end_time": 1338924113,
"ttotal": 75.860817,
"psi0": 1497321.0,
"bank_chisq_dof": 0,
"spin1x": 0.0,
"cont_chisq": 0.0,
"sigmasq": 5685633.996472067,
"Gamma9": 0.0,
"alpha3": 0.0,
"Gamma5": 350.55511,
"end_time_gmst": 51644.80787261624,
"spin2y": 0.0,
"alpha": 0.0,
"event_duration": 0.0,
"template_duration": 75.86827910135217,
"end_time_ns": 77976986,
"cont_chisq_dof": 0,
"eff_distance": 196.6301,
"eta": 0.24976879,
"bank_chisq": 0.0,
"psi3": -3587.729,
"Gamma3": 155.69308,
"alpha1": 0.0,
"Gamma0": 246044.5,
"tau5": 0.0,
"mchirp": 1.3401653,
"mtotal": 3.080601,
"impulse_time": 0,
"coa_phase": -2.3101556,
"f_final": 2047.0,
"Gamma4": -217.3298,
"ifo": "H1",
"tau0": 74.326508,
"spin2z": 0.0,
"Gamma8": 0.0,
"mass2": 1.493459,
"Gamma1": 16.0,
"snr": 12.126612,
"amplitude": 0.0,
"Gamma6": 0.0,
"spin1y": 0.0,
"beta": 0.0,
"tau3": 1.780937,
"alpha2": 0.0,
"impulse_time_ns": 0,
"mass1": 1.587142,
"chisq": 0.74225748,
"channel": "GAUSSIAN_PLUS_INJECTIONS",
"chi": 0.0,
"rsqveto_duration": 0.0,
"Gamma2": 6874.4478,
"alpha6": 0.0,
"Gamma7": 0.0
}
]
},
"superevent": null,
"superevent_neighbours": {},
"links": {
"neighbors": "https://gracedb.ligo.org/api/events/M394156/neighbors/",
"log": "https://gracedb.ligo.org/api/events/M394156/log/",
"emobservations": "https://gracedb.ligo.org/api/events/M394156/emobservation/",
"files": "https://gracedb.ligo.org/api/events/M394156/files/",
"labels": "https://gracedb.ligo.org/api/events/M394156/labels/",
"self": "https://gracedb.ligo.org/api/events/M394156",
"tags": "https://gracedb.ligo.org/api/events/M394156/tag/"
}
}
}
......@@ -320,31 +320,12 @@ def test_handle_superevent_retraction_alert(mock_create_retraction_circular,
def mock_download(filename, graceid, *args, **kwargs):
assert graceid == 'T250822'
assert graceid == 'M394156'
filenames = {'coinc.xml': 'coinc.xml',
'psd.xml.gz': 'psd.xml.gz',
'ranking_data.xml.gz': 'ranking_data_G322589.xml.gz'}
return resources.read_binary(data, filenames[filename])
@patch(
'gwcelery.tasks.gracedb.get_event._orig_run',
return_value={'graceid': 'T250822', 'group': 'CBC', 'pipeline': 'gstlal',
'far': 1e-7,
'extra_attributes':
{'CoincInspiral': {'snr': 10.},
'SingleInspiral': [{'mass1': 10., 'mass2': 5.}]}})
@patch('gwcelery.tasks.gracedb.download._orig_run', mock_download)
@patch('gwcelery.tasks.bayestar.localize.run')
def test_handle_cbc_event(mock_localize, mock_get_event):
"""Test that an LVAlert message for a newly uploaded PSD file triggers
BAYESTAR.
"""
alert = read_json(data, 'lvalert_psd.json')
orchestrator.handle_cbc_event(alert)
mock_localize.assert_called_once()
@pytest.mark.parametrize(
'alert_type,filename',
[['new', ''], ['log', 'psd.xml.gz'],
......@@ -396,38 +377,14 @@ def test_handle_posterior_samples(monkeypatch, alert_type, filename):
flatten.assert_called_once()
@patch('gwcelery.tasks.gracedb.download._orig_run', mock_download)
@patch('gwcelery.tasks.bayestar.localize.run')
@patch('gwcelery.tasks.em_bright.classifier_gstlal.run')
def test_handle_cbc_event_new_event(mock_classifier):
payload = {
"uid": "G000003",
"alert_type": "new",
"description": "",
"object": {
"graceid": "G000003",
"gpstime": 100.0,
"pipeline": "gstlal",
"labels": [],
"group": "CBC",
"search": "AllSky",
"far": 1.e-31,
"instruments": "H1,L1",
"extra_attributes": {
"CoincInspiral": {"snr": 20},
"SingleInspiral": [{
"mass1": 3.0,
"mass2": 1.0,
"spin1z": 0.0,
"spin2z": 0.0,
"snr": 20,
"ifo": "H1",
"chisq": 1.571
}]
},
"offline": False
}
}
orchestrator.handle_cbc_event(payload)
def test_handle_cbc_event_new_event(mock_classifier, mock_localize):
alert = read_json(data, 'lvalert_event_creation.json')
orchestrator.handle_cbc_event(alert)
mock_classifier.assert_called_once()
mock_localize.assert_called_once()
@patch(
......
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