From a3487b66eab1aef2b65df7edc03c73d32fc03762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Tue, 27 Jun 2017 13:59:00 +0200 Subject: [PATCH] [Bugfix] Take care that chosen window lengths fit to length of time series. --- pylot/core/analysis/magnitude.py | 2 ++ pylot/core/pick/picker.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/pylot/core/analysis/magnitude.py b/pylot/core/analysis/magnitude.py index 867a302d..c1eee9cd 100644 --- a/pylot/core/analysis/magnitude.py +++ b/pylot/core/analysis/magnitude.py @@ -215,6 +215,8 @@ class LocalMagnitude(Magnitude): th = np.arange(0, len(sqH) * dt, dt) # get maximum peak within pick window iwin = getsignalwin(th, t0 - stime, self.calc_win) + ii = min([iwin[len(iwin)-1], len(th)]) + iwin = iwin[0:ii] wapp = np.max(sqH[iwin]) if self.verbose: print("Determined Wood-Anderson peak-to-peak amplitude for station {0}: {1} " diff --git a/pylot/core/pick/picker.py b/pylot/core/pick/picker.py index a6cd7452..ebf737a5 100644 --- a/pylot/core/pick/picker.py +++ b/pylot/core/pick/picker.py @@ -212,6 +212,14 @@ class AICPicker(AutoPicker): self.Data[0].data = self.Data[0].data * 1000000 # get signal window isignal = getsignalwin(self.Tcf, self.Pick, self.TSNR[2]) + ii = min([isignal[len(isignal)-1], len(self.Tcf)]) + isignal = isignal[0:ii] + try: + aic[isignal] + except IndexError as e: + msg = "Time series out of bounds! {}".format(e) + print(msg) + return # calculate SNR from CF self.SNR = max(abs(aic[isignal] - np.mean(aic[isignal]))) / \ max(abs(aic[inoise] - np.mean(aic[inoise])))