Skip to content

Commit a2c7e59

Browse files
Merge pull request #8 from eqcorrscan/hypocentral-decluster
Add hypocentral decluster options
2 parents f0c59ed + a2e5747 commit a2c7e59

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
down the real-time processing.
2121
- Templates are reshaped prior to detection use to avoid time-cost associated
2222
with re-doing this every iteration.
23+
- Added a hypocentral_separation parameter for declustering - this also has
24+
a default config value set for it (30km)
2325

2426
# 0.0.2
2527
- First full release. Everything is new!

rt_eqcorrscan/config/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class RTMatchFilterConfig(_ConfigAttribDict):
6767
"threshold": 0.3,
6868
"threshold_type": "av_chan_corr",
6969
"trig_int": 2.0,
70+
"hypocentral_separation": 30.0,
7071
"save_waveforms": True,
7172
"plot_detections": False,
7273
"max_correlation_cores": None,

rt_eqcorrscan/reactor/spin_up.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def run(working_dir: str, cores: int = 1, log_to_screen: bool = False):
144144
threshold=config.rt_match_filter.threshold,
145145
threshold_type=config.rt_match_filter.threshold_type,
146146
trig_int=config.rt_match_filter.trig_int,
147+
hypocentral_separation=config.rt_match_filter.hypocentral_separation,
147148
keep_detections=86400,
148149
detect_directory="{name}/detections",
149150
plot_detections=config.rt_match_filter.plot_detections)
@@ -152,6 +153,7 @@ def run(working_dir: str, cores: int = 1, log_to_screen: bool = False):
152153
threshold=config.rt_match_filter.threshold,
153154
threshold_type=config.rt_match_filter.threshold_type,
154155
trig_int=config.rt_match_filter.trig_int,
156+
hypocentral_separation=config.rt_match_filter.hypocentral_separation,
155157
min_stations=min_stations,
156158
keep_detections=86400,
157159
detect_directory="{name}/detections",

rt_eqcorrscan/rt_match_filter.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def _handle_detections(
196196
self,
197197
new_party: Party,
198198
trig_int: float,
199+
hypocentral_separation: float,
199200
endtime: UTCDateTime,
200201
detect_directory: str,
201202
save_waveforms: bool,
@@ -211,6 +212,9 @@ def _handle_detections(
211212
The party of new detections
212213
trig_int
213214
Minimum inter-detection time in seconds.
215+
hypocentral_separation
216+
Maximum inter-event distance in km to consider detections as being
217+
duplicates.
214218
endtime
215219
Last detection-time to be kept.
216220
detect_directory
@@ -231,11 +235,10 @@ def _handle_detections(
231235
d._calculate_event(template=family.template)
232236
self.party += family
233237
Logger.info("Removing duplicate detections")
234-
# TODO: Decluster on pick time? Find matching picks and calc median
235-
# pick time difference.
236238
if len(self.party) > 0:
237239
self.party.decluster(
238-
trig_int=trig_int, timing="origin", metric="cor_sum")
240+
trig_int=trig_int, timing="origin", metric="cor_sum",
241+
hypocentral_separation=hypocentral_separation)
239242
Logger.info("Completed decluster")
240243
Logger.info("Writing detections to disk")
241244
for family in self.party:
@@ -321,6 +324,7 @@ def run(
321324
threshold: float,
322325
threshold_type: str,
323326
trig_int: float,
327+
hypocentral_separation: float = None,
324328
min_stations: int = None,
325329
keep_detections: float = 86400,
326330
detect_directory: str = "{name}/detections",
@@ -349,6 +353,9 @@ def run(
349353
`eqcorrscan.core.match_filter.Tribe.detect` for options.
350354
trig_int
351355
Minimum inter-detection time in seconds.
356+
hypocentral_separation
357+
Maximum inter-event distance in km to consider detections as being
358+
duplicates.
352359
min_stations
353360
Minimum number of stations required to make a detection.
354361
keep_detections
@@ -478,10 +485,11 @@ def run(
478485
for tr in self.rt_client.stream.merge()])
479486
detection_kwargs = dict(
480487
threshold=threshold, threshold_type=threshold_type,
481-
trig_int=trig_int, keep_detections=keep_detections,
482-
detect_directory=detect_directory, plot_detections=plot_detections,
483-
save_waveforms=save_waveforms, maximum_backfill=first_data,
484-
endtime=None, min_stations=min_stations)
488+
trig_int=trig_int, hypocentral_separation=hypocentral_separation,
489+
keep_detections=keep_detections, detect_directory=detect_directory,
490+
plot_detections=plot_detections, save_waveforms=save_waveforms,
491+
maximum_backfill=first_data, endtime=None,
492+
min_stations=min_stations)
485493
try:
486494
while self.busy:
487495
self._running = True # Lock tribe
@@ -543,6 +551,7 @@ def run(
543551
if len(new_party) > 0:
544552
self._handle_detections(
545553
new_party, trig_int=trig_int,
554+
hypocentral_separation=hypocentral_separation,
546555
endtime=last_data - keep_detections,
547556
detect_directory=detect_directory,
548557
save_waveforms=save_waveforms,
@@ -727,6 +736,7 @@ def backfill(
727736
threshold: float,
728737
threshold_type: str,
729738
trig_int: float,
739+
hypocentral_separation: float = None,
730740
keep_detections: float = 86400,
731741
detect_directory: str = "{name}/detections",
732742
plot_detections: bool = True,
@@ -752,6 +762,9 @@ def backfill(
752762
`eqcorrscan.core.match_filter.Tribe.detect` for options.
753763
trig_int
754764
Minimum inter-detection time in seconds.
765+
hypocentral_separation
766+
Maximum inter-event distance in km to consider detections as being
767+
duplicates.
755768
keep_detections
756769
Duration to store detection in memory for in seconds.
757770
detect_directory
@@ -775,8 +788,8 @@ def backfill(
775788
backfill_process = Process(
776789
target=self._backfill,
777790
args=(templates, threshold, threshold_type, trig_int,
778-
keep_detections, detect_directory, plot_detections,
779-
save_waveforms, maximum_backfill, endtime),
791+
hypocentral_separation, keep_detections, detect_directory,
792+
plot_detections, save_waveforms, maximum_backfill, endtime),
780793
kwargs=kwargs, name=f"Backfiller_{self._number_of_backfillers}")
781794
backfill_process.start()
782795
self._backfillers.append(backfill_process)
@@ -787,6 +800,7 @@ def _backfill(
787800
threshold: float,
788801
threshold_type: str,
789802
trig_int: float,
803+
hypocentral_separation: float = None,
790804
keep_detections: float = 86400,
791805
detect_directory: str = "{name}/detections",
792806
plot_detections: bool = True,
@@ -848,13 +862,14 @@ def _backfill(
848862
Logger.info("Backfill detection completed - handling detections")
849863
if len(new_party) > 0:
850864
Logger.info(f"Lock status: {self.lock}")
851-
with self.lock: # The only time the state of RealTimeTribe is altered
865+
with self.lock: # The only time the state is altered
852866
Logger.info(f"Lock status: {self.lock}")
853867
self._handle_detections(
854868
new_party=new_party, detect_directory=detect_directory,
855869
endtime=endtime - keep_detections,
856-
plot_detections=plot_detections, save_waveforms=save_waveforms,
857-
st=st, trig_int=trig_int)
870+
plot_detections=plot_detections,
871+
save_waveforms=save_waveforms, st=st, trig_int=trig_int,
872+
hypocentral_separation=hypocentral_separation)
858873
return
859874

860875
def stop(self, write_stopfile: bool = False) -> None:

0 commit comments

Comments
 (0)