Add Piezo.zero().
authorW. Trevor King <wking@drexel.edu>
Mon, 26 Mar 2012 18:00:36 +0000 (14:00 -0400)
committerW. Trevor King <wking@drexel.edu>
Mon, 26 Mar 2012 18:28:16 +0000 (14:28 -0400)
pypiezo/afm.py
pypiezo/base.py

index a7cb9d5e3ff227216ef75a133d299c80d4b003b6..402ac182be6f837aee633d567550503bce0c6534 100644 (file)
@@ -81,9 +81,8 @@ class AFMPiezo (_base.Piezo):
     We need to know where we are before we can move somewhere
     smoothly.
 
-    >>> pos = _base.convert_volts_to_bits(p.config.select_config(
-    ...     'axes', 'z', get_attribute=_base.get_axis_name)['channel'], 0)
-    >>> p.jump('z', pos)
+    >>> zeros = p.zero(axis_names=['z'])
+    >>> pos = zeros[0]
 
     Usually `.move_to_pos_or_def` is used to approach the surface, but
     for testing we assume the z output channel is connected directly
index 6f9eefc9e172e94aa703166745e61f157cf181da..25461c717675b0df8b9348dc0dd4eba06e52d9ab 100644 (file)
@@ -912,3 +912,16 @@ class Piezo (object):
         for i,name in enumerate(input_names):
             ret[name] = input_data[:,i]
         return ret
+
+    def zero(self, axis_names=None, **kwargs):
+        zeros = []
+        if axis_names is None:
+            axis_names = [axis.name for axis in self.axes]
+        for axis_name in axis_names:
+            axis = self.axis_by_name(axis_name)
+            config = self.config.select_config(
+                'axes', axis_name, get_attribute=get_axis_name)['channel']
+            zero = convert_volts_to_bits(config, 0)
+            zeros.append(zero)
+            self.jump(axis_name, zero)
+        return zeros