Double initial guess for the surface kink position.
authorW. Trevor King <wking@drexel.edu>
Fri, 27 Aug 2010 21:31:39 +0000 (17:31 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 27 Aug 2010 21:31:39 +0000 (17:31 -0400)
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:
    _______
   /
  /

hooke/plugin/vclamp.py
hooke/util/fit.py

index 0cfad0def3bef641e9022afd56a8db13cf840b2a..88306ff44ededee715b174438cd18da374e46356 100644 (file)
@@ -165,7 +165,7 @@ Minimum `fit-contact-slope/guessed-contact-slope` ratio for a "good" fit.
         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
index 13606773be4417a02d9384b7ff0bfee0648929e6..6d2e30333ac4e48c2729211c738cc73e099b7e06 100644 (file)
@@ -187,6 +187,12 @@ class ModelFitter (object):
         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