diff --git a/ligo/followup_advocate/__init__.py b/ligo/followup_advocate/__init__.py index c6f63b13e2a74671176d4e87314b16168a53ddc1..abd4ea03f59a8afb20260eb273c7551b47836d45 100644 --- a/ligo/followup_advocate/__init__.py +++ b/ligo/followup_advocate/__init__.py @@ -178,7 +178,7 @@ def compose(gracedb_id, authors=(), mailto=False, return '{0}\n{1}'.format(subject, body) -def compose_RAVEN(gracedb_id, authors=(), +def compose_raven(gracedb_id, authors=(), service=rest.DEFAULT_SERVICE_URL, client=None): """Compose EM_COINC RAVEN GCN Circular draft""" @@ -202,8 +202,8 @@ def compose_RAVEN(gracedb_id, authors=(), external_pipeline = em_event['pipeline'] # FIXME in GraceDb: Even SNEWS triggers have an extra attribute GRB. external_trigger_id = em_event['extra_attributes']['GRB']['trigger_id'] - SNEWS = (em_event['search'] == 'Supernova') - GRB = (em_event['search'] == 'GRB') + snews = (em_event['search'] == 'Supernova') + grb = (em_event['search'] == 'GRB') o = urllib.parse.urlparse(client.service_url) kwargs = dict( @@ -214,23 +214,23 @@ def compose_RAVEN(gracedb_id, authors=(), superevent_far=preferred_event['far'], external_pipeline=external_pipeline, external_trigger=external_trigger_id, - SNEWS=SNEWS, - GRB=GRB, + snews=snews, + grb=grb, latency=abs(round(em_event_gpstime-gpstime, 1)), beforeafter='before' if gpstime > em_event_gpstime else 'after') - if GRB: + if grb: # Grab GRB coincidence FARs files = client.files(gracedb_id).json() coinc_far_file = 'coincidence_far.json' if coinc_far_file in files: coincidence_far = client.files(gracedb_id, coinc_far_file).json() - time_coinc_FAR = coincidence_far.get('temporal_coinc_far') - space_time_coinc_FAR = coincidence_far.get( + time_coinc_far = coincidence_far.get('temporal_coinc_far') + space_time_coinc_far = coincidence_far.get( 'spatiotemporal_coinc_far') kwargs.update( - time_coinc_FAR=time_coinc_FAR, - space_time_coinc_FAR=space_time_coinc_FAR) + time_coinc_far=time_coinc_far, + space_time_coinc_far=space_time_coinc_far) # Check if subthreshold trigger voevent_text = client.files( @@ -306,7 +306,7 @@ def compose_grb_medium_latency( (o.scheme, o.netloc, '/events/', '', '')), gracedb_id=gracedb_id, group=group, - GRB=True, + grb=True, pipeline=pipeline, external_trigger=external_trigger, exclusions=[], diff --git a/ligo/followup_advocate/templates/RAVEN_circular.jinja2 b/ligo/followup_advocate/templates/RAVEN_circular.jinja2 index 1abf528fac860e88b6a5618cbd6f95a1b7ce2068..53155405dcdc78586906fda88f9f2adad7823a3b 100644 --- a/ligo/followup_advocate/templates/RAVEN_circular.jinja2 +++ b/ligo/followup_advocate/templates/RAVEN_circular.jinja2 @@ -5,13 +5,13 @@ {% filter rewrap %} A search performed by the RAVEN pipeline found a temporal coincidence between -{{gracedb_id}} and a {% if SNEWS %}SNEWS supernova{% elif GRB %}{% if subthreshold %}sub-threshold {% endif %}{{grbmission(external_pipeline)}}{% endif %} {{propername(external_trigger)}} **CITE ORIGINAL GCN FOR THE EXTERNAL TRIGGER FROM https://gcn.gsfc.nasa.gov/gcn3_archive.html, e.g., (Bhalerao et al., GCN Circular XXXXX)**. -The {% if SNEWS %}neutrino{% elif GRB %}GRB{% endif %} trigger time is {{latency}} seconds {{beforeafter}} the GW candidate event. -{% if GRB %} -The estimated joint false alarm rate for the time coincidence is {{naturalfar(time_coinc_FAR)}}. +{{gracedb_id}} and a {% if snews %}SNEWS supernova{% elif grb %}{% if subthreshold %}sub-threshold {% endif %}{{grbmission(external_pipeline)}}{% endif %} {{propername(external_trigger)}} **CITE ORIGINAL GCN FOR THE EXTERNAL TRIGGER FROM https://gcn.gsfc.nasa.gov/gcn3_archive.html, e.g., (Bhalerao et al., GCN Circular XXXXX)**. +The {% if snews %}neutrino{% elif grb %}GRB{% endif %} trigger time is {{latency}} seconds {{beforeafter}} the GW candidate event. +{% if grb %} +The estimated joint false alarm rate for the time coincidence is {{naturalfar(time_coinc_far)}}. {% endif %} -{% if GRB %}{%- include 'classification_info.jinja2' -%}{% endif %} +{% if grb %}{%- include 'classification_info.jinja2' -%}{% endif %} {% if combined_skymap is not defined %} {% include 'userguide_conclusion.jinja2'%} @@ -20,8 +20,8 @@ A combined sky map is also available: * {{combined_skymap}}, the normalized product of the GW and GRB localizations. For the {{combined_skymap}} sky map, the {{cl}}% credible region is {{combined_skymap_greedy_area|round|int}} deg2. -{% if space_time_coinc_FAR is not none %} -Considering the overlap of the individual sky maps, the estimated joint false alarm rate for the spatial and temporal coincidence is {{naturalfar(space_time_coinc_FAR)}}. +{% if space_time_coinc_far is not none %} +Considering the overlap of the individual sky maps, the estimated joint false alarm rate for the spatial and temporal coincidence is {{naturalfar(space_time_coinc_far)}}. {% else %} The spatial and temporal coincidence is not yet available. {% endif %} diff --git a/ligo/followup_advocate/templates/initial_body.jinja2 b/ligo/followup_advocate/templates/initial_body.jinja2 index 49c2b9ae85e5d1261792b4bbfbd02965853072c0..72333a6d2649bb2abc0f09c08cf6e18c4836bfd7 100644 --- a/ligo/followup_advocate/templates/initial_body.jinja2 +++ b/ligo/followup_advocate/templates/initial_body.jinja2 @@ -11,7 +11,7 @@ analysis pipeline{% if ([pipeline] + other_pipelines)|length > 1 %}s{% endif %}. {% if change_significance_statement %} This gravitational wave candidate is not significant enough on its own to produce a public alert -but its coincidence with the {% if SNEWS %}SNEWS neutrino{% endif %}{% if GRB %}GRB{% endif %} trigger increases its significance. +but its coincidence with the {% if snews %}SNEWS neutrino{% endif %}{% if grb %}GRB{% endif %} trigger increases its significance. {% else %} {{gracedb_id}} is an event of interest because its false alarm rate, as estimated by the online analysis, is {{naturalfar(far)}}. @@ -20,7 +20,7 @@ The event's properties can be found at this URL: {{ gracedb_service_url }}{{ gracedb_id }} -{% if not GRB %}{%- include 'classification_info.jinja2' -%}{% endif %} +{% if not grb %}{%- include 'classification_info.jinja2' -%}{% endif %} {% if skymaps|length == 0 %} No{% else %}{{ skymaps|length|apnumber|capitalize }}{% endif %} {% if combined_skymap is not defined %}sky map{% else %}GW-only sky map{% endif %}{% if skymaps|length == 1 %} is{% else %}s are{% endif %} available at this time{% if skymaps|length > 0 %} and can be retrieved from the GraceDB event page:{% else %}.{% endif %} diff --git a/ligo/followup_advocate/test/test_tool.py b/ligo/followup_advocate/test/test_tool.py index ef224acb07e3bad9c0a2d8be25073f834464ad21..ff69c39e9c81131ca76eab7516840b358008e34c 100644 --- a/ligo/followup_advocate/test/test_tool.py +++ b/ligo/followup_advocate/test/test_tool.py @@ -85,13 +85,13 @@ def test_compose_mailto(mock_gracedb, mock_webbrowser_open): assert mock_webbrowser_open.called_once() -def test_RAVEN_with_initial_circular(mock_gracedb): - main(['--service', 'https://gracedb.invalid/api/', 'compose_RAVEN', +def test_raven_with_initial_circular(mock_gracedb): + main(['--service', 'https://gracedb.invalid/api/', 'compose_raven', 'S1234']) -def test_RAVEN_without_initial_circular(mock_gracedb): - main(['--service', 'https://gracedb.invalid/api/', 'compose_RAVEN', +def test_raven_without_initial_circular(mock_gracedb): + main(['--service', 'https://gracedb.invalid/api/', 'compose_raven', 'S5678']) diff --git a/ligo/followup_advocate/tool.py b/ligo/followup_advocate/tool.py index 96858811bebc4c35d02e8e8b7e8adaa2a19d5588..a6bc3869117c66264078d7fb0ea22f36684f0089 100644 --- a/ligo/followup_advocate/tool.py +++ b/ligo/followup_advocate/tool.py @@ -32,7 +32,7 @@ def main(args=None): cmd.add_argument('gracedb_id', metavar='S123456', help='GraceDB ID of superevent') - cmd = add_command(followup_advocate.compose_RAVEN, parents=[authors]) + cmd = add_command(followup_advocate.compose_raven, parents=[authors]) cmd.add_argument('gracedb_id', metavar='S123456', help='GraceDB ID of superevent')