Removed old references to freq in calibrate.py after freq->push_speed change.
[calibcant.git] / calibcant / calibrate.py
index 10622f49b8a3df44035e1ff489cb65bdbf3c40a0..379c2b7220489e96f04624a9090120e09b8dfc7d 100755 (executable)
@@ -119,17 +119,19 @@ import analyze
 # bump family
 
 @splittableKwargsFunction()
-def bump_aquire(zpiezo, push_depth=200, npoints=1024, freq=100e3) :
+def bump_aquire(zpiezo, push_depth=200, npoints=1024, push_speed=1000) :
     """
     Ramps closer push_depth and returns to the original position.
     Inputs:
      zpiezo     an opened zpiezo.zpiezo instance
      push_depth distance to approach, in nm
      npoints    number points during the approach and during the retreat
-     freq       rate at which data is aquired
+     push_speed piezo speed during approach and retreat, in nm/s
     Returns the aquired ramp data dictionary, with data in DAC/ADC bits.
     """
     # generate the bump output
+    nm_per_step = float(push_depth) / npoints
+    freq = push_speed / nm_per_step # freq is sample frequency in Hz
     start_pos = zpiezo.curPos()
     pos_dist = zpiezo.pos_nm2out(push_depth) - zpiezo.pos_nm2out(0)
     close_pos = start_pos + pos_dist
@@ -138,7 +140,7 @@ def bump_aquire(zpiezo, push_depth=200, npoints=1024, freq=100e3) :
     out = numpy.concatenate((appr, retr))
     # run the bump, and measure deflection
     if config.TEXT_VERBOSE :
-        print "Bump %g nm" % push_depth
+        print "Bump %g nm at %g nm/s" % (push_depth, push_speed)
     data = zpiezo.ramp(out, freq)
     return data
 
@@ -228,13 +230,14 @@ def vib(**kwargs) :
 # with proper spacing relative to the surface.
 
 @splittableKwargsFunction()
-def move_just_onto_surface(stepper, zpiezo, Depth_nm=100, setpoint=2) :
+def move_just_onto_surface(stepper, zpiezo, Depth_nm=-50, setpoint=2) :
     """
-    Uses z_piezo_utils.getSurfPos() to pinpoint the position of the surface.
-    Adjusts the stepper position as required to get within stepper_tol nm
-    of the surface.
-    Then set Vzp to place the cantilever Depth_nm onto the surface.
-
+    Uses z_piezo_utils.getSurfPos() to pinpoint the position of the
+    surface.  Adjusts the stepper position as required to get within
+    stepper_tol nm of the surface.  Then set Vzp to place the
+    cantilever Depth_nm onto the surface.  Negative Depth_nm values
+    will place the cantilever that many nm _off_ the surface.
+    
     If getSurfPos() fails to find the surface, backs off (for safety)
     and steps in (without moving the zpiezo) until Vphoto > setpoint.
     """
@@ -331,13 +334,12 @@ def move_far_from_surface(stepper, um_back=50) :
 # and finally, the calib family
 
 @splittableKwargsFunction((move_just_onto_surface, 'stepper', 'zpiezo'),
-                          (bump, 'zpiezo', 'freq', 'log_dir', 'Vphoto_in2V'),
+                          (bump, 'zpiezo', 'log_dir', 'Vphoto_in2V'),
                           (move_far_from_surface, 'stepper'),
                           (T, 'log_dir'),
                           (vib, 'zpiezo', 'log_dir', 'Vphoto_in2V'),
                           (analyze.calib_save, 'bumps','Ts','vibs','log_dir'))
 def calib_aquire(stepper, zpiezo, num_bumps=10, num_Ts=10, num_vibs=20,
-                 bump_freq=100e3,
                  log_dir=config.LOG_DIR, Vphoto_in2V=config.Vphoto_in2V,
                  **kwargs):
     """
@@ -364,7 +366,7 @@ def calib_aquire(stepper, zpiezo, num_bumps=10, num_Ts=10, num_vibs=20,
     move_just_onto_surface(stepper, zpiezo, **move_just_onto_surface_kwargs)
     bumps = numpy.zeros((num_bumps,), dtype=numpy.float)
     for i in range(num_bumps) :
-        bumps[i] = bump(zpiezo=zpiezo, freq=bump_freq, log_dir=log_dir,
+        bumps[i] = bump(zpiezo=zpiezo, log_dir=log_dir,
                         Vphoto_in2V=Vphoto_in2V, **bump_kwargs)
     if config.TEXT_VERBOSE :
         print bumps