Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process AMON IceCube alerts correctly #90

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions gtecs/alert/notices.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,12 @@ def _get_subclass(message):
return GECAMNotice(message)
elif base_notice.source.upper() == 'EINSTEIN_PROBE':
return EinsteinProbeNotice(message)
elif base_notice.source.upper() == 'ICECUBE':
return IceCubeNotice(message)
elif base_notice.source.upper() == 'AMON':
# AMON is the "Astrophysical Multimessenger Observatory Network",
# and there are several different types of notices they produce.
# For now we only care about the IceCube neutrino alerts.
if hasattr(base_notice, 'ivorn') and 'ICECUBE' in base_notice.ivorn:
return IceCubeNotice(message)
except InvalidNoticeError:
# For whatever reason the notice isn't valid, so fall back to the default class
pass
Expand Down Expand Up @@ -1072,10 +1076,10 @@ def __init__(self, payload):
super().__init__(payload)

# Check source
if self.source.upper() != 'ICECUBE':
raise InvalidNoticeError(f'Invalid source for Neutrino notice: "{self.source}"')
if self.source == 'ICECUBE':
self.source = 'IceCube' # For nice formatting
# Note IceCube uses 'AMON' as the source for all notices
if self.source.upper() != 'AMON':
raise InvalidNoticeError(f'Invalid source for IceCube notice: "{self.source}"')
self.source = 'IceCube' # For nice formatting

# Event properties
self.event_type = 'NU'
Expand Down
3 changes: 3 additions & 0 deletions gtecs/alert/sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,10 @@ def get_queue(self):

def clear_queue(self):
"""Clear the current notice queue."""
queue_length = len(self.notice_queue)
self.log.info(f'Clearing {queue_length} notices from queue')
self.notice_queue = []
return queue_length


def run():
Expand Down
4 changes: 2 additions & 2 deletions scripts/sentinel
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def query(command, args):
print(i, ivorn)
elif len(args) == 1 and args[0] == 'clear':
with Pyro4.Proxy(params.PYRO_URI) as proxy:
proxy.clear_queue()
print('Queue cleared')
queue_length = proxy.clear_queue()
print(f'Cleared {queue_length} notices from the queue')
else:
print('ERROR: Invalid arguments for "queue" command')
print('Usage: sentinel queue [clear]')
Expand Down