[bugfix] If getsignalwindow provided an empty array, checksignallength failed and lead to incomplete pick dictionaries.
This commit is contained in:
parent
e6f4545058
commit
bca4ce1c11
@ -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,21 +829,27 @@ 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)
|
||||||
# calculate minimum adjusted signal level
|
if isignal is None:
|
||||||
minsiglevel = np.mean(rms[inoise]) * nfac
|
print("checksignallength: Empty array after pick!")
|
||||||
# minimum adjusted number of samples over minimum signal level
|
|
||||||
minnum = len(isignal) * minpercent / 100
|
|
||||||
# get number of samples above minimum adjusted signal level
|
|
||||||
numoverthr = len(np.where(rms[isignal] >= minsiglevel)[0])
|
|
||||||
|
|
||||||
if numoverthr >= minnum:
|
|
||||||
print("checksignallength: Signal reached required length.")
|
|
||||||
returnflag = 1
|
|
||||||
else:
|
|
||||||
print("checksignallength: Signal shorter than required minimum signal length!")
|
|
||||||
print("Presumably picked noise peak, pick is rejected!")
|
print("Presumably picked noise peak, pick is rejected!")
|
||||||
print("(min. signal length required: %s s)" % minsiglength)
|
print("(min. signal length required: %s s)" % minsiglength)
|
||||||
returnflag = 0
|
returnflag = 0
|
||||||
|
else:
|
||||||
|
# calculate minimum adjusted signal level
|
||||||
|
minsiglevel = np.mean(rms[inoise]) * nfac
|
||||||
|
# minimum adjusted number of samples over minimum signal level
|
||||||
|
minnum = len(isignal) * minpercent / 100
|
||||||
|
# get number of samples above minimum adjusted signal level
|
||||||
|
numoverthr = len(np.where(rms[isignal] >= minsiglevel)[0])
|
||||||
|
|
||||||
|
if numoverthr >= minnum:
|
||||||
|
print("checksignallength: Signal reached required length.")
|
||||||
|
returnflag = 1
|
||||||
|
else:
|
||||||
|
print("checksignallength: Signal shorter than required minimum signal length!")
|
||||||
|
print("Presumably picked noise peak, pick is rejected!")
|
||||||
|
print("(min. signal length required: %s s)" % minsiglength)
|
||||||
|
returnflag = 0
|
||||||
|
|
||||||
if iplot > 1:
|
if iplot > 1:
|
||||||
if real_None(fig) is None:
|
if real_None(fig) is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user