Fixups in hooke.plugin.vclamp parameter guess and check.
authorW. Trevor King <wking@drexel.edu>
Wed, 2 Jun 2010 05:25:52 +0000 (01:25 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 2 Jun 2010 05:25:52 +0000 (01:25 -0400)
* guessing adjusted for +deflection for +tension.
* checking adjusted for left-contact and possibly negative slopes.
* added details to 'Too far' version of PoorFit.

hooke/plugin/vclamp.py

index 2ab03727a7376387081c9c5d37a4d771ff90dd6f..b83d5de9cfda2e872c0bc3f8c2d757bfdf1cb3a0 100644 (file)
@@ -126,9 +126,9 @@ class SurfacePositionModel (ModelFitter):
         produces the maximum deflection at the left-most point, and the
         final (non-contact) slope (:math:`p_3`) is zero.
         """
-        left_offset = self.info['max deflection']
-        left_slope = 2*(-self.info['deflection range']
-                         /self.info['position range'])
+        left_offset = self.info['min deflection']
+        left_slope = 2*(self.info['deflection range']
+                        /self.info['position range'])
         kink_position = (self.info['max position']
                          +self.info['min position'])/2.0
         right_slope = 0
@@ -182,8 +182,9 @@ class SurfacePositionModel (ModelFitter):
                 % (params[2],
                    self.info['max position']-0.02*self.info['position range']))
         if (self.info['guessed contact slope'] != None
-            and params[3] < 0.5 * self.info['guessed contact slope']):
-            raise PoorFit('Too far')
+            and abs(params[1]) < 0.5 * abs(self.info['guessed contact slope'])):
+            raise PoorFit('Too far (contact slope %g, but expected ~%g'
+                          % (params[3], self.info['guessed contact slope']))
         return params
 
 class VelocityClampPlugin (Builtin):