Measuring distances and forces
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-You can easily zoom in the plot by dragging a rectangle on it with the
-left mouse button. To zoom out, click the right mouse
-button. Sometimes by zooming in and out too much, you can lose the
-picture (this is probably a small bug in Matplotlib). Just type
-``plot`` at the command line and the curve will be refreshed.
+You can move about the plot using its navigation toolbar. See the
+`Matplotlib manual`_ for details.
+
+.. _Matplotlib manual:
+ http://matplotlib.sourceforge.net/users/navigation_toolbar.html
You can measure distances and forces directly in the plot. Just issue
-the command ``distance``. You will be asked to click two points.
-When you click a point, a blue dot should appear. When you click the
-second point, the distances (in nanometers and piconewtons) will
-appear on the command line. You can use ``delta`` if you prefer,
-which gives meaningful values for every kind of graph (not only force
-curves). If you want to know the coordinates of a single point, use
-``point``.
+the command ``delta``. You will be asked to click two points. When
+you click a point, a blue dot should appear. When you click the
+second point, the distances will appear in the output panel. If you
+want to know the coordinates of a single point, left click on it.
Hooke automatically adjusts the position of the clicked point to the
nearest point in the graph, so you will be always measuring distances
and forces between points in the graph.
-The commands ``force`` and ``distance`` are present in the
-``generalvclamp`` plugin.
-
Worm like chain and freely jointed chain fitting
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
from ..plugin.playlist import current_playlist_callback
from ..util.calculus import derivative
from ..util.fft import unitary_avg_power_spectrum
+from ..util.si import ppSI, split_data_label
class CurvePlugin (Builtin):
def __init__(self):
super(CurvePlugin, self).__init__(name='curve')
self._commands = [
- GetCommand(self), InfoCommand(self), ExportCommand(self),
- DifferenceCommand(self), DerivativeCommand(self),
- PowerSpectrumCommand(self)]
+ GetCommand(self), InfoCommand(self), DeltaCommand(self),
+ ExportCommand(self), DifferenceCommand(self),
+ DerivativeCommand(self), PowerSpectrumCommand(self)]
# Define common or complicated arguments
def _get_block_sizes(self, curve):
return [block.shape for block in curve.data]
+
+class DeltaCommand (Command):
+ """Get distance information between two points.
+
+ With two points A and B, the returned distances are A-B.
+ """
+ def __init__(self, plugin):
+ super(DeltaCommand, self).__init__(
+ name='delta',
+ arguments=[
+ CurveArgument,
+ Argument(name='block', type='int', default=0,
+ help="""
+Data block that points are selected from. For an approach/retract
+force curve, `0` selects the approaching curve and `1` selects the
+retracting curve.
+""".strip()),
+ Argument(name='point', type='point', optional=False, count=2,
+ help="""
+Indicies of points bounding the selected data.
+""".strip()),
+ Argument(name='SI', type='bool', default=False,
+ help="""
+Return distances in SI notation.
+""".strip())
+ ],
+ help=self.__doc__, plugin=plugin)
+
+ def _run(self, hooke, inqueue, outqueue, params):
+ data = params['curve'].data[params['block']]
+ As = data[params['point'][0],:]
+ Bs = data[params['point'][1],:]
+ ds = [A-B for A,B in zip(As, Bs)]
+ if params['SI'] == False:
+ out = [(name, d) for name,d in zip(data.info['columns'], ds)]
+ else:
+ out = []
+ for name,d in zip(data.info['columns'], ds):
+ n,units = split_data_label(name)
+ out.append(
+ (n, ppSI(value=d, unit=units, decimals=2)))
+ outqueue.put(out)
+
+
class ExportCommand (Command):
"""Export a :class:`hooke.curve.Curve` data block as TAB-delimeted
ASCII text.