diff --git a/pylot/core/pick/picker.py b/pylot/core/pick/picker.py index af17acf6..b73819a1 100644 --- a/pylot/core/pick/picker.py +++ b/pylot/core/pick/picker.py @@ -326,14 +326,17 @@ class AICPicker(AutoPicker): dataslope = aicsmooth[pickindex: iaicmax] # calculate slope as polynomal fit of order 1 xslope = np.arange(0, len(dataslope), 1) - P = np.polyfit(xslope, dataslope, 1) - datafit = np.polyval(P, xslope) - if datafit[0] >= datafit[-1]: - print('AICPicker: Negative slope, bad onset skipped!') - else: - self.slope = 1 / (len(dataslope) * self.Data[0].stats.delta) * (datafit[-1] - datafit[0]) - # normalize slope to maximum of cf to make it unit independent - self.slope /= aicsmooth[iaicmax] + try: + P = np.polyfit(xslope, dataslope, 1) + datafit = np.polyval(P, xslope) + if datafit[0] >= datafit[-1]: + print('AICPicker: Negative slope, bad onset skipped!') + else: + self.slope = 1 / (len(dataslope) * self.Data[0].stats.delta) * (datafit[-1] - datafit[0]) + # normalize slope to maximum of cf to make it unit independent + self.slope /= aicsmooth[iaicmax] + except ValueError as e: + print("AICPicker: Problems with data fitting! {}".format(e)) else: self.SNR = None diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index 9929e5bb..29b35b59 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -270,8 +270,13 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=0, fig=None, linecolor='k'): islope1 = np.where((t >= Pick) & (t <= Pick + t[imax1])) # calculate slope as polynomal fit of order 1 xslope1 = np.arange(0, len(xraw[islope1]), 1) - P1 = np.polyfit(xslope1, xraw[islope1], 1) - datafit1 = np.polyval(P1, xslope1) + try: + P1 = np.polyfit(xslope1, xraw[islope1], 1) + datafit1 = np.polyval(P1, xslope1) + except ValueError as e: + print("fmpicker: Problems with data fit! {}".format(e)) + print("Skip first motion determination!") + return FM # now using filterd trace # next zero crossings after most likely pick