Oops, forgot to convert 'z piezo gain' to a float in the picoforce driver
[hooke.git] / hooke / driver / picoforce.py
index c1c914336ce9c0bc3935c8a56f6ccbeece7d0766..c1139d6f5353fb1c71de954b8a78be0092ccf13d 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2010 Alberto Gomez-Kasai
+# Copyright (C) 2006-2010 Alberto Gomez-Casado
 #                         Massimo Sandal <devicerandom@gmail.com>
 #                         W. Trevor King <wking@drexel.edu>
 #
@@ -183,7 +183,7 @@ class PicoForceDriver (Driver):
 
     def _extract_traces(self, buffer, info):
         """Extract each of the three vector blocks in a PicoForce file.
-        
+
         The blocks are:
 
         * Deflection input
@@ -192,7 +192,7 @@ class PicoForceDriver (Driver):
 
         And their headers are marked with 'Ciao force image list'.
         """
-        traces = [] 
+        traces = []
         for image in info['Ciao force image list']:
             offset = int(image['Data offset'])
             length = int(image['Data length'])
@@ -241,7 +241,7 @@ class PicoForceDriver (Driver):
             'raw info':info,
             'raw z piezo info': z_piezo_info,
             'raw deflection info': deflection_info,
-            'spring constant (N/m)':float(z_piezo_info['Spring Constant'])
+            'spring constant (N/m)':float(z_piezo_info['Spring Constant']),
             }
 
         t = info['Force file list']['Date'] # 04:42:34 PM Tue Sep 11 2007
@@ -261,7 +261,7 @@ class PicoForceDriver (Driver):
         ret['columns'] = ['z piezo (m)', 'deflection (m)']
 
         volt_re = re.compile(
-            'V \[Sens. (\w*)\] \(([.0-9]*) V/LSB\) ([.0-9]*) V')
+            'V \[Sens. (\w*)\] \(([.0-9]*) V/LSB\) (-?[.0-9]*) V')
         match = volt_re.match(z_piezo_info['@4:Z scale'])
         assert match.group(1) == 'ZSensorSens', z_piezo_info['@4:Z scale']
         ret['z piezo sensitivity (V/bit)'] = float(match.group(2))
@@ -293,12 +293,12 @@ class PicoForceDriver (Driver):
         const_re = re.compile('C \[([:\w\s]*)\] ([.0-9]*)')
         match = const_re.match(z_piezo_info['@Z magnify'])
         assert match.group(1) == '4:Z scale', match.group(1)
-        ret['z piezo magnification'] = match.group(2)
+        ret['z piezo gain'] = float(match.group(2))
 
         match = volt_re.match(z_piezo_info['@4:Z scale'])
         assert match.group(1) == 'ZSensorSens', match.group(1)
-        ret['z piezo scale (V/bit)'] = float(match.group(2))
-        ret['z piezo scale (V)'] = float(match.group(3))
+        ret['z piezo sensitivity (V/bit)'] = float(match.group(2))
+        ret['z piezo range (V)'] = float(match.group(3))
 
         match = volt_re.match(z_piezo_info['@4:Ramp size'])
         assert match.group(1) == 'Zsens', match.group(1)
@@ -309,10 +309,10 @@ class PicoForceDriver (Driver):
         assert match.group(1) == 'Zsens', match.group(1)
         ret['z piezo ramp offset (V/bit)'] = float(match.group(2))
         ret['z piezo ramp offset (V)'] = float(match.group(3))
-        
+
         # Unaccounted for:
         #   Samps*
-        
+
         return ret
 
     def _scale_block(self, data):
@@ -325,7 +325,7 @@ class PicoForceDriver (Driver):
             )
         info = data.info
         ret.info = info
-        ret.info['raw-data'] = data # store the raw data
+        ret.info['raw data'] = data # store the raw data
         data.info = {} # break circular reference info <-> data
 
         z_col = info['columns'].index('z piezo (m)')
@@ -333,12 +333,13 @@ class PicoForceDriver (Driver):
 
         # Leading '-' because Veeco's z increases towards the surface
         # (positive indentation), but it makes more sense to me to
-        # have it inzrease away from the surface (positive
+        # have it increase away from the surface (positive
         # separation).
         ret[:,z_col] = -(
             (data[:,z_col].astype(ret.dtype)
              * info['z piezo sensitivity (V/bit)']
              - info['z piezo offset (V)'])
+            * info['z piezo gain']
             * info['z piezo sensitivity (m/V)']
             )
 
@@ -350,4 +351,3 @@ class PicoForceDriver (Driver):
             )
 
         return ret
-