Skip to content

Commit

Permalink
Catch no matching data in the right places
Browse files Browse the repository at this point in the history
  • Loading branch information
calum-chamberlain committed Feb 7, 2024
1 parent a45ba3a commit 32e3675
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions eqcorrscan/core/match_filter/helpers/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,17 @@ def _pre_processor(
break
Logger.debug("Getting stream from queue")
st = _get_and_check(input_stream_queue, poison_queue)
Logger.warning(st)
if st is None:
Logger.info("Ran out of streams, stopping processing")
break
elif isinstance(st, Poison):
Logger.error("Killed")
break
if len(st) == 0:
break
# if len(st) == 0:
# Logger.error("Empty stream provided")
# poison_queue.put_nowait(Poison(IndexError("No matching channels between stream and ")))

Check failure on line 400 in eqcorrscan/core/match_filter/helpers/processes.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E501 line too long (101 > 80 characters)
# break
Logger.info(f"Processing stream:\n{st}")

# Process stream
Expand Down Expand Up @@ -528,6 +531,10 @@ def _prepper(
f"Multiple channels in continuous data for "
f"{', '.join(_duplicate_sids)}")))
break
template_sids = {tr.id for template in templates for tr in template.st}
if len(template_sids.intersection(st_sids)) == 0:
poison_queue.put_nowait(Poison(

Check warning on line 536 in eqcorrscan/core/match_filter/helpers/processes.py

View check run for this annotation

Codecov / codecov/patch

eqcorrscan/core/match_filter/helpers/processes.py#L536

Added line #L536 was not covered by tests
IndexError("No matching channels between templates and data")))
# Do the grouping for this stream
Logger.info(f"Grouping {len(templates)} templates into groups "
f"of {group_size} templates")
Expand Down
2 changes: 1 addition & 1 deletion eqcorrscan/core/match_filter/helpers/tribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def _group(
if t_name in t_dict.keys() and
len({tr.stats.station for tr in
t_dict.get(t_name).st}.intersection(stations)
) >= min_stations]
) >= max(1, min_stations)]
Logger.info(f"Dropping {len(grp) - len(template_group)} templates "
f"due to fewer than {min_stations} matched channels")
if len(template_group):
Expand Down
2 changes: 1 addition & 1 deletion eqcorrscan/core/match_filter/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ def group_templates_by_seedid(
# Don't use templates that don't have any overlap with the stream
template_seed_ids = tuple(
(t_name, t_chans) for t_name, t_chans in template_seed_ids
if len({sid.split('.')[1] for sid in t_chans}) >= min_stations)
if len({sid.split('.')[1] for sid in t_chans}) >= max(1, min_stations))
Logger.info(f"Dropping {len(templates) - len(template_seed_ids)} "
f"templates due to fewer than {min_stations} matched channels")
# We will need this dictionary at the end for getting the templates by id
Expand Down

0 comments on commit 32e3675

Please sign in to comment.