[add] an exception if unable to find minimum in AIC cf

This commit is contained in:
Darius Arnold 2017-11-13 09:32:39 +01:00
parent 8f721da643
commit 16a8170e49
2 changed files with 12 additions and 6 deletions

View File

@ -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
# quality assessment using SNR and slope from CF
if self.Pick is not None:

View File

@ -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