Change checksignallength so it extracts the required parameters

from the PylotParameter instance itself. The function is only used in one place, so this change wont break anything else.
This commit is contained in:
Darius Arnold 2019-04-09 16:57:37 +02:00
parent 8a4be00ac6
commit c45f52510b
2 changed files with 17 additions and 9 deletions

View File

@ -786,8 +786,7 @@ class AutopickStation(object):
zne += trH1_filt zne += trH1_filt
zne += trH2_filt zne += trH2_filt
minsiglength = self.signal_length_params.minsiglength minsiglength = self.signal_length_params.minsiglength
Pflag = checksignallength(zne, aicpick.getpick(), self.p_params.tsnrz, minsiglength, Pflag = checksignallength(zne, aicpick.getpick(), minsiglength, self.pickparams,
self.signal_length_params.noisefactor, self.signal_length_params.minpercent,
self.iplot, self.current_figure, self.current_linecolor) self.iplot, self.current_figure, self.current_linecolor)
if Pflag == 0: if Pflag == 0:
self.p_results.marked = 'shortsignallength' self.p_results.marked = 'shortsignallength'

View File

@ -757,7 +757,7 @@ def RMS(X):
return np.sqrt(np.sum(np.power(X, 2)) / len(X)) return np.sqrt(np.sum(np.power(X, 2)) / len(X))
def checksignallength(X, pick, TSNR, minsiglength, nfac, minpercent, iplot=0, fig=None, linecolor='k'): def checksignallength(X, pick, minsiglength, pickparams, iplot=0, fig=None, linecolor='k'):
""" """
Function to detect spuriously picked noise peaks. Function to detect spuriously picked noise peaks.
@ -768,14 +768,10 @@ def checksignallength(X, pick, TSNR, minsiglength, nfac, minpercent, iplot=0, fi
:type X: `~obspy.core.stream.Stream` :type X: `~obspy.core.stream.Stream`
:param pick: initial (AIC) P onset time :param pick: initial (AIC) P onset time
:type pick: float :type pick: float
:param TSNR: length of time windows around initial pick [s]
:type TSNR: (T_noise, T_gap, T_signal)
:param minsiglength: minium required signal length [s] to declare pick as P onset :param minsiglength: minium required signal length [s] to declare pick as P onset
:type minsiglength: float :type minsiglength: float
:param nfac: noise factor (nfac * noise level = threshold) :param pickparams: PylotParameter instance that holds the current picker settings loaded from a .in file
:type nfac: float :type pickparams: PylotParameter
:param minpercent: minimum required percentage of samples above calculated threshold
:type minpercent: float
:param iplot: iplot, if iplot > 1, results are shown in figure :param iplot: iplot, if iplot > 1, results are shown in figure
:type iplot: int :type iplot: int
:param fig: Matplotlib figure to plot results in :param fig: Matplotlib figure to plot results in
@ -787,6 +783,19 @@ def checksignallength(X, pick, TSNR, minsiglength, nfac, minpercent, iplot=0, fi
:rtype: int :rtype: int
""" """
"""
Extract additional parameters from pickparams
:param TSNR: length of time windows around initial pick [s]
:type TSNR: (T_noise, T_gap, T_signal)
:param nfac: noise factor (nfac * noise level = threshold)
:type nfac: float
:param minpercent: minimum required percentage of samples above calculated threshold
:type minpercent: float
"""
TSNR = pickparams["tsnrz"]
nfac = pickparams["noisefactor"]
minpercent = pickparams["minpercent"]
plt_flag = 0 plt_flag = 0
try: try:
iplot = int(iplot) iplot = int(iplot)