Ran update_copyright.py
[hooke.git] / hooke / driver / wtk.py
index c7387ffe1fdcc55388b986718b50074f373ca84e..893512076eafdd6d2f144e1620d75c58be7bcd7f 100644 (file)
@@ -2,21 +2,21 @@
 #
 # This file is part of Hooke.
 #
-# Hooke is free software: you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation, either
-# version 3 of the License, or (at your option) any later version.
+# Hooke is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
 #
-# Hooke is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Lesser General Public License for more details.
+# Hooke is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
+# Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public
 # License along with Hooke.  If not, see
 # <http://www.gnu.org/licenses/>.
 
-"""Hooke driver for W. Trevor King's velocity clamp data format.
+"""Driver for W. Trevor King's velocity clamp data format.
 
 See my related projects:
 
@@ -81,7 +81,7 @@ class WTKDriver (Driver):
                 return False
         return True
 
-    def read(self, path):
+    def read(self, path, info=None):
         approach_path,retract_path,param_path = self._paths(path)
 
         unlabeled_approach_data = numpy.loadtxt(
@@ -96,7 +96,7 @@ class WTKDriver (Driver):
             unlabeled_approach_data, params, 'approach')
         retract = self._scale_block(
             unlabeled_retract_data, params, 'retract')
-        info = {'filetype':'wtk', 'experiment':experiment.VelocityClamp}
+        info = {'filetype':self.name, 'experiment':experiment.VelocityClamp}
         return ([approach, retract], info)
 
     def _paths(self, path):
@@ -156,7 +156,7 @@ class WTKDriver (Driver):
         array in SI units.
         """
         ret = curve.Data(
-            shape=data.shape,
+            shape=(data.shape[0], 2),
             dtype=numpy.float,
             info=copy.deepcopy(info)
             )
@@ -185,7 +185,11 @@ class WTKDriver (Driver):
             * info['z piezo sensitivity (m/V)']
             )
 
-        ret[:,d_scol] = (
+        # Leading '-' because deflection voltage increases as the tip
+        # moves away from the surface, but it makes more sense to me
+        # to have it increase as it moves toward the surface (positive
+        # tension on the protein chain).
+        ret[:,d_scol] = -(
             (data[:,d_rcol]
              * info['deflection sensitivity (V/bit)']
              - info['deflection offset (V)'])
@@ -244,7 +248,7 @@ class WTKDriver (Driver):
             if self._calibfile_timestamp(calibfiles[i]) > timestamp:
                 i -= 1
                 break
-        return os.path.join(dir, calibfiles[i])
+        return calibfiles[i]
 
     def _read_cantilever_calibration_file(self, filename):
         ret = {'file': filename}