Come analyze HEASARC, IRSA, and MAST data in the cloud! The Fornax Initiative is now welcoming all interested beta users.
Script Example
In the directory $HEADAS/../ftools/spectral/session is a script file called tclex.xcm. This script gives an example of how one might use the power of tcl's scripting language in an XSPEC session. This script should be executed with
XSPEC> @tclex
# This script gives an example of how one might use the power of tcl's
# scripting language in an XSPEC session. In this example, XSPEC loops
# thru 3 data files (file1, file2 and file3) and fits them each to the
# same model `wabs(po+ga)'. After the fit the value of parameter 4 (the
# line energy for the gaussian) for each data set is saved to a file.
# Keep going until fit converges.
query yes
# Open the file to put the results in.
set fileid [open fit_result.dat w]
for {set i 1} {$i < 4} {incr i} {
# Set up the model.
model wabs(po+ga) & /*
# Get the file.
data file$i
# Fit it to the model.
fit
# Get the values specified for parameter 4.
tclout param 4
set par4 [string trim $xspec_tclout]
# Turn it into a Tcl list.
regsub -all { +} $par4 { } cpar4
set lpar4 [split $cpar4]
# Print out the result to the file. Parameter value is
# the 0th element of the list `lpar4'.
puts $fileid "$i [lindex $lpar4 0]"
}
# Close the file.
close $fileid
end
The user is encouraged to read the voluminous on-line documentation and literature available about tcl in order to benefit fully its flexible command processing, graphical interfacing, and scripting capabilities. See http://www.tcl.tk for much more information and extensive bibliography.