From 86ad072dbf872af12c2bae008be80e91eb1c546d Mon Sep 17 00:00:00 2001 From: Donavin97 Date: Fri, 23 Feb 2024 14:23:19 +0000 Subject: [PATCH 1/7] fixed some typos, also added author filter. --- apps/python/descriptions/scalert.xml | 8 ++++++++ apps/python/scalert.py | 29 ++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/apps/python/descriptions/scalert.xml b/apps/python/descriptions/scalert.xml index 84effa7e3..1877246c4 100644 --- a/apps/python/descriptions/scalert.xml +++ b/apps/python/descriptions/scalert.xml @@ -19,6 +19,14 @@ empty list (=""): all agencies are allowed + + + List of authors to consider picks and origins. The author + is extracted from the pick or the preferred origin of the event + and compared with the configured authors. + empty list (=""): all authors are allowed + + diff --git a/apps/python/scalert.py b/apps/python/scalert.py index 29870bdae..1f3a56565 100644 --- a/apps/python/scalert.py +++ b/apps/python/scalert.py @@ -61,6 +61,7 @@ def __init__(self, argc, argv): self._newWhenFirstSeen = False self._oldEvents = [] self._agencyIDs = [] + self._authors = [] self._phaseHints = [] self._phaseStreams = [] self._phaseNumber = 1 @@ -115,7 +116,21 @@ def init(self): except: pass + try: + self._authors = [self.configGetString("author")] + except: + pass + try: + authors = self.configGetStrings("authors") + self._authors = [] + for item in authors: + item = item.strip() + if item not in self._authors: + self._authors.append(item) + except: + pass + self._phaseHints = ['P','S'] try: phaseHints = self.configGetStrings("constraints.phaseHints") @@ -318,6 +333,11 @@ def init(self): else: seiscomp.logging.info(" + agencyIDs: no filter is applied") + if " ".join(self._authors): + seiscomp.logging.info(" + Authors filter for events and picks: %s" % (" ".join(self._authors))) + else: + seiscomp.logging.info(" + authors: no filter is applied") + if " ".join(self._phaseHints): seiscomp.logging.info(" + phase hint filter for picks: '%s'" % (" ".join(self._phaseHints))) else: @@ -469,6 +489,7 @@ def addObject(self, parentID, object): self._cache.feed(obj) seiscomp.logging.debug("got new pick '%s'" % obj.publicID()) agencyID = obj.creationInfo().agencyID() + authors = org.creationInfo().author() phaseHint = obj.phaseHint().code() if self._phaseStreams: waveformID = "%s.%s.%s.%s" % ( @@ -534,9 +555,11 @@ def addObject(self, parentID, object): org = self._cache.get( seiscomp.datamodel.Origin, obj.preferredOriginID()) agencyID = org.creationInfo().agencyID() + authors = org.creationInfo().author() seiscomp.logging.debug("got new event '%s'" % obj.publicID()) if not self._agencyIDs or agencyID in self._agencyIDs: - self.notifyEvent(obj, True) + if not self._authors or authors in self._authors: + self.notifyEvent(obj, True) return except: info = traceback.format_exception(*sys.exc_info()) @@ -550,9 +573,11 @@ def updateObject(self, parentID, object): org = self._cache.get( seiscomp.datamodel.Origin, obj.preferredOriginID()) agencyID = org.creationInfo().agencyID() + author = org.creationInfo().author() seiscomp.logging.debug("update event '%s'" % obj.publicID()) if not self._agencyIDs or agencyID in self._agencyIDs: - self.notifyEvent(obj, False) + if not self._authors or author in self._authors: + self.notifyEvent(obj, False) except: info = traceback.format_exception(*sys.exc_info()) for i in info: From a1758e1077428e5a1a03fe4f6b0adf0ffb9f6a65 Mon Sep 17 00:00:00 2001 From: Donavin97 Date: Fri, 23 Feb 2024 14:23:19 +0000 Subject: [PATCH 2/7] Scalert: Fixed some typos, also added author filter. --- apps/python/descriptions/scalert.xml | 8 ++++++++ apps/python/scalert.py | 29 ++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/apps/python/descriptions/scalert.xml b/apps/python/descriptions/scalert.xml index 84effa7e3..1877246c4 100644 --- a/apps/python/descriptions/scalert.xml +++ b/apps/python/descriptions/scalert.xml @@ -19,6 +19,14 @@ empty list (=""): all agencies are allowed + + + List of authors to consider picks and origins. The author + is extracted from the pick or the preferred origin of the event + and compared with the configured authors. + empty list (=""): all authors are allowed + + diff --git a/apps/python/scalert.py b/apps/python/scalert.py index 29870bdae..1f3a56565 100644 --- a/apps/python/scalert.py +++ b/apps/python/scalert.py @@ -61,6 +61,7 @@ def __init__(self, argc, argv): self._newWhenFirstSeen = False self._oldEvents = [] self._agencyIDs = [] + self._authors = [] self._phaseHints = [] self._phaseStreams = [] self._phaseNumber = 1 @@ -115,7 +116,21 @@ def init(self): except: pass + try: + self._authors = [self.configGetString("author")] + except: + pass + try: + authors = self.configGetStrings("authors") + self._authors = [] + for item in authors: + item = item.strip() + if item not in self._authors: + self._authors.append(item) + except: + pass + self._phaseHints = ['P','S'] try: phaseHints = self.configGetStrings("constraints.phaseHints") @@ -318,6 +333,11 @@ def init(self): else: seiscomp.logging.info(" + agencyIDs: no filter is applied") + if " ".join(self._authors): + seiscomp.logging.info(" + Authors filter for events and picks: %s" % (" ".join(self._authors))) + else: + seiscomp.logging.info(" + authors: no filter is applied") + if " ".join(self._phaseHints): seiscomp.logging.info(" + phase hint filter for picks: '%s'" % (" ".join(self._phaseHints))) else: @@ -469,6 +489,7 @@ def addObject(self, parentID, object): self._cache.feed(obj) seiscomp.logging.debug("got new pick '%s'" % obj.publicID()) agencyID = obj.creationInfo().agencyID() + authors = org.creationInfo().author() phaseHint = obj.phaseHint().code() if self._phaseStreams: waveformID = "%s.%s.%s.%s" % ( @@ -534,9 +555,11 @@ def addObject(self, parentID, object): org = self._cache.get( seiscomp.datamodel.Origin, obj.preferredOriginID()) agencyID = org.creationInfo().agencyID() + authors = org.creationInfo().author() seiscomp.logging.debug("got new event '%s'" % obj.publicID()) if not self._agencyIDs or agencyID in self._agencyIDs: - self.notifyEvent(obj, True) + if not self._authors or authors in self._authors: + self.notifyEvent(obj, True) return except: info = traceback.format_exception(*sys.exc_info()) @@ -550,9 +573,11 @@ def updateObject(self, parentID, object): org = self._cache.get( seiscomp.datamodel.Origin, obj.preferredOriginID()) agencyID = org.creationInfo().agencyID() + author = org.creationInfo().author() seiscomp.logging.debug("update event '%s'" % obj.publicID()) if not self._agencyIDs or agencyID in self._agencyIDs: - self.notifyEvent(obj, False) + if not self._authors or author in self._authors: + self.notifyEvent(obj, False) except: info = traceback.format_exception(*sys.exc_info()) for i in info: From c11049e3afa27c70a05c3b57ef48c71e6afb0e61 Mon Sep 17 00:00:00 2001 From: Donavin97 Date: Fri, 12 Apr 2024 12:12:45 +0000 Subject: [PATCH 3/7] Scalert: Author filter. Removed redundent code. --- apps/python/scalert.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/apps/python/scalert.py b/apps/python/scalert.py index 1f3a56565..f9bd3bebb 100644 --- a/apps/python/scalert.py +++ b/apps/python/scalert.py @@ -116,11 +116,6 @@ def init(self): except: pass - try: - self._authors = [self.configGetString("author")] - except: - pass - try: authors = self.configGetStrings("authors") self._authors = [] @@ -576,7 +571,7 @@ def updateObject(self, parentID, object): author = org.creationInfo().author() seiscomp.logging.debug("update event '%s'" % obj.publicID()) if not self._agencyIDs or agencyID in self._agencyIDs: - if not self._authors or author in self._authors: + if not self._authors or authosr in self._authors: self.notifyEvent(obj, False) except: info = traceback.format_exception(*sys.exc_info()) From 2cd02b6aca6a5087d6618ad33512515f1a211936 Mon Sep 17 00:00:00 2001 From: Donavin97 Date: Thu, 10 Jul 2025 15:54:08 +0000 Subject: [PATCH 4/7] Added "evtype" variable. --- apps/python/scalert.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/python/scalert.py b/apps/python/scalert.py index e0e74c9c4..0c9f49787 100644 --- a/apps/python/scalert.py +++ b/apps/python/scalert.py @@ -750,6 +750,13 @@ def notifyEvent(self, evt, newEvent=True, dtmax=3600): seiscomp.logging.debug(f"desc: {dsc}") + evtype = "" + try: + evtype = seiscomp.datamodel.EEventTypeNames.name(evt.type()) + except ValueError: + evtype = "earthquake" + + dep = org.depth().value() now = seiscomp.core.Time.GMT() otm = org.time().value() @@ -769,7 +776,8 @@ def notifyEvent(self, evt, newEvent=True, dtmax=3600): if preliminary: message = f"earthquake, XXL, preliminary, {dt}, {dsc}" else: - message = "earthquake, %s, %s, %s, depth %d kilometers" % ( + message = "%s, %s, %s, %s, depth %d kilometers" % ( + evtype, dt, dsc, mag, From 84870d505c1239f83f62cfacb5152cf4dd9275a1 Mon Sep 17 00:00:00 2001 From: Donavin97 Date: Fri, 11 Jul 2025 08:19:27 +0000 Subject: [PATCH 5/7] Fixed code to be inline with new standards. --- apps/python/scalert.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/apps/python/scalert.py b/apps/python/scalert.py index 0c9f49787..ef0b4b398 100644 --- a/apps/python/scalert.py +++ b/apps/python/scalert.py @@ -750,12 +750,11 @@ def notifyEvent(self, evt, newEvent=True, dtmax=3600): seiscomp.logging.debug(f"desc: {dsc}") - evtype = "" + try: - evtype = seiscomp.datamodel.EEventTypeNames.name(evt.type()) - except ValueError: - evtype = "earthquake" - + evType = seiscomp.datamodel.EEventTypeNames.name(evt.type()) + except Exception: + evType = "earthquake" dep = org.depth().value() now = seiscomp.core.Time.GMT() @@ -774,15 +773,10 @@ def notifyEvent(self, evt, newEvent=True, dtmax=3600): dt = f"{int(dt)} seconds ago" if preliminary: - message = f"earthquake, XXL, preliminary, {dt}, {dsc}" + message = f"{evType}, XXL, preliminary, {dt}, {dsc}" else: - message = "%s, %s, %s, %s, depth %d kilometers" % ( - evtype, - dt, - dsc, - mag, - int(dep + 0.5), - ) + message = f"{evType}, {dt}, {dsc}, {mag}, depth {int(dep + 0.5)} kilometers" + seiscomp.logging.info(message) if not self._eventScript: From faba77389e56e3de4617c0bbc09eb1db03f10733 Mon Sep 17 00:00:00 2001 From: Donavin97 Date: Fri, 11 Jul 2025 09:27:18 +0000 Subject: [PATCH 6/7] Fixed indentation --- apps/python/scalert.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/python/scalert.py b/apps/python/scalert.py index ef0b4b398..fccdf6a6d 100644 --- a/apps/python/scalert.py +++ b/apps/python/scalert.py @@ -754,7 +754,7 @@ def notifyEvent(self, evt, newEvent=True, dtmax=3600): try: evType = seiscomp.datamodel.EEventTypeNames.name(evt.type()) except Exception: - evType = "earthquake" + evType = "earthquake" dep = org.depth().value() now = seiscomp.core.Time.GMT() From bd06faeeb99a3e0429e00dd671428d76323dfe29 Mon Sep 17 00:00:00 2001 From: Donavin97 Date: Sat, 10 Jan 2026 11:45:30 +0000 Subject: [PATCH 7/7] Added meters if depth is less than 1KM, Also specified dynamic variable that changes when depth is below and above 1 KM. --- apps/python/scalert.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/python/scalert.py b/apps/python/scalert.py index a249767b9..de10df48f 100644 --- a/apps/python/scalert.py +++ b/apps/python/scalert.py @@ -755,7 +755,16 @@ def notifyEvent(self, evt, newEvent=True, dtmax=3600): except Exception: evType = "earthquake" - dep = org.depth().value() + if org.depth().value() <1: + dep = round(org.depth().value(), 2) * 1000 + else: + dep = round(org.depth().value(), 2) + + if org.depth().value() <1: + depth_measure = "Meters" + else: + depth_measure = "Kilometers" + now = seiscomp.core.Time.GMT() otm = org.time().value() @@ -774,7 +783,7 @@ def notifyEvent(self, evt, newEvent=True, dtmax=3600): if preliminary: message = f"{evType}, XXL, preliminary, {dt}, {dsc}" else: - message = f"{evType}, {dt}, {dsc}, {mag}, depth {int(dep + 0.5)} kilometers" + message = f"{evType}, {dt}, {dsc}, {mag}, depth {dep} {depth_measure}" seiscomp.logging.info(message)