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__(
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)
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