From 94834dec5952b43460565fd0f0bc805fda198123 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 11 Aug 2010 09:46:02 -0400 Subject: [PATCH] Add 'ignore index' argument to SurfaceContactCommand --- hooke/plugin/vclamp.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/hooke/plugin/vclamp.py b/hooke/plugin/vclamp.py index 5ffba75..48d55b3 100644 --- a/hooke/plugin/vclamp.py +++ b/hooke/plugin/vclamp.py @@ -139,7 +139,7 @@ class SurfacePositionModel (ModelFitter): 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()), @@ -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. +""".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)', @@ -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( - 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 @@ -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 - 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 @@ -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']) - 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 @@ -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. """ - 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. @@ -399,7 +404,7 @@ Name (without units) for storing fit parameters in the `.info` dictionary. 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 @@ -444,7 +449,7 @@ Name (without units) for storing fit parameters in the `.info` dictionary. 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 @@ -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) + 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 = { -- 2.26.2