Added preliminary hooke.plugin.vclamp.scale (just def. m -> N conversion).
authorW. Trevor King <wking@drexel.edu>
Wed, 19 May 2010 07:15:23 +0000 (03:15 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 19 May 2010 07:15:23 +0000 (03:15 -0400)
hooke/plugin/vclamp.py

index 2bc39d68fef0563268cdb865e099e60d759215cb..7374ab529ada89eb8b87e4c65a84034423ee7a93 100644 (file)
@@ -25,13 +25,28 @@ several associated :class:`hooke.command.Command`\s for handling
 common velocity clamp analysis tasks.
 """
 
+import copy
+
 from ..command import Command, Argument, Failure
+from ..curve import Data
 from ..plugin import Builtin
 
 
 # Utility functions
 
 def scale(curve):
+    for i,block in enumerate(curve.data):
+        data = Data((block.shape[0], block.shape[1]+2), dtype=block.dtype)
+        data.info = copy.deepcopy(block.info)
+        data[:,:-2] = block
+        data.info['columns'].extend(['surface z piezo (m)', 'deflection (N)'])
+        z_data = data[:,data.info['columns'].index('z piezo (m)')]
+        d_data = data[:,data.info['columns'].index('deflection (m)')]
+        surface_offset = 0 # TODO
+        data.info['surface offset (m)'] = surface_offset
+        data[:,-2] = z_data - surface_offset
+        data[:,-1] = d_data * data.info['spring constant (N/m)']
+        curve.data[i] = data
     return curve