From: W. Trevor King Date: Sat, 7 Aug 2010 21:37:41 +0000 (-0400) Subject: Update SurfaceContactCommand to use flexible column/info names. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d396dd234bf97b6159ce0afcc816874c781b6659;p=hooke.git Update SurfaceContactCommand to use flexible column/info names. --- diff --git a/hooke/plugin/vclamp.py b/hooke/plugin/vclamp.py index 21f078a..40c1ecb 100644 --- a/hooke/plugin/vclamp.py +++ b/hooke/plugin/vclamp.py @@ -35,6 +35,7 @@ from ..config import Setting from ..curve import Data from ..plugin import Plugin from ..util.fit import PoorFit, ModelFitter +from ..util.si import join_data_label, split_data_label from .curve import CurveArgument @@ -75,7 +76,7 @@ def scale(hooke, curve, block=None): return curve class SurfacePositionModel (ModelFitter): - """ + """Bilinear surface position model. The bilinear model is symmetric, but the parameter guessing and sanity checks assume the contact region occurs for lower indicies @@ -96,9 +97,6 @@ class SurfacePositionModel (ModelFitter): should be enough data in the off-surface region that interactions due to proteins, etc. will not seriously skew the fit in the off-surface region. - - - We guess """ def model(self, params): """A continuous, bilinear model. @@ -168,7 +166,6 @@ class SurfacePositionModel (ModelFitter): Notes ----- - We guess offset scale (:math:`p_0`) as one tenth of the total deflection range, the kink scale (:math:`p_2`) as one tenth of the total index range, the initial (contact) slope scale @@ -234,14 +231,6 @@ class VelocityClampPlugin (Plugin): class SurfaceContactCommand (Command): """Automatically determine a block's surface contact point. - Uses the block's `z piezo (m)` and `deflection (m)` arrays. - Stores the contact parameters in `block.info`'s `surface distance - offset (m)` and `surface deflection offset (m)`. Model-specific - fitting information is stored in `surface detection parameters`. - - The adjusted data columns `surface distance (m)` and `surface - adjusted deflection (m)` are also added to the block. - You can select the contact point algorithm with the creatively named `surface contact point algorithm` configuration setting. Currently available options are: @@ -260,6 +249,41 @@ 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='input distance column', type='string', + default='z piezo (m)', + help=""" +Name of the column to use as the surface positioning input. +""".strip()), + Argument(name='input deflection column', type='string', + default='deflection (m)', + help=""" +Name of the column to use as the deflection input. +""".strip()), + Argument(name='output distance column', type='string', + default='surface distance', + help=""" +Name of the column (without units) to use as the surface positioning output. +""".strip()), + Argument(name='output deflection column', type='string', + default='surface deflection', + help=""" +Name of the column (without units) to use as the deflection output. +""".strip()), + Argument(name='distance info name', type='string', + default='surface distance offset', + help=""" +Name of the column (without units) for storing the distance offset in the `.info` dictionary. +""".strip()), + Argument(name='deflection info name', type='string', + default='surface deflection offset', + help=""" +Name of the column (without units) for storing the deflection offset in the `.info` dictionary. +""".strip()), + Argument(name='fit parameters info name', type='string', + default='surface deflection offset', + help=""" +Name of the column (without units) for storing the deflection offset in the `.info` dictionary. """.strip()), ], help=self.__doc__, plugin=plugin) @@ -274,18 +298,26 @@ selects the retracting curve. new = Data((data.shape[0], data.shape[1]+2), dtype=data.dtype) new.info = copy.deepcopy(data.info) new[:,:-2] = data - new.info['columns'].extend( - ['surface distance (m)', 'surface adjusted deflection (m)']) - z_data = data[:,data.info['columns'].index('z piezo (m)')] - d_data = data[:,data.info['columns'].index('deflection (m)')] - i,deflection_offset,ps = self.find_contact_point( - params['curve'], z_data, d_data, outqueue) - surface_offset = z_data[i] - new.info['surface distance offset (m)'] = surface_offset - new.info['surface deflection offset (m)'] = deflection_offset - new.info['surface detection parameters'] = ps - new[:,-2] = z_data - surface_offset - new[:,-1] = d_data - deflection_offset + name,dist_units = split_data_label(params['input distance column']) + name,def_units = split_data_label(params['input deflection column']) + new.info['columns'].extend([ + join_data_label(params['output distance column'], dist_units), + join_data_label(params['output deflection column'], def_units), + ]) + dist_data = data[:,data.info['columns'].index( + params['input distance column'])] + 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) + dist_offset = dist_data[i] + new.info[join_data_label(params['distance info name'], dist_units + )] = dist_offset + new.info[join_data_label(params['deflection info name'], def_units + )] = def_offset + new.info[params['fit parameters info name']] = ps + new[:,-2] = dist_data - dist_offset + new[:,-1] = def_data - def_offset params['curve'].data[params['block']] = new def find_contact_point(self, curve, z_data, d_data, outqueue=None): diff --git a/hooke/util/si.py b/hooke/util/si.py index 6108b9f..48fe4e0 100644 --- a/hooke/util/si.py +++ b/hooke/util/si.py @@ -166,8 +166,28 @@ def prefix_from_value(value): """ return PREFIX[get_power(value)] +def join_data_label(name, unit): + """Create laels for `curve.data[i].info['columns']`. + + See Also + -------- + split_data_label + + Examples + -------- + >>> join_data_label('z piezo', 'm') + 'z piezo (m)' + >>> join_data_label('deflection', 'N') + 'deflection N' + """ + return '%s (%s)' % (name, unit) + def split_data_label(label): - """Split `curve.data[i].info['name']` labels into `(name, unit)`. + """Split `curve.data[i].info['columns']` labels into `(name, unit)`. + + See Also + -------- + join_data_label Examples --------