Skip to content

Commit

Permalink
Add catch for negative length trimming
Browse files Browse the repository at this point in the history
  • Loading branch information
calum-chamberlain committed Jun 19, 2024
1 parent d166230 commit ad1ff18
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions eqcorrscan/utils/mag_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,9 @@ def amp_pick_event(event, st, inventory, chans=('Z',), var_wintype=True,
else:
trim_start = s_time - pre_pick
trim_end = s_time + winlen
if trim_end <= trim_start:
Logger.error(f"Trying to trim to negative length: {trim_start} -- {trim_end}. Skipping")

Check failure on line 923 in eqcorrscan/utils/mag_calc.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E501 line too long (104 > 80 characters)
continue

Check warning on line 924 in eqcorrscan/utils/mag_calc.py

View check run for this annotation

Codecov / codecov/patch

eqcorrscan/utils/mag_calc.py#L923-L924

Added lines #L923 - L924 were not covered by tests
tr = tr.trim(trim_start, trim_end)
if len(tr.data) <= 10:
Logger.warning(f'Insufficient data for {sta}')
Expand Down

0 comments on commit ad1ff18

Please sign in to comment.