Macros

A SAC macro is a script of SAC commands.  SAC macros can take several forms depending on how you want to implement them.  These include:




Example 1 - A simple macro based on the plotting example
 
 
macro name = mlntplot
How it is used
r mlnt.z mlnt.r mlnt.t
xvport 0.1 0.6
qdp off
xlim 58 70
title on "Rotated Data at MLNT"
xlabel on "Time, sec"
ylabel on "Digital Counts"
bd sgf
p1
ed sgf
sgftops f001.sgf plot1 1 y
SAC> macro mlntplot



Example 2 - The same macro driven by dependent arguments
 
macro name = mlntplot2
How it is used
r $1 $2 $3
xvport 0.1 0.6
qdp off
xlim 58 70
title on "Rotated Data at MLNT"
xlabel on "Time, sec"
ylabel on "Digital Counts"
bd sgf
p1
ed sgf
sgftops f001.sgf plot1 1 y
SAC> macro mlntplot2 mlnt.z mlnt.r mlnt.t



Example 3 - The same macro driven by keywords
 
macro name = mlntplot3
How it is used
$keys files values
r $files
xvport 0.1 0.6
qdp off
xlim $values
title on "Rotated Data at MLNT"
xlabel on "Time, sec"
ylabel on "Digital Counts"
bd sgf
p1
ed sgf
sgftops f001.sgf plot1 1 y
SAC> macro mlntplot3 files mlnt.z mlnt.r mlnt.t values 58 70



Macros can also call other macros.  This is very useful in applying a generic operation to many specific data files.

Another useful trick, particularly when using SAC with CShells, is to use the UNIX directed input.  For example, using the first macro above, we could produce the plot by typing the following at the UNIX system prompt:

sysprompt> sac2000 < mlntplot > sac.output

"sac.output" is a file that catches all the sac i/o that would normally be seen on the screen.



Macro examples from the SAC files of C.A. Langston - ("The truth is out where?")
 

Return



last modified 3/05/01