# The Scan Command

An important concept in neutron scattering instrument control is a "scan". For a simple scan a range of instrument positions is divided into equidistant steps. The instrument then proceeds to drive to each of these points and collects data at each of them.

The general idea of the scan object for TOPSI is, that you configure the scan by typing commands at the command line. Once, the configuration is finished the requested scan is started. A data file will be written automatically to the default location. The scan command can not only scan over motors but also about some variables which relate to motors. For instance lamda for the wavelength. Scan can scan over more then one variable. The syntax of the scan command in some detail:

scan clear
  Clears current scan parameters.
scan list
  lists current scan parameters.
scan var name start step
  Defines a variable (motor) to be scanned. The name of the variable, a start value and a stpe width need to be given. More then one scan variable can be specified.
scan modvar name start step
  Modifies the scan parameters for scan variable name to the new values given.
scan getvars
  Returns a list of currently active scan variables terminated with the string -END-.
scan NP num
  Sets the number of scan points.
scan Preset val
  Sets the Preset value for the scan. Without a parameter, inquires the current value.
scan Mode val
  Sets the count mode for the scan. Without a parameter, inquires the current value. Possible values are Timer or Monitor.
scan run
  Executes the scan.
scan cinterest
  This call enables automatic printing of scan counts to your connection when new values arise. This command is primariliy of interest for status display clients.
scan pinterest
  This function makes the scan command send a notification (the string ScanVarChange) to you whenever the scan variables get modified. This command is primarily of interest for status display clients.

## Center Scan

Center scan is a convenience command which starts a scan around a specified center value. This mostly used for centering purposes. The syntax is like this:

> cscan var center delta np preset

All parameters must be specified. The parameters and their meanings:

- var is the variable which is to be center scanned. Only one can be specified.
- center is the value to use as center of the scan.
- delta is the step width to use for the scan.
- np is the number of points to scan in each direction.
- preset is the preset to use for the counter. As the counter mode, the mode currently configured active in the scan object is used.

## Simple Scan

Simple scan is a convenience command which starts a scan for one to several variables with a simplified syntax. The syntax is like this:

> sscan var1 start end var2 start end ... np preset

All parameters must be specified. The parameters and their meanings:

- var1 start end This is how the variables to scan are specified. For each variable scanned the name of the variable, the start value and the end value of the scan must be given. More then one triplet can be given in order to allow for several scan variables.
- np is the number of points to scan.
- preset is the preset to use for the counter. As the counter mode, the mode currently configured active in the scan object is used.

## Peak And Center

These two commands are related to the scan command insofar as they act upon the results of the last scan still in memory. The command peak prints the position, FWHM and maximum value of the peak in the last scan. The command center drives the first scan variable to the peak center of the last scan. Both peak and center use a rather simple but effective method for locating peaks. The prerequisite is that the peak is approximatly gaussian shaped. The algorithm first locates the peak maximum. Then it goes to the left and right of the maximum and tries to find the points of half maximum peak height. The two points are interpolated from the data and the peak position calculated as the middle point between the two halfheight points.