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
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
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.
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
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:
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)
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):