diff --git a/pylot/core/pick/picker.py b/pylot/core/pick/picker.py index 31ea86f8..a64c9dbc 100644 --- a/pylot/core/pick/picker.py +++ b/pylot/core/pick/picker.py @@ -201,6 +201,9 @@ class AICPicker(AutoPicker): if diffcf[i - 1] >= diffcf[i]: self.Pick = self.Tcf[i] break + if self.Pick is None: + raise ValueError + def calcPick(self): """ @@ -221,8 +224,12 @@ class AICPicker(AutoPicker): self.prepareCF() except ValueError: return + try: + self.findMinimum() + except ValueError: + print('Could not determine pick on AIC CF') + return - self.findMinimum() # quality assessment using SNR and slope from CF if self.Pick is not None: diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index c8c68ff7..88dbb667 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -1281,13 +1281,12 @@ def smooth_cf(cf, t_smooth, delta): if len(cf) < ismooth: raise ValueError - - for i, val in enumerate(cf): - if i <= ismooth: - cf_smooth[i] = np.mean(cf[0:i+1]) - elif i > ismooth: + for i in range(1, len(cf)): + if i > ismooth: ii1 = i - ismooth cf_smooth[i] = cf_smooth[i - 1] + (cf[i] - cf[ii1]) / ismooth + else: + cf_smooth[i] = np.mean(cf[1: i]) offset = abs(min(cf) - min(cf_smooth)) cf_smooth -= offset # remove offset from smoothed function return cf_smooth