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

Optionally do not make events at detection time. #575

Merged
merged 4 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 4 additions & 1 deletion eqcorrscan/core/match_filter/helpers/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ def _make_detections(
threshold: float,
threshold_type: str,
save_progress: bool,
make_events: bool,
output_queue: Queue,
poison_queue: Queue,
):
Expand All @@ -677,6 +678,8 @@ def _make_detections(
:param save_progress:
Whether to save progress or not: If true, individual Party files will
be written each time this is run.
:param make_events:
Whether to make events for all detections or not.
:param output_queue:
Queue of output Party filenames.
:param poison_queue:
Expand Down Expand Up @@ -706,7 +709,7 @@ def _make_detections(
detections=detections, threshold=threshold,
threshold_type=threshold_type, templates=templates,
chunk_start=starttime, chunk_id=chunk_id,
save_progress=save_progress)
save_progress=save_progress, make_events=make_events)
chunk_id += 1
output_queue.put_nowait(chunk_file)
except Exception as e:
Expand Down
12 changes: 9 additions & 3 deletions eqcorrscan/core/match_filter/helpers/tribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,8 @@
templates: List[Template],
chunk_start: UTCDateTime,
chunk_id: int,
save_progress: bool
save_progress: bool,
make_events: bool,
) -> str:
"""
Construct a Party from Detections.
Expand All @@ -629,6 +630,7 @@
:param chunk_start: Starttime of party epoch
:param chunk_id: Internal index for party epoch
:param save_progress: Whether to save progress or not
:param make_events: Whether to make events for all detections or not

:return: The filename the party has been pickled to.
"""
Expand Down Expand Up @@ -657,7 +659,10 @@
detection_idx_dict[detection.template_name].append(n)

# Convert to Families and build party.
Logger.info("Converting to party and making events")
if not make_events:
Logger.info("Converting to party")

Check warning on line 663 in eqcorrscan/core/match_filter/helpers/tribe.py

View check run for this annotation

Codecov / codecov/patch

eqcorrscan/core/match_filter/helpers/tribe.py#L663

Added line #L663 was not covered by tests
else:
Logger.info("Converting to party and making events")
chunk_party = Party()

# Make a dictionary of templates keyed by name - we could be passed a dict
Expand All @@ -676,7 +681,8 @@
with open(template, "rb") as f:
template = pickle.load(f)
for d in family_detections:
d._calculate_event(template=template)
if make_events:
d._calculate_event(template=template)
family = Family(
template=template, detections=family_detections)
chunk_party += family
Expand Down
19 changes: 11 additions & 8 deletions eqcorrscan/core/match_filter/tribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@
concurrent_processing=False, ignore_length=False,
ignore_bad_data=False, group_size=None, overlap="calculate",
full_peaks=False, save_progress=False, process_cores=None,
pre_processed=False, check_processing=True, min_stations=0,
**kwargs):
pre_processed=False, check_processing=True, make_events=True,
min_stations=0, **kwargs):
"""
Detect using a Tribe of templates within a continuous stream.

Expand Down Expand Up @@ -875,7 +875,7 @@
ignore_bad_data, group_size, groups, sampling_rate, threshold,
threshold_type, save_progress, xcorr_func, concurrency, cores,
export_cccsums, parallel, peak_cores, trig_int, full_peaks,
plot, plotdir, plot_format, min_stations,)
plot, plotdir, plot_format, make_events, min_stations,)

if concurrent_processing:
party = self._detect_concurrent(*args, **inner_kwargs)
Expand Down Expand Up @@ -903,7 +903,7 @@
group_size, groups, sampling_rate, threshold, threshold_type,
save_progress, xcorr_func, concurrency, cores, export_cccsums,
parallel, peak_cores, trig_int, full_peaks, plot, plotdir, plot_format,
min_stations, **kwargs
make_events, min_stations, **kwargs
):
""" Internal serial detect workflow. """
from eqcorrscan.core.match_filter.helpers.tribe import (
Expand Down Expand Up @@ -968,7 +968,8 @@
detections=detections, threshold=threshold,
threshold_type=threshold_type,
templates=self.templates, chunk_start=starttime,
chunk_id=i, save_progress=save_progress)
chunk_id=i, save_progress=save_progress,

Check failure on line 971 in eqcorrscan/core/match_filter/tribe.py

View workflow job for this annotation

GitHub Actions / flake8-linter

W291 trailing whitespace
calum-chamberlain marked this conversation as resolved.
Show resolved Hide resolved
make_events=make_events)
chunk_files.append(chunk_file)
# Rebuild
for _chunk_file in chunk_files:
Expand All @@ -993,7 +994,7 @@
group_size, groups, sampling_rate, threshold, threshold_type,
save_progress, xcorr_func, concurrency, cores, export_cccsums,
parallel, peak_cores, trig_int, full_peaks, plot, plotdir, plot_format,
min_stations, **kwargs
make_events, min_stations, **kwargs
):
""" Internal concurrent detect workflow. """
from eqcorrscan.core.match_filter.helpers.processes import (
Expand Down Expand Up @@ -1082,6 +1083,7 @@
threshold=threshold,
threshold_type=threshold_type,
save_progress=save_progress,
make_events=make_events,
output_queue=party_file_queue,
poison_queue=poison_queue,
),
Expand Down Expand Up @@ -1232,7 +1234,8 @@
ignore_bad_data=False, group_size=None,
return_stream=False, full_peaks=False,
save_progress=False, process_cores=None, retries=3,
check_processing=True, min_stations=0, **kwargs):
check_processing=True, make_events=True,

Check failure on line 1237 in eqcorrscan/core/match_filter/tribe.py

View workflow job for this annotation

GitHub Actions / flake8-linter

W291 trailing whitespace
calum-chamberlain marked this conversation as resolved.
Show resolved Hide resolved
min_stations=0, **kwargs):
"""
Detect using a Tribe of templates within a continuous stream.

Expand Down Expand Up @@ -1438,7 +1441,7 @@
return_stream=return_stream, check_processing=False,
poison_queue=poison_queue, shutdown=False,
concurrent_processing=concurrent_processing, groups=groups,
min_stations=min_stations)
make_events=make_events, min_stations=min_stations)

if not concurrent_processing:
Logger.warning("Using concurrent_processing=True can be faster if"
Expand Down
Loading