Skip to content
Snippets Groups Projects

Draft: Ingestion of SVOM ECLAIRS notices into LLAI workflow

Open Naresh Adhikari requested to merge naresh.adhikari/gwcelery:addsvom into main
Compare and Show latest version
3 files
+ 56
18
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -85,7 +85,7 @@ def handle_snews_gcn(payload):
gcn.NoticeType.INTEGRAL_REFINED,
gcn.NoticeType.INTEGRAL_OFFLINE,
gcn.NoticeType.AGILE_MCAL_ALERT,
#gcn.NoticeType.SVOM_ECLAIRS_ALERT,
# gcn.NoticeType.SVOM_ECLAIRS_ALERT,
queue='exttrig',
shared=False)
def handle_grb_gcn(payload):
@@ -469,10 +469,12 @@ def handle_snews_igwn_alert(alert):
@alerts.handler('fermi',
'swift')
'swift',
'svom')
def handle_targeted_kafka_alert(alert):
"""Parse an alert sent via Kafka from a MOU partner in our joint
subthreshold targeted search.
subthreshold targeted search. Also, parse Kafka alert types for
SVOM ECLAIRS GRBs.
Parameters
----------
@@ -721,7 +723,7 @@ def _create_replace_external_event_and_skymap(
def _kafka_to_voevent(alert):
"""Parse an alert sent via Kafka from a MOU partner in our joint
subthreshold targeted search and convert to an equivalent XML string
GCN VOEvent.
GCN VOEvent. Also, include handling for SVOM/ECLAIRs mission alert.
Parameters
----------
@@ -751,7 +753,7 @@ def _kafka_to_voevent(alert):
# sky localization may not be available
ra = alert.get('ra')
dec = alert.get('dec')
# Try to get dec first then ra, None if both misssing
# Try to get dec first then ra, None if both missing
error = alert.get('dec_uncertainty')
if error is None:
error = alert.get('ra_uncertainty')
@@ -762,21 +764,34 @@ def _kafka_to_voevent(alert):
if ra is None or dec is None or error is None:
ra, dec, error = 0., 0., 0.
# Load template
fname = str(Path(__file__).parent /
'../tests/data/{}_subgrbtargeted_template.xml'.format(
pipeline.lower()))
root = etree.parse(fname)
# Load template based on the mission
# FIXME: Need to adjust for targeted Fermi-Swift and SVOM/ECLAIRS GRBs
if pipeline.lower() in ['fermi', 'swift']:
fname = f'{pipeline_lower()}_subgrbtargeted_template.xml'
ivorn_suffix = 'targeted_subthreshold'
else:
fname = 'svom_grb_template_xml'
ivorn_suffix = 'grb'
# Construct the full path to the template
template_path = Path(__file__).parent / f'../tests/data/{fname}'
if not template_path.is_file():
raise FileNotFoundError(f'Template file {fname} not found '
f'in ../tests/data')
root = etree.parse(str(template_path))
# Update template values
# Change ivorn to indicate this is a subthreshold targeted event
root.xpath('.')[0].attrib['ivorn'] = \
'ivo://lvk.internal/{0}#targeted_subthreshold-{1}'.format(
pipeline.lower(), trigger_time).encode()
# Change ivorn to indicate this is subthreshold targeted event and SVOM grb
ivorn = \
f'ivo://lvk.internal/{pipeline.lower()}#{ivorn_suffix}-{trigger_time}'
root.xpath('.')[0].attrib['ivorn'] = ivorn
# Update ID
root.find("./What/Param[@name='TrigID']").attrib['value'] = \
id.encode()
if pipeline.lower() in ['fermi', 'swift']:
root.find("./What/Param[@name='TrigID']").attrib['value'] = str(id)
else:
root.find("./What/Param[@name='Burst_Id']").attrib['value'] = str(id)
# Change times to chosen time
root.find("./Who/Date").text = str(alert_time).encode()
root.find(("./WhereWhen/ObsDataLocation/"
"ObservationLocation/AstroCoords/Time/TimeInstant/"
"ISOTime")).text = str(trigger_time).encode()
Loading