Add 'ignore index' argument to SurfaceContactCommand
authorW. Trevor King <wking@drexel.edu>
Wed, 11 Aug 2010 13:46:02 +0000 (09:46 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 11 Aug 2010 13:46:02 +0000 (09:46 -0400)
hooke/plugin/vclamp.py

index 5ffba75b5585c02e96d31260326782aeabfb25d8..48d55b3e6a6f1cbaa2135a9566884aa118a1d5f3 100644 (file)
@@ -139,7 +139,7 @@ class SurfacePositionModel (ModelFitter):
             self.info = {}
         for key,value in [
             ('force zero non-contact slope', False),
             self.info = {}
         for key,value in [
             ('force zero non-contact slope', False),
-            ('ignore non-contact before index', 6158),
+            ('ignore non-contact before index', -1),
             ('min position', 0),  # Store postions etc. to avoid recalculating.
             ('max position', len(data)),
             ('max deflection', data.max()),
             ('min position', 0),  # Store postions etc. to avoid recalculating.
             ('max position', len(data)),
             ('max deflection', data.max()),
@@ -257,6 +257,11 @@ class SurfaceContactCommand (Command):
 Data block for which the force should be calculated.  For an
 approach/retract force curve, `0` selects the approaching curve and `1`
 selects the retracting curve.
 Data block for which the force should be calculated.  For an
 approach/retract force curve, `0` selects the approaching curve and `1`
 selects the retracting curve.
+""".strip()),
+                Argument(name='ignore index', type='int', default=None,
+                         help="""
+Ignore the residual from the non-contact region before the indexed
+point (for the `wtk` algorithm).
 """.strip()),
                 Argument(name='input distance column', type='string',
                          default='z piezo (m)',
 """.strip()),
                 Argument(name='input distance column', type='string',
                          default='z piezo (m)',
@@ -317,7 +322,7 @@ Name (without units) for storing fit parameters in the `.info` dictionary.
         def_data = data[:,data.info['columns'].index(
                 params['input deflection column'])]
         i,def_offset,ps = self.find_contact_point(
         def_data = data[:,data.info['columns'].index(
                 params['input deflection column'])]
         i,def_offset,ps = self.find_contact_point(
-            params['curve'], dist_data, def_data, outqueue)
+            params, dist_data, def_data, outqueue)
         dist_offset = dist_data[i]
         new.info[join_data_label(params['distance info name'], dist_units
                                  )] = dist_offset
         dist_offset = dist_data[i]
         new.info[join_data_label(params['distance info name'], dist_units
                                  )] = dist_offset
@@ -328,7 +333,7 @@ Name (without units) for storing fit parameters in the `.info` dictionary.
         new[:,-1] = def_data - def_offset
         params['curve'].data[params['block']] = new
 
         new[:,-1] = def_data - def_offset
         params['curve'].data[params['block']] = new
 
-    def find_contact_point(self, curve, z_data, d_data, outqueue=None):
+    def find_contact_point(self, params, z_data, d_data, outqueue=None):
         """Railyard for the `find_contact_point_*` family.
 
         Uses the `surface contact point algorithm` configuration
         """Railyard for the `find_contact_point_*` family.
 
         Uses the `surface contact point algorithm` configuration
@@ -336,9 +341,9 @@ Name (without units) for storing fit parameters in the `.info` dictionary.
         """
         fn = getattr(self, 'find_contact_point_%s'
                      % self.plugin.config['surface contact point algorithm'])
         """
         fn = getattr(self, 'find_contact_point_%s'
                      % self.plugin.config['surface contact point algorithm'])
-        return fn(curve, z_data, d_data, outqueue)
+        return fn(params, z_data, d_data, outqueue)
 
 
-    def find_contact_point_fmms(self, curve, z_data, d_data, outqueue=None):
+    def find_contact_point_fmms(self, params, z_data, d_data, outqueue=None):
         """Algorithm by Francesco Musiani and Massimo Sandal.
 
         Notes
         """Algorithm by Francesco Musiani and Massimo Sandal.
 
         Notes
@@ -358,7 +363,7 @@ Name (without units) for storing fit parameters in the `.info` dictionary.
         curve, until you find a point with greater than baseline
         deflection.  That point is the contact point.
         """
         curve, until you find a point with greater than baseline
         deflection.  That point is the contact point.
         """
-        if curve.info['filetype'] == 'picoforce':
+        if params['curve'].info['filetype'] == 'picoforce':
             # Take care of the picoforce trigger bug (TODO: example
             # data file demonstrating the bug).  We exclude portions
             # of the curve that have too much standard deviation.
             # Take care of the picoforce trigger bug (TODO: example
             # data file demonstrating the bug).  We exclude portions
             # of the curve that have too much standard deviation.
@@ -399,7 +404,7 @@ Name (without units) for storing fit parameters in the `.info` dictionary.
             i += 1
         return (i, d_baseline, {})
 
             i += 1
         return (i, d_baseline, {})
 
-    def find_contact_point_ms(self, curve, z_data, d_data, outqueue=None):
+    def find_contact_point_ms(self, params, z_data, d_data, outqueue=None):
         """Algorithm by Massimo Sandal.
 
         Notes
         """Algorithm by Massimo Sandal.
 
         Notes
@@ -444,7 +449,7 @@ Name (without units) for storing fit parameters in the `.info` dictionary.
         else:
             return dummy.index
 
         else:
             return dummy.index
 
-    def find_contact_point_wtk(self, curve, z_data, d_data, outqueue=None):
+    def find_contact_point_wtk(self, params, z_data, d_data, outqueue=None):
         """Algorithm by W. Trevor King.
 
         Notes
         """Algorithm by W. Trevor King.
 
         Notes
@@ -457,6 +462,8 @@ Name (without units) for storing fit parameters in the `.info` dictionary.
         s = SurfacePositionModel(d_data, info={
                 'force zero non-contact slope':True},
                                  rescale=True)
         s = SurfacePositionModel(d_data, info={
                 'force zero non-contact slope':True},
                                  rescale=True)
+        if params['ignore index'] != None:
+            s.info['ignore non-contact before index'] = params['ignore index']
         offset,contact_slope,surface_index,non_contact_slope = s.fit(
             outqueue=outqueue)
         info = {
         offset,contact_slope,surface_index,non_contact_slope = s.fit(
             outqueue=outqueue)
         info = {