Tcl console

Tcl is an easy to learn scripting language in which you will eventually be able to automate your data reduction if you take your data systematically.

I will not attempt to describe tcl here. See for an interactive tutorial.

At present, the reduction is set up to be driven by the GUI, so although you could automate it now it would be awkward to do so. Here are some incomplete notes to get you started. Be warned that the information given below is subject to change without notice as the scripting interface evolves.

The active set of records is determined by a call to setdirectory. This takes a file pattern, categorizes all the matching files and displays them in the file selection tree. E.g., to load all the ng7 files in your reflectivity directory you might use:

	setdirectory ~/refl/*.ng7

Information about individual files are stored in arrays in the global namespace. The name of the array is visible in parentheses beside the name of the file when the file is selected. You can see what information is being stored for each file using "array get". E.g.,

	array get R1

To find the record associated with a particular file name, use the function rec which searches through all categorized files for a file of the given name. E.g., to find 074A of dataset f524b use:

	rec f542b074.na1

This maps the array rec to the record found, so you can see the fields using, e.g., puts $rec(file).

Records can be added to or removed from the current scan using toggle_section. The following command adds R3 to the current scan. The keep option makes sure that it is an add, since otherwise it will be a toggle.

	toggle_section -keep 1 -node R3

You can manipulate the data directly by accessing the data record. For example, you can set an attenuator factor using:

	set R2(k) 23.
	set R2(dk) 0.1

If you change the attenuator by hand, be sure to call the following to update the display:


Once all the records are selected and the attenuators are set, you can accept the scan with a call to addrun accept. A table of all accepted scans is stored in scanindex. You can examine an individual scan with array get scan#, where # is the number of the scan given in the scan index.

	addrun accept
	array get scanindex

The rest of reduction is even less amenable to scripting. To use e.g. scan1 you will need to find "$scan1(name) $scan1(comment)" in the listbox for .reduce.$scan1(type) to get the index (see the function listbox_ordered_insert in generic.tcl for clues how to do this), then you will need to force that index to be selected (see the listbox manual page for clues). Footprint correction is more awkward still.


Browse Index