[bugfix] If getsignalwindow provided an empty array, checksignallength failed and lead to incomplete pick dictionaries.

This commit is contained in:
Ludger Küperkoch 2019-06-19 14:07:15 +02:00
parent e6f4545058
commit bca4ce1c11

View File

@ -8,7 +8,6 @@
:author: Ludger Kueperkoch, BESTEC GmbH :author: Ludger Kueperkoch, BESTEC GmbH
""" """
import warnings import warnings
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
from scipy.signal import argrelmax from scipy.signal import argrelmax
@ -503,6 +502,7 @@ def getsignalwin(t, t1, tsignal):
isignal, = np.where((t <= min([t1 + tsignal, t[-1]])) isignal, = np.where((t <= min([t1 + tsignal, t[-1]]))
& (t >= t1)) & (t >= t1))
if np.size(isignal) < 1: if np.size(isignal) < 1:
isignal = None
print("getsignalwin: Empty array isignal, check signal window!") print("getsignalwin: Empty array isignal, check signal window!")
return isignal return isignal
@ -829,6 +829,12 @@ def checksignallength(X, pick, minsiglength, pickparams, iplot=0, fig=None, line
inoise = getnoisewin(t, pick, TSNR[0], TSNR[1]) inoise = getnoisewin(t, pick, TSNR[0], TSNR[1])
# get signal window # get signal window
isignal = getsignalwin(t, pick, minsiglength) isignal = getsignalwin(t, pick, minsiglength)
if isignal is None:
print("checksignallength: Empty array after pick!")
print("Presumably picked noise peak, pick is rejected!")
print("(min. signal length required: %s s)" % minsiglength)
returnflag = 0
else:
# calculate minimum adjusted signal level # calculate minimum adjusted signal level
minsiglevel = np.mean(rms[inoise]) * nfac minsiglevel = np.mean(rms[inoise]) * nfac
# minimum adjusted number of samples over minimum signal level # minimum adjusted number of samples over minimum signal level