User Defined Scans Ferdi Franceschini 2006-08-16 15:25 Creating a Scan Command A scan command must first be initialised with MakeScanCommand command in the SICS configuration file before it can be used. MakeScanCommand initialises the SICS internal scan command. MakeScanCommand name countername headfile recoverfil Arguments must be in the order described name The scan will be accessible as name in the system. countername The name of a valid counter object to use for counting headfile The full pathname of a header description file. This file describes the contents of the header of the data file. The format of this file is described below recoverfil The full pathname of a file to store recover data. The internal scan command writes the state of the scan to a file after each scan point. This allows for restarting of aborted scans. Using a Scan Command The scan command (named here MyScan, but may have another name) understands the following commands: MyScan run NP mode preset Executes a scan. NP is the number of scan points mode is the counter mode, either or preset is the preset value for the counter Scan data is written to an output file. MyScan add name start step Adds the variable specified by the argument name to the list of variables scanned in the next scan. The arguments start and step define the starting point and the step width for the scan on this variable. MyScan appendvarpos i pos Append pos to the array of positions for scan variable i. To be used from user defined scan functions. MyScan callback status Triggers callbacks configured on the scan object. Allow status one of: May be used by user functions implementing own scan loops. MyScan clear Clears the list of scan variables. Must be called before each scan that has different parameters. MyScan configure mode Configures the scan mode Allowed mode one of: (default). Writing ASCII files Scan functions are overriden by the user. The scan stores and saves software zero point corrected motor positions. The standard is to save the hardware positions as read from the motor controller. MyScan continue NP mode preset Continues an interrupted scan. Used by the recovery feature. MyScan function list Lists the available configurable function names. The calling style of these functions is described in the next section about stdscan. MyScan function functionname Returns the currently configured function for functionname MyScan function functionname newfunctionname Sets a new function to be called for the function functionname in the scan. MyScan getcounts Retrieves the counts collected during the scan. MyScan getfile Returns the name of the current data file MyScan getmonitor i Prints the monitor values collected during the scan for monitor i MyScan gettime Prints the counting times for the scan points in the current scan. MyScan getvardata n Retrieves the values of a scan variable during the scan (the x axis). n is the ID of the scan variable to retrieve data for. ID is 0 for the first scan variable added, 1 for the second etc. MyScan getvarpar i Prints the name, start and step of the scan variable number i MyScan interest A SICS client can be automatically notified about scan progress. This is switched on with this command. Three types of messages are sent: a string NewScan on start of the scan a string ScanEnd after the scan has finished a string scan.Counts = {109292 8377 ...} with the scan values after each finished scan point. MyScan uuinterest As for interest but the array of counts is transferred in UU encoded format. MyScan dyninterest As for interest but scan points are printed one by one as a list containing: point number first_scan_var_pos counts. MyScan uninterest Uninterest switches automatic notification about scan progress off. MyScan integrate Calculates the integrated intensity of the peak and the variance of the intensity for the last scan. Returns either an error when insufficient scan data is available, or a pair of numbers. Peak integration is performed along the method described by Grant and Gabe in J. Appl. Cryst. (1978), 11, 114-120. MyScan log var Adds var to list of variables logged during the scan. Can be slave motors such as during four circle work. These variables are not driven, just logged. var is the SICS variable to log. Only drivable parameters may be logged in such a way. MyScan noscanvar Prints the number of scan variables MyScan np Prints the number of points in the current scan. MyScan setchannel n Sometimes it is required to scan not the counter but a monitor. This command sets the channel to collect data from. n is an integer ID for the channel to use. MyScan simscan pos FWHM height BROKEN This is a debugging command. It simulates scan data with a hundred points between an x axis ranging from 10 to 20. A gaussian peak is produced from the arguments given: pos the position of the peak maximum FWHM is the full width at half maxxximum for the peak height is its height MyScan silent NP mode preset Executes a scan. Does not produce an output file MyScan storecounts counts time mon1 mon2 ... Don't understand the syntax nha. This stores an entry of count values into the scan data structure. To be used from user defined scan functions. The scan pointer is incremented by one. MyScan storecounter Store the counts and monitors in the counter object configured for the scan into the scan data structure. Increments the scan pointer by one. MyScan recover Recovers an aborted scan. The scan object writes a file with all data necessary to continue the scan after each scan point. If for some reason a scan has been aborted due to user intervention or a system failure, this scheme allows to continue the scan when everything is alright again. This works only if the scan has been started with run, not with silent MyScan window newval Peak Integration uses a window in order to determine if it is still in the peak or in background. This command allows to request the size of this window (without argument) or set it with newval User Definable Scan Functions The last commands in the last section allow overloading functions that implement various operations during the scan with user defined functions. This section is the reference for user defined functions. The following operations during a scan can be configured: count MyScan userobjectname point mode preset Called at each scan point to perform the counting operation collect MyScan userobjectname point Called for each scan point. This function stores the scan data into the scan data structure. drive MyScan userobjectname point drive to the next scan point finish MyScan userobjectname Called after the scan finishes and may be used to dump a data file or perform other clean up operations after a scan. prepare MyScan userobjectname Does operations before a scan starts. userdata This is the name of a user defined object which may be used to store user data for the scan. writeheader MyScan userobjectname Write the header of the data file writepoint MyScan userobjectname point Called for each scan point. Prints information about the scan point to the data file and to the user. MyScan is the name of the scan object invoking the function. This can be used for querying the scan object. userobjectname is the name of a entity as specified as userdata in the configuration. point is the number of the current scan point.