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 http://www.msen.com/~clif/TclTutor.html 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 recR1

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 recR3 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 recR3

Once the file is selected and displayed in the graph, the data is stored in a suite of BLT vectors. For example, to see the vectors associated with recR1 use:

	vector names *_recR1

Some comments on the vectors are in order:

  x_recR1	Qz value for data
  xth_recR1	theta corresponding to the Qz stored in x
  y_recR1	counts in the file normalized by monitor*prefactor
  dy_recR1	standard error on y
  ky_recR1	counts*attenuator scaled to current monitor
  kdy_recR1	standard error on ky
  idx_recR1	index of included points
  XXX_recR1	data for column XXX as stored in the ICP file

Note that not all records will exist for all files at all times. x and xth may change if the user changes the background basis for a dataset. ky and kdy will change whenever attenuators change or runs are added. idx will change whenever a point is included or excluded.

Attenuators are stored for each record as rec(k) and rec(dk). If you change the attenuator by hand, be sure to call the following to update the ky and kdy vectors:

	atten_set $::addrun

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.

2002-09-18


Browse Index