From 2960e6fc398633fdd00c2371a2d5f0518836dccb Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 8 Aug 2010 16:37:53 -0400 Subject: [PATCH] Update CantileverAdjustedExtensionCommand to use flexible column names. --- hooke/plugin/vclamp.py | 45 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/hooke/plugin/vclamp.py b/hooke/plugin/vclamp.py index 617f09d..de5bff7 100644 --- a/hooke/plugin/vclamp.py +++ b/hooke/plugin/vclamp.py @@ -514,10 +514,7 @@ Name of the spring constant in the `.info` dictionary. class CantileverAdjustedExtensionCommand (Command): - """Calculate a block's `cantilever adjusted extension (m)` array. - - Uses the block's `deflection (m)` and `surface distance offset (m)` - arrays and `spring constant (N/m)`. + """Remove cantilever extension from a total extension column. """ def __init__(self, plugin): super(CantileverAdjustedExtensionCommand, self).__init__( @@ -529,6 +526,26 @@ class CantileverAdjustedExtensionCommand (Command): Data block for which the adjusted extension 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='surface distance (m)', + help=""" +Name of the column to use as the distance input. +""".strip()), + Argument(name='input deflection column', type='string', + default='deflection (N)', + help=""" +Name of the column to use as the deflection input. +""".strip()), + Argument(name='output distance column', type='string', + default='cantilever adjusted extension', + help=""" +Name of the column (without units) to use as the deflection output. +""".strip()), + Argument(name='spring constant info name', type='string', + default='spring constant (N/m)', + help=""" +Name of the spring constant in the `.info` dictionary. """.strip()), ], help=self.__doc__, plugin=plugin) @@ -543,10 +560,22 @@ an approach/retract force curve, `0` selects the approaching curve and new = Data((data.shape[0], data.shape[1]+1), dtype=data.dtype) new.info = copy.deepcopy(data.info) new[:,:-1] = data - new.info['columns'].append('cantilever adjusted extension (m)') - z_data = data[:,data.info['columns'].index('surface distance (m)')] - d_data = data[:,data.info['columns'].index('deflection (N)')] - new[:,-1] = z_data - d_data / data.info['spring constant (N/m)'] + new.info['columns'].append( + join_data_label(params['output distance column'], 'm')) + z_data = data[:,data.info['columns'].index( + params['input distance column'])] + d_data = data[:,data.info['columns'].index( + params['input deflection column'])] + k = data.info[params['spring constant info name']] + + z_name,z_unit = split_data_label(params['input distance column']) + assert z_unit == 'm', params['input distance column'] + d_name,d_unit = split_data_label(params['input deflection column']) + assert d_unit == 'N', params['input deflection column'] + k_name,k_unit = split_data_label(params['spring constant info name']) + assert k_unit == 'N/m', params['spring constant info name'] + + new[:,-1] = z_data - d_data / k params['curve'].data[params['block']] = new -- 2.26.2