The previous algorithm would fail for curves if
1) They didn't have many tension features to stretch out the range.
2) The contact slope "softened" a bit in the kink region.
For example, try it on most of the test/vclamp_picoforce data ;).
The new algorithm works perfectly on the ideal, boring curve:
_______
/
/
left_offset = self.info['min deflection']
middle_deflection = (self.info['min deflection']
+ self.info['deflection range']/2.)
- kink_position = (self._data > middle_deflection).argmax()
+ kink_position = 2*(self._data > middle_deflection).argmax()
left_slope = ((self._data[-1] - self.info['min deflection'])
/kink_position)
right_slope = 0
if self._rescale == True:
params = [p*s for p,s in zip(params, self._param_scale_factors)]
residual = self._data - self.model(params)
+ if False: # fit debugging
+ if not hasattr(self, '_i_'):
+ self._i_ = 0
+ self._data.tofile('data.%d' % self._i_, sep='\n')
+ self.model(params).tofile('model.%d' % self._i_, sep='\n')
+ self._i_ += 1
if self._rescale == True:
residual /= self._data_scale_factor
return residual