#!/bin/csh -f #+ # focusloop -- acquire images over a range of internal focus positions # # Purpose: # Given a starting internal focus value, acquire a series of # images while changing the internal focus value. # # Usage: # focusloop [start [ [incr]]] # # Arguments: # start = starting secondary position [microns] (default=-3250) # n = number of images to acquire (default=7, max=100) # incr = increment in focus [microns] (default=-1000) # # Output: # # Restrictions: # # Exit values: # 0 = normal completion # 1 = wrong number of arguments # 3 = start and/or incr are not valid floats # 4 = n too large # # Example: # 1) Acquire a series of 7 focus frames starting at -3250 # at -1000 micron increments # focusloop # # 2) Acquire a series of 11 focus frames starting at -7000 # at 100 micron increments # focusloop -7000 11 100 #- # Modification history: # Date unknown RWG Original version # 2000-Jul-11 GDW Added documentation # 2000-Oct-09 GDW Updated documentation # 2002-Jun-06 GDW Adapted for DEIMOS # 2002-Aug-14 GDW Removed backlash compensation # (already in DEIMOS motor control software) #----------------------------------------------------------------------- # extract command name... set buf = $0 set cmd = $buf:t # define defaults... set usage = "Usage: $cmd [start [n [incr]]]" set incr = -1000 @ start = -3250 @ n = 7 @ n_max = 100 # verify args... if ( $#argv > 3 ) then echo "$usage" exit 1 endif # grab arguments... if ( $#argv >= 1) then set start = $1 shift endif if ( $#argv >= 1 ) then set n = $1 shift endif if ( $#argv >= 1 ) then set incr = $1 shift endif # validate args... is_float $start $incr > /dev/null if ( $status ) then echo "ERROR -- start and/or incr are not valid floats" exit 3 endif if ( $n > $n_max ) then echo "ERROR --- n too large (max is $n_max)" exit 4 endif # trap CTRL-C... onintr quit set old_focus = `focus` # acquire data... @ i = 0 while ( $i < $n ) # compute new secondary position... set focus = `calc "$start + $i*$incr"` # change focus position... focus $focus # report new position... @ j=$i @ j++ printf "-----------------------------------------------------------------------\n" printf "Acquiring image %d of %d (%s) at %.0f\n" \ $j $n `nextimage -tail` `focus` printf "-----------------------------------------------------------------------\n" # acquire image(s) using the appropriate command... goi # increment... @ i++ end # reset focus value... quit: focus $old_focus