By
The user can move freely between the two windows. Clicking the left mouse button in the corresponding window switches input focus. In the command window command lines can be recalled, edited and re-issued. In the graphics window key-press and button-press events are used to manipulate the picture.
XSA creates log-files, like "saMMDDYY_time.dat","results.dat" (appends to existing logfile), to record useful information and results.
Data are read from a File. An XSA-File requires a special File header. For compatibility Radware (.spe) and ASCII-array (.asc) data files are accepted.
XSA can be called to use shared memory for its data space ("xsa -s"). The shared memory segment has to be initialized with the program shm_init (which is part of the distribution). For 'online' applications the shared memory segment can be filled by a separate histogram process.
Total data space available 440k
Work area 16k
These sizes are limited to comply with default shared memory sizes.
Data can be placed anywhere in the data space. A total of 440 spectra
can be in memory at one time.
(see read).
Data/Spectra are referred to (see display)
by their histogram_id (try ls "listing").
There are two id's; the first id uses the placement in data space
starting with id 1 for the first spectrum or the
histogram_id which is inherited from the data file.
Either id can be used
to reference the spectra (see Options menu).
The work area has the default id 0.
Generally, whole spectra are addressed and manipulated, but,
all data can be viewed and manipulated in absolute
data space by using the proper array addresses.
For convenience kilo numbers
(chunks of 1024 data words) can be used.
When appropriate, a number appended with a k or K
will be multiplied by 1024 (eg. 1k -> 1024).
Important restriction!
When accessing the data array as a whole, keep in
mind that the zero point is the start point (array
offset) of the last called spectrum. A call to the first
spectrum selects as zero point the begin of the data array.
Under the FILE menu is the Sa Command Window (command widget).
All command widget properties apply, like command history list.
Especially, any command can be repeated by double clicking the command.
Line commands consist of a code word
and input in form of text and/or numbers.
The number of input entries is important as it determines
in many cases the action taken (for a typical example see
addc).
A command terminated without input is executed
with default or former input parameters.
Not all parameters have to be provided every time.
Most commands act on whole spectra.
A general advice: Spectra should be changed,
when possible, only in the work area.
One or more spectra are
copied into the work area using the sel id command.
First select a spectrum (sel id) then call the action.
Adding spectra puts the sum into the work area. The add command
adds the data to the content in the work.
A typical command sequence would be
sel id put spectrum with id in work area
add idx add spectrum with id idx to the first and display
the result in the work area.
The add command can take a list of spectra id's
Examples
sel 1
add 2 3 4 will add the three spectra to the content (spectrum 1) in
he work space.
If the work area is empty, the sel command can be skipped.
addc constant to spectrum in work area.
addc constant id addc constant to spectrum with id
addc constant to be added to each channel
[first ch] start of spectrum
[last ch] last channel
Example
addc 23 0 1k expands to
add 23 to the first 1024 data words.
back
For instance: Edit a cmdfile (collection of valid commands)
r file1 0 ;read and store file1 at beginning of data array
r file2 4k ;read and store file2 at address 4096
add 0 4k 4k ;add file2 to file1
w file3 0 4k ;write sum spectrum (now in 0) to file3
The run command with a file name invokes the reading
of that file as command file.
Execute the file by calling
run filename
Any filename starting with the letters "mk" (make) will be run as
command file with out the "run".
A limited argument substitution $1 to $5 can be used. back
The number of input tokens determines what is expected:
cal [CR] resets calibration to channel numbers,
which is the default "calibration".
cal all resets calibration for all spectra.
cal filename calibration stored in a file is read in.
cal 1.Energy 2.Energy
Type the energies and get the
channel information from display.
cal spectrum_id slope zero_offset
known calibration is expected
If id is all, all spectra in memory
get the same calibration.
cal 1.Energy 2.Energy 1.Channel 2.Channel
provides all information for a calibration
of the current id.
mcal 2 - 10 slope zero_offset
multiple id's for the same calibration.
wcal filename The calibration can be stored in a file.
New calibrations are appended to an
existing file.
rcal filename A wcal file can be read back.
cpcal id After displaying or selecting a spectrum
the calibration of id is copied to the current spectrum
esc (e-scale)
toggles between "ENERGY" and "CHANNEL NUMBER"
scale (see Options menu).
back
ds id [-ymax] Display spectrum with identification id.
up to 8 spectra can be displayed
simultaneously on the screen.
The default id is the position in the
absolute data space 1,2,3,....
When appropriate spectra can be selected by
their intrinsic id (provided by the data file).
setid toggles between both modes.
If the last entry is < 0 it is taken as maximum
of the y-scale
ds 1 2 3 4 for instance, will display the first 4 spectra.
ds 1 - 4 has the same effect (spaces are important).
The order can be chosen arbitrarily,
eg. 1 3 8 5.
Again, if the last number is negative,
it will be used as YMAX for a fixed scale
for all displayed spectra (eg. ds 1 2 -500).
do id plots data over old picture.
do id col specify in addition color of overlaid spectrum.
do 2 red -100 a optional third input will be taken as YMAX
for the overlaid data.
do 2 green 0 A 'zero' as last number invokes auto scaling for the overlaid
spectrum.
ov id similar to 'do id'. In addition it has the
functionality of the 'ds' command.
ov 2 4 5 overlayes on the current display spectra 2 4 and 5.
Select a display range.
dsr 100 512 The display field starts at channel 100 and has a length of 512 until reset using dsr[CR] without parameter. dsr 512 If only one input parameter is provided it defaults to a new display length.
Define new first channel and display length.
d fch lch first channel last channel If last channel is less than first channel, last ch is taken as the display length. First and last channel are relative to the last displayed spectrum. d 0 1k displays the first K of current spectrum d[CR] repeats former setting (repaints display).back
Use of mouse buttons:
Display command list in alphabetical order:
gmf 1.007 -8.2 sets the gain match factors to the given values
gmf -5.3 (one input item only) is taken as shift factor.
gmf 600.0 1600.0 605.0 1640.0
will calculate gain match factors to
match channel 605 to 600 and 1640 to 1600.
gm id does the matching. The result is in the work space.
Examples
gmf 0.5 0.0 the new spectrum will be half the length
gm id and be in the work area.
Typically, the last displayed spectrum will be adjusted. If
an id is provided, that spectrum will be used.
shift 1.23 shifts the current spectrum by 1.23 channels to the right
WARNING: the result is in the current spectrum not in the work area.
Shifts can be negative (to the left).
rebin 1024 the current spectrum will be re-binned to 1024 channels.
the results is always in the work area.
rebin 1024 3 spectrum with id 3 will be re-binned to 1024 and left in
work area.
For gain matching a set of detectors, like Clover detector segments,
the gain match information (gain match factors) can be derived within
XSA and written out into a file (date_time.gmf).
First, the peak information for the new position
(two energies) is provided with the cmd
pp e1 e2
this initiates a mode where the next two peak positions in the current
spectrum should be selected (peak centroids - click right mouse button).
Display next spectrum and select next two peaks and so on.
After for all detectors the reference positions were determined
pp out (0 is equivalent to out)
is used to write the currently stored information out and the pp mode
is terminated. Any selection can be repeated by using
pp nr
where nr is 1 - 16 (16 detectors max). If nr is omitted the current
display id is used. Like
pp
ds 1
or clicking in the spectra listing.
back
mul id Spectrum in work area is multiplied by spectrum with id
div id Spectrum in work area is divided by spectrum with id
The result is in work area.
In absolute data space:
div addr1 start address of data in array
addr2 start address of other data
length total number of channels
Type the start address of the first and second spectrum
and the total number of channels to be dived.
Examples
div 0 3k 1k will be expanded as, divide 1024 (1K)
data starting at 3072 by data starting
at 0 and leave the result in K0.
back
mulf factor multiplies whole spectrum in work area mulf factor id multiplies data in spectrum id.In absolute data space:
mulf 1.25 0 1k expands into multiply all channels of the first K by 1.25.back
m number where number is the channel number or
energy if a calibration is provided
One or a group of markers can be moved to a new
position. Type
mm # [#] [#]
then click with the left mouse Button at the new position.
Pull down File menu and choose listing or
ls all spectra in core are listed:
index,id,name,begin in array,length,calibration data
Spectra can be called by ind or id. If
identical id's in separate spectra,
the ind has to be used.
setid toggles between id and index. id is default (see Options
menu).
back
pd first_channel last_channel
Example
pd 100 150 the data of the channels between
100 and 150 will be printed out.
back
ps
Examplesproduces a postscript file 'sagraph.ps' containing the current picture. ps works similar to the ds command. ps[CR] takes effectively the screen picture. Text enclosed in " " is taken as title of the picture.
ps 1 2 "Detector 3"
Spectra 1 and 2 with a heading 'Detector 3' are written into sagraph.ps
ps 1 "Title" > newname.ps (changes output file name)
If only one spectrum is selected;
Landscape format is used,
all marks set in that window or region will be converted into channel numbers or energies (if calibration present). If the highest channel is marked a centroid using the adjacent channels will be calculated.
The command lps sends the ps file directly to the default printer. Equivalent: Print of file menu which 'copies' the screen.
Graphs can be overlaid (in colors) using pso instead of ps like in
pso 2 5 -ymax
If the last entry is a negative number, it is used as YMAX for all spectra. -1 in overlay mode invokes auto scaling for each spectrum.
pso
An overlay picture can also be printed using the current screen layout (preserving the yscales).
The title can use super or sub scripts. Subscripts start with
"_" and and end with "^" and vice versa. So, ^152_Eu becomes
152Eu.
One spectrum is always plotted using LANDSCAPE format. ps1 plots spectra in 1 column (PORTRAIT). 1-8 spectra fit on one page.
ps1 2 - 5 > name.ps
spectra 2 3 4 5 are written in postscript file 'name.ps'.
ps2 does the same in 2 columns. Up to 16 spectra fit on one
page.
back
In command mode peaks are called by their marker number.
p peak_no peak number
width optional width of display window
Default is 64 left and right of peak.
pm peak_no imports all peak marks from the specified peak
Examples
p 0 [110] select peak zero. The optional [#]
replaces the width parameter.
p [CR] repeat last peak
pm 0 make peak marks from peak zero the current markers.
A marked peak can also be selected by moving the
cursor close to the peak and typing g for grab.
The peak and a window around the peak will be displayed. Set marker for background region left (0 to 1) peak region (2 to 3) and background region right (4 to 5).
Fit background polynomial b. If no bkgd is needed, simply do not select the order of the bkgd polynomial or reset it with b-. In this case only two marks (0 and 1) need to be set.
A simple summation is started with s or i (integrate).
For a Gaussian fit the center of the peak or peaks (max 4) has(ve) to be marked (marker 6 to 10) before f (fit) is started. Even if bkgd should be set zero all marks have to be set.
The results are written to the screen and to the file sa.dat (check file results.dat), which contains shortened information of your session. All markers and the order of the background polynomial are stored for further use. All display mode commands are enabled. After a fit or peak area summation of the selected peak typing g returns the picture to the full screen.
Sometimes, it is desirable to sum many peaks automatically. Using the so called 'flat upper limit' method a background can be determined for the whole spectrum and then subtracted.
ful id
A 'background free' spectrum is generated in the work area
and the background spectrum is left in the adjacent work area for
viewing and error calculation of peak sums (addr: w+len).
Examples
ds 1 thats your spectrum
ful 1 does the background calculation
ds w show the data without bkgd (see sum)
ds 1 shows data
do w+2k red overlays the bkgd curve (if a spectrum has length of 2k)
Setting marker pairs
for peak regions and issuing the command sum produces
a list of peak sums (center of gravity, peaks sum, peaks sum error).
Examples
sum 2 sum between all marker pairs in spectrum 2,
errors are sqrt of content.
sum 3 1 sum in spectrum 3, take bkgd and errors from spectrum 1
sum 3 w s sum in spectrum 3 (no bkgd subtracted),
take errors from spectrum in work area using
sqrt of these sums as error only.
beside s, n (no bkgd), b (bkgd), similar ps, pn and pb.
p signals that marker pairs are set in peak mode.
back
Internally, all data are stored and used as real independent of their file format.
r File_name file name of spectrum
K no K no of start address in memory.
Read_in should start only on full k boundaries.
r myfile 2k myfile is read and stored from address
2048 up-wards the length is taken from file header.
If the K no is omitted, the new data are stored
at the beginning of the data array.
r myfile a the next data are appended to the data array.
rs File_name
file name of spectrum
Spec no spectrum to be read from file
Address start address for data in memory array
rs myfile 1 0
myfile spectrum with id 1 is read and stored
beginning at addr 0.
In subsequent reads from the same file only the spectrum number and optional the K number are required (rs 2 0).
rr File_name matrix name
row starting row
rows number of rows
address start address for data
The cd command can be used to set a path to a different directory. cd without input resets to the default directory. Likewise pwd tells where data are read from. A File menu entry Open... brings up a file selection box from which a read (reads the whole file into the next free data space) or open (opens only the file) can be selected.This creates a cut of the matrix and stores the result as spectrum.
Similar input is used for reading columns. The short input form requires no File_name. If another file name is needed the long form has to be used or a file can be opened using the command
file name open file for subsequent reading open name is synonymous.
struct filehead { /* File Header Block */
char name[16]; /* Character line: "his/.." */
int nrun; /* Run number */
int dtype; /* Data Type: 0 long; 1 short unsigned; 2 real*/
int len; /* Total Number of Channels */
int maxid; /* Max Number of Spectra */
struct {
int id; /* spectrum id */
int offs; /* begin of spectrum in file */
} sinfo[124]; /* id and offset of each spectrum */
};
A data file always starts with the word 'his/' or 'data/*'[phased out],
the next characters can be anything followed by '\0'.flhd.maxid = 1; flhd.sinfo[0].id = row_length; flhd.sinfo[0].offs = column_length;flhd.len is the total number of data words (excluding the header). A file can contain up to 124 spectra (sinfo) each can have an unique identification number (flhd.sinfo[i].id) and has to have a start point. By definition flhd.sinfo[0].offs = 0;
rmarks filename for marker file. To write a marker file
wmarks has to be used.
The filename is appended with the extension .mks
reset[CR] all markers including the background
markers are cleared.
back
sflhd num select number of spectra
The number of channels per spectrum is
calculated from the total length and num.
All spectra then have the same length.
tr start_addr first address
new addr second address to which data are moved
length number of channels to be transferred.
"title" optional name, used in ls.
id optional new id
Examples
tr 2k 0 2k transfer two K of data from second
to first K
tr [CR] uses former numbers again
tr w 10k 2k transfer data from work area to 10k (2k long)
tr w+2k 8k 2k "bkgd" 5
tr w work area data are transferred to 'end' of used data space
simplifying space selection
back
w File_name Name of output file
startaddr Start address of data set
length number of channels
The output file is written in the standard data format.
The spectra organization present in memory is kept in the
file header.
Examples
w file 2k 4k 3 stands for write file of 4096
channels beginning at address 2048.
and set run_number to 3
wf name writes data as floating numbers.
If only a file name is provided the data of the work area
are written out.
wspe name writes data of the work area as .spe (Radware) file
wasci name writes data (work area) as ASCII list to file
The File menu entry Save brings up a message dialog for writing
data to disk.
back
wmarks filename stores the marker array.
This effectively makes a suspension of XSA possible.
To resume start XSA read data and marker file and continue.
ww name
There is also a rw command to read windows back.
zero first ch first channel
last ch last channel
The channel numbers refer to the total histogram array.
If last channel is less than first, last ch is taken as length.
Examples
zero 0 1k clear first K
zero all zero all data
zero reset (clear all spectra and
reset number of histograms to 0)
back
set channel new-Data
set new-Data
and click in window (between 2 marker).
back
A special set of commands is provided: ud,rat,anis.
ud ndet id
For each detector ndet the 4 spectra starting at a given
id
are selected for analysis. The default id is 1.
rat npeak number
npeak is 0 for peaks 0-3 (1 for peaks 4-7 and so on) and
number is the number for how many of such peak groups
ratios should be calculated.
Examples
rat 0 1 only the ratio for the first peak group is calculated.
The peak areas are logged in a file, default name "rlog.dat", for
further analysis. This default name can be overwritten.
rat 0 1 > newfile
The new file name is in effect until changed or the program is restarted.
In principle 2 detectors are sufficient for a double ratio.
rat2 det1 det2
calculates a double ratio for two detectors, which have to be provided
where det1 det2 are the numbers of the detectors.
anis
For this to work, the order of the peak information should be as follows:
anis can also be used with a known anisotropy ratio.
The command is
anis R dR
where R is the ratio and dr its error. All
back
sran id
The spectrum with id is put into the work area with the random spectrum
subtract. Mark and select a peak of interest. Sum or fit peak. The
random subtraction is included in the peakarea error when written out.
sran id1 id2
id2 is the id of the randoms spetrum if other than id1+1.
sran id1 p #
a p (for peak) with a peak number can be added in the command line
to select a peak for immediate summation.
esc toggles between Energy scale and Channel numbers
cd [path] change data directory
without path reset to starting directory
ls list what is in memory
ful id ful creates a background free
spectrum of id in work area plus the
background next (adjacent) in the work area
pwd show the current data directory
rebin nk rebins current spectrum to new (nk) lenght (e.g.2048 -> 1024)
setid toggles between id and index.
scale # # creates a channel by channel scale factor spectrum
from summed windows.
shift ch shift current id spectrum by ch channels.
sqrt makes a sqrt spectrum from current id.
sum sum Peak Integration or Peak(s) Fitting
between marker pairs, write to results.dat
useful after using ful background subtraction.
system invoke system call (like 'date', 'echo' ...)
exit[CR] normal exit of program.
quit[CR] The log files are removed on exit.
back
"ds" : display 1 or more spectra ( disp )
"do" : overlay spectrum ( disp_o )
"ov" : overlay list of spectra ( overlay )
"d" : redisplay or display selected region ( disp_d )
"dsr" : set display range ( set_dsr )
"log" : display in log scale (subtract decade) ( logdis )
"lin" : display linear ( lindis )
"setid" : toggle use of file / data space id ( set_id )
"r" : read whole file ( readfile )
"rs" : read selected spectrum from file ( readspec )
"rc" : read matrix data, select columns ( readcol )
"rr" : read matrix data, select rows ( readrow )
"file" : open datafile for reading ( get_fln )
"open" : open datafile for reading ( get_fln )
"cd" : set path for reading data files ( chpath )
"pwd" : show directory from where data are read ( prpath )
"w" : write new file (integers) ( wrtf0 )
"wf" : write new file (floating numbers) ( wrtf2 )
"wspe" : write Radware file .spe ( wspe )
"wasci" : write ASCII data to file ( wasci )
"tr" : transfer data in memory ( trans )
"sel" : select (copy) spectra in work area ( sel_id )
"ls" : list spectra in memory ( shspec )
"zero" : purge spectra from memory ( zero_dat )
"clear" : clear all data space ( clear )
"ps" : create postscript picture file ( psfile )
"pso" : create postscript data in overlay mode ( o_psfile )
"lps" : send postscript picture to printer ( p_psfile )
"lpso" : same for overlay mode ( po_psfil )
"pd" : print data as vector list (sa.dat) ( pridata )
"cal" : calibrate energy scale ( calibrat )
"cpcal" : copy calibration to display region ( cpcal )
"wcal" : write calibration data to file ( wcal )
"esc" : toggle energy scale display ( escale )
"m" : mark; type channel number to be marked ( set_mark )
"mm" : move[mark] one/several marks to new position ( mv_marks )
"reset" : clear all marker ( reset )
"rmarks" : read marker file back ( rmarks )
"wmarks" : write marker file to disk (.mks) ( wmarks )
"ww" : write window (marker pairs) to disk (.win) ( w_win )
"rw" : read window file back ( r_win )
"p" : select marked peak for integration ( peak )
"pm" : import peak marks from an other peak ( peakmar )
"i" : sum peak (integrate) ( integrat )
"f" : fit Gaussian to peak[s] ( fit )
"aps" : set automatic peak search factors ( set_aps )
"nspec" : set number of spectra (work area) ( set_flhd )
"set" : set individual data point in spectrum ( data_set )
"sum" : sum content for list of window ( sumlines )
"add" : add spectrum to data in work area ( add )
"addc" : add a constant to all channels ( forge )
"sub" : subtract spectrum from data in work area ( sub )
"sran" : subtract two spectra and put in work area ( subran )
"mulf" : multiply data in work area by a factor ( forge )
"div" : divide two spectra ( divide )
"mul" : multiply two spectra ( multiply )
"smooth" : smooth data ( smooth )
"sqrt" : make square root of data in work area ( forge )
"gmf" : set shift and gain change factors ( set_scf )
"gm" : apply shift and gain change ( g_match )
"scale" : select scale factors (special feature) ( scale )
"cut" : cut negative data of spectrum ( forge )
"ful" : "flat upper limit" background subtraction ( genful )
"ud" : select data set for up/down analysis ( udselect )
"anis" : calculate anisotropy ratio ( anis )
"rat" : for u/d analysis make 4 det. double ratio ( dratio4 )
"rat2" : for u/d analysis make 2 det. double ratio ( dratio2 )
"run" : run command list file ( runfile )
"system" : execute shell command ( dosystem )
"exit" : exit XSA ( exitus )
"quit" : exit and delete log files ( quit_pro )
Up to Outline.