From 5ecc22195b0ea13cb81760d2b408857d331aff8f Mon Sep 17 00:00:00 2001 From: Tobias Megies Date: Fri, 16 Oct 2015 11:54:06 +0200 Subject: [PATCH] triggering: correct length of index array np.diff() ends up with shorter array by one item, numpy was always silently expanding the index array so far but with 1.10 is showing a deprecation warning and likely gonna raise in the future. --- obspy/signal/trigger.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/obspy/signal/trigger.py b/obspy/signal/trigger.py index 5f2645d8183..d5e58123ece 100644 --- a/obspy/signal/trigger.py +++ b/obspy/signal/trigger.py @@ -346,7 +346,11 @@ def triggerOnset(charfct, thres1, thres2, max_len=9e99, max_len_delete=False): # on = deque([ind1[0]]) of = deque([-1]) - of.extend(ind2[np.diff(ind2) > 1].tolist()) + # determine the indices where charfct falls below off-threshold + ind2_ = np.empty_like(ind2, dtype=bool) + ind2_[:-1] = np.diff(ind2) > 1 + ind2_[-1] = False + of.extend(ind2[ind2_[:-1]].tolist()) on.extend(ind1[np.where(np.diff(ind1) > 1)[0] + 1].tolist()) # include last pick if trigger is on or drop it if max_len_delete: