middle_deflection = (self.info['min deflection']
+ self.info['deflection range']/2.)
kink_position = 2*(self._data > middle_deflection).argmax()
- left_slope = ((self._data[-1] - self.info['min deflection'])
- /kink_position)
+ if kink_position == 0:
+ # jump vibration at the start of the retraction?
+ start = int(min(max(20, 0.01 * len(self._data)), 0.5*len(self._data)))
+ std = self._data[:start].std()
+ left_offset = self._data[start].mean()
+ stop = start
+ while abs(self._data[stop] - left_offset) < 3*std:
+ stop += 1
+ left_slope = (self._data[stop-start:stop].mean()
+ - left_offset) / (stop-start)
+ left_offset -= left_slope * start/2
+ kink_position = (self._data[-1] - left_offset)/left_slope
+ else:
+ left_slope = (self._data[-1] - self.info['min deflection']
+ )/kink_position
right_slope = 0
self.info['guessed contact slope'] = left_slope
params = [left_offset, left_slope, kink_position, right_slope]