From 11f61de536c292dabd54f076d941e0cee4e919c7 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 8 Aug 2010 16:17:28 -0400 Subject: [PATCH] Update ForceCommand to use flexible column names. --- hooke/plugin/vclamp.py | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/hooke/plugin/vclamp.py b/hooke/plugin/vclamp.py index 90acc97..617f09d 100644 --- a/hooke/plugin/vclamp.py +++ b/hooke/plugin/vclamp.py @@ -63,7 +63,7 @@ def scale(hooke, curve, block=None): params = {'curve':curve, 'block':block} b = curve.data[block] if ('surface distance (m)' not in b.info['columns'] - or 'surface adjusted deflection (m)' not in b.info['columns']): + or 'surface deflection (m)' not in b.info['columns']): try: contact.run(hooke, inqueue, outqueue, **params) except PoorFit, e: @@ -273,17 +273,17 @@ Name of the column (without units) to use as the deflection output. 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. +Name (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. +Name (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. +Name (without units) for storing the deflection offset in the `.info` dictionary. """.strip()), ], help=self.__doc__, plugin=plugin) @@ -462,11 +462,9 @@ Name of the column (without units) for storing the deflection offset in the `.in surface_index = len(d_data)-1-surface_index return (numpy.round(surface_index), deflection_offset, info) -class ForceCommand (Command): - """Calculate a block's `deflection (N)` array. - Uses the block's `deflection (m)` array and - `spring constant (N/m)`. +class ForceCommand (Command): + """Convert a deflection column from meters to newtons. """ def __init__(self, plugin): super(ForceCommand, self).__init__( @@ -478,6 +476,21 @@ class ForceCommand (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 deflection column', type='string', + default='surface deflection (m)', + help=""" +Name of the column to use as the deflection input. +""".strip()), + Argument(name='output deflection column', type='string', + default='deflection', + 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) @@ -492,9 +505,11 @@ selects the retracting curve. 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('deflection (N)') - d_data = data[:,data.info['columns'].index('surface adjusted deflection (m)')] - new[:,-1] = d_data * data.info['spring constant (N/m)'] + new.info['columns'].append( + join_data_label(params['output deflection column'], 'N')) + d_data = data[:,data.info['columns'].index( + params['input deflection column'])] + new[:,-1] = d_data * data.info[params['spring constant info name']] params['curve'].data[params['block']] = new -- 2.26.2