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
12 unresolved threads
Compare and Show latest version
4 files
+ 73
107
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -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):
@@ -102,7 +102,7 @@ def handle_grb_gcn(payload):
Swift: https://gcn.gsfc.nasa.gov/swift.html
INTEGRAL: https://gcn.gsfc.nasa.gov/integral.html
AGILE-MCAL: https://gcn.gsfc.nasa.gov/agile_mcal.html
#SVOM-ECLAIRS: https://gcn.gsfc.nasa.gov/svom.html
# SVOM-ECLAIRS: https://gcn.gsfc.nasa.gov/svom.html
Parameters
----------
@@ -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
----------
@@ -739,6 +741,7 @@ def _kafka_to_voevent(alert):
start_time = alert['trigger_time']
alert_time = alert['alert_datetime']
far = alert['far']
snr = alert['rate_snr']
duration = alert['rate_duration']
id = '_'.join(str(x) for x in alert['id'])
# Use central time since starting time is not well measured
@@ -751,7 +754,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 +765,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()
@@ -784,11 +800,21 @@ def _kafka_to_voevent(alert):
"ObservationLocation/AstroCoords/Time/TimeInstant/"
"ISOTime")).text = str(trigger_time).encode()
root.find("./What/Param[@name='FAR']").attrib['value'] = \
str(far).encode()
if pipeline.lower() in ['fermi', 'swift']:
root.find("./What/Param[@name='FAR']").attrib['value'] = \
(str(far).encode())
else:
root.find("./Group[@name='Detection_Info']"
"/Param[@name='SNR']").attrib['value'] = \
(str(snr).encode())
root.find("./What/Param[@name='Integ_Time']").attrib['value'] = \
str(duration).encode()
if pipeline.lower() in ['fermi', 'swift']:
root.find("./What/Param[@name='Integ_Time']").attrib['value'] = \
str(duration).encode()
else:
root.find("./Group[@name='Svom_Identifiers']"
"/Param[@name='Timescale']").attrib['value'] = \
(str(duration).encode())
# Sky position
root.find(("./WhereWhen/ObsDataLocation/"
Loading