[change] more readable indexing during slope determination

This commit is contained in:
Darius Arnold 2017-08-21 13:18:31 +02:00 committed by Marcel
parent 8ce9e40d49
commit afd03da178

View File

@ -258,7 +258,7 @@ class AICPicker(AutoPicker):
# calculate slope from initial onset to maximum of AIC function # calculate slope from initial onset to maximum of AIC function
print("AICPicker: Not enough data samples left for slope calculation!") print("AICPicker: Not enough data samples left for slope calculation!")
print("Calculating slope from initial onset to maximum of AIC function ...") print("Calculating slope from initial onset to maximum of AIC function ...")
imax = np.argmax(aicsmooth[islope[0][0]:islope[0][len(islope[0])-1]]) imax = np.argmax(aicsmooth[islope[0][0:-1]])
if imax == 0: if imax == 0:
print("AICPicker: Maximum for slope determination right at the beginning of the window!") print("AICPicker: Maximum for slope determination right at the beginning of the window!")
print("Choose longer slope determination window!") print("Choose longer slope determination window!")
@ -288,10 +288,10 @@ class AICPicker(AutoPicker):
xslope = np.arange(0, len(dataslope), 1) xslope = np.arange(0, len(dataslope), 1)
P = np.polyfit(xslope, dataslope, 1) P = np.polyfit(xslope, dataslope, 1)
datafit = np.polyval(P, xslope) datafit = np.polyval(P, xslope)
if datafit[0] >= datafit[len(datafit) - 1]: if datafit[0] >= datafit[-1]:
print('AICPicker: Negative slope, bad onset skipped!') print('AICPicker: Negative slope, bad onset skipped!')
return return
self.slope = 1 / (len(dataslope) * self.Data[0].stats.delta) * (datafit[len(dataslope) - 1] - datafit[0]) self.slope = 1 / (len(dataslope) * self.Data[0].stats.delta) * (datafit[-1] - datafit[0])
else: else:
self.SNR = None self.SNR = None