SAC Tutorial



SAC2000 is a general purpose interactive program designed for the study of sequential data, especially time-series data. Emphasis has been placed on analysis tools needed by research seismologists in the detailed study of seismic events.


This guide shows you by example how the basic SAC commands work. Trying these examples as you read the guide will quicken the learning process. If you want to learn more about a particular command, see the Command Reference Manual. For general information on how SAC2000 works, how to create and use SAC macros, on the structure of SAC data files, and how to interface other programs to SAC2000 see the User's Manual.

If You Need Help

Ask a knowledgeable friend! This often works best. If you have further questions, suggestions, or gripes of any kind feel free to contact us at the address listed at the bottom of this page. We will always listen and can often help.

An Important Note

SAC2000 is a large program with many capabilities and options. It can be confusing at first. Don't despair. The most important commands are discussed in this guide. You need to learn about the rest of the commands only as you need them. Common sense defaults exist for most options. SAC2000 does a lot of error checking so you can't get into too much trouble. Good luck and have fun!

Getting Started

Starting up SAC2000

Once you have set up your environment as discussed in the last section and are logged onto a graphics terminal or workstation, simply type "sac2000" or " sac ". SAC2000 will then print a short headline including the number and date of the version you have on your system. It may also print a bulletin giving some current information. SAC2000 will then ask you for input by sending the prompt ``SAC > ''.


SAC2000 is an interactive command driven program. This means that you must type a command to get SAC2000 to do something. It does not prompt you for input. Commands may be typed at the terminal or placed in a command file. Symbols within a command are separated by spaces and commands within a given line may be separated by a semicolon.

A Simple Example

We'll start by creating a simple function:

funcgen impulse

This generates an impulse function and stores it in SAC2000's memory. FUNCGEN is one of the many SAC commands.

To see what this function looks like on your screen type:


Note that both upper and lower cases are acceptable by SAC.


There are abbreviations for the most used SAC commands. For example, FG, BD, and P are the abbreviations for FUNCGEN, BEGINDEVICE, and PLOT respectively. Most options also have abbreviations: X for XWINDOWS. (There is a graphics device for generating hardcopy plots. It is called SGF for SAC Graphics File.

More Functions

The FUNCGEN command can generate a number of different functions. This is very useful when first learning how to use SAC2000 because you can see how the other SAC operations work on these functions. For example, type:


This generates a sample seismic signal in SAC2000's memory. It also deletes the impulse generated earlier. Use the PLOT command to see this seismogram on your screen. Now for another function:


This is an example of a more complicated SAC command. This example generates a 2 Hz sine wave in SAC2000's memory. The function will contain 200 data points and have a sampling interval of 0.01 seconds. You may want to use the PLOT command to plot this function also.

SAC Commands

There are several general points to be made at this point about SAC commands. All input is space delimited. The decimal point is optional wherever numeric input is needed. When you specify a value for a particular option, this value becomes the new current value. This means you don't have to keep entering values for options that you don't want to change. For example, you can now generate this same 2 Hz sine wave using the same sampling interval but with 400 data points by simply typing:


SAC commands fall into two main categories: parameter-setting and action-producing. The parameter-setting commands basically change values of internal SAC parameters. Action-producing commands perform some operation on the data files currently in memory based upon the values of these same parameters. The effect of a parameter-setting command remains in effect until it is reset. The effect of an action-producing command, however, is immediate and transitory. For example, the parameter-setting command, YLOG, tells SAC2000 to use logarithmic interpolation for the y axis in subsequent plots. The action-producing command, PLOT, does the actual plotting. Options to action-producing commands also remain in effect until reset just like parameter-setting commands. The underlying assumption is that you are more likely than not to want to use the same values the next time you execute the same command.

Default Values

All commands have ``nice'' default values for most options. The use of current and default values for command options can save you a lot of typing. For example, let's look at the BANDPASS command. This command applies a bandpass filter to the data currently in memory:



These two commands generate an impulse function and then apply a bandpass filter to that impulse. The filter is a four-pole Bessel filter with corner freqencies at 0.1 and 0.3 Hz. You can see the result in the time domain by typing PLOT or you can see the amplitude reponse by taking the Fourier transform and using the PLOTSP command:



You can now try a different set of corner frequencies very easily:



SAC2000 generates the same impulse function and applies the same Bessel filter except for the new corner frequencies.

SAC Data Files

What is a SAC Data File?

SAC2000 is a program to examine, analyze, and plot data. This data is stored on disk as SAC data files. Each data file contains a single data set. For seismic data this means a single data component recorded at a single seismic station. SAC2000 does not currently work on multiplexed data. The data will generally be evenly spaced time series data. SAC2000 can also handle unevenly spaced data and spectral data. The spectral data can be in either real-imaginary or amplitude-phase format.

The SAC Header

Each data file also contains a header record which describes the contents of that file. Certain header entries are always present (e.g., the number of data points, the file type.) Others are always present for certain file types (e.g., sampling interval, begin time, etc. for evenly spaced time series files.) Other header variables provide information needed by a particular operation (e.g., seismic component orientation used by the ROTATE command.) Still others are not used by SAC2000 at all. They are simply informational. SAC data files, including all header information, can be read and written by user created programs as well as by SAC2000. See the SAC2000 User's Manual for details. The LISTHDR or lh command displays the contents of the headers for the data files currently in memory. You may wish to examine the header from the sample seismogram mentioned earlier:



If a particular header variable does not have a value for a particular file, then that variable is said to be ``undefined'' for that file. The LISTHDR command does not list undefined header variables, usless it is invoked with the INC or INCLUSIVE option (which includes undefined header variables).

Header Variables

Each header variable is described in the Users Manual. The most important ones are also listed below:

NPTS Number of points in data set.
B Beginning value of the independent variable.
E Ending value of the independent variable.
IFTYPE Type of file.
LEVEN TRUE if data set is evenly spaced.
DELTA Increment between evenly spaced samples.
IDEP Type of dependent variable.
KZDATE Alphanumeric form of GMT reference date.
KZTIME Alphanumeric form of GMT reference time.
A First arrival time (seconds relative to reference time).
Tn User defined time picks or markers, n=3D0,9.

Reading and Writing Data Files

The READ Command

SAC commands work on data already in SAC2000's working memory, not data on disk. The READ command is used to transfer data from disk to memory. Up to 200 data files can be in memory at the same time. These can be of any size up the maximum size of SAC2000's working memory. This value is normally 1,000,000 32-bit words. (Both the number of files and the size of SAC2000's working memory can be changed by making minor modifications to the source code and recompiling the program.) You can use wildcard characters in the READ command to represent groups of files which have a similiar set of characters in their names. Each time you use the READ command to transfer data from disk to memory the data currently in memory is destroyed. If you want this data saved, you must write it to disk before reading more data into memory. There is an option called MORE in the READ command that lets you read data into memory without destroying the old data. See the Command Reference Manual for details.

The WRITE Command

Action commands (such as ADD, DECIMATE, and FFT) modify the data that is currently in memory. The data files on disk are not modified. At any time during your analysis, you may transfer this modified data back to disk using the WRITE command. You may overwrite the old data files on disk using the OVER option or create new ones by specifying their file names.

Several Examples

The examples below demonstrates several uses of the READ and WRITE commands. The first example reads two files into memory, multiplies each data point in each file by a constant, and then writes the results to disk in two new files:


MUL 10 20


The next example reads a single file into memory, desamples the data by a factor of five (DECIMATE also applies an anti-aliasing filter), and then writes the results back to disk using the same file name:




Sample Data Files

You're going to need some data files for use in the next section on plotting. You'll also need them if you want to try any of the other commands discussed later in this guide. If you don't have any sample SAC data files around to play with, you can use FUNCGEN to generate some. This is shown in the example below:







This results in you having three files in your directory called FILE1, FILE2, FILE3 which contain the triangle and boxcar, and step functions respectively. Each will have 200 data points in them and be sampled at 1 sample per second. If you already had files in your directory by those names, they would be replaced by these new ones.

Some Real Seismic Data

If you want to use some real seismic data files instead of the simple functions generated above, you can use the DATAGEN command. It has three-component data from three different seismic events (a local, a regional, and a teleseisem) that were recorded at Livermore. For example, to generate three different vertical components from the local event you could type:



Or if you wanted all three components from a single station in the teleseismic event you could type:



Each of these events, including some information about the recording network, the length of the files, and the file names can be found in the DATAGEN documentation in the Command Reference Manual.

Seeing the Results


After reading data into SAC2000 you can see it on your screen in several different formats using the various plot commands. Default values for each of the graphics display commands have been chosen to make it as easy as possible to display your data. By changing these default values before plotting, you also have complete control over the details of how each plot will look.


You've already used PLOT to display data files. With this command, each data file is plotted one at a time. SAC2000 pauses between files to give you a chance to examine the data. This is shown in the following example. User responses (what you type) are preceeded by a ``u:'' and SAC2000's responses by an ``s:''.

u: READ FILE1 FILE2 FILE3 (read in 3 files)

u: PLOT (plots first file to your terminal).

s: (Waiting after looking at plot type a carriage return).

u: [hit the return key] (plots second file).

s: (Waiting look at second plot).

There are other responses to this prompt that allow you to cancel the remainder of the plots or see them without pausing (e.g., type "k" will kill the plot).

Other PLOT Commands

Several other canned plot formats are available. PLOT1 plots each file along a common x axis but with a separate y axes. By default all files are placed on the same plot. Try this with the three files from the example above. PLOT2 is an overlay plot. Again all files are plotted together, this time using both a common x and a common y axis. PLOTPK uses a format similiar to PLOT1. It lets you use the cursor to blow up parts of the plot, determine values of selected data points, pick phase arrival times, etc.

Plotting Options

By default, all SAC2000 plots are self-scaling. SAC2000 determines what limits to use for the x and y axes. If you want to set these limits yourself, you may do so using the XLIM and YLIM commands. If you wish, you may also change the location of annotated axes, change the linestyle, select a symbol to be plotted at each data point, create titles and labels, make logarithmic plots, change the size and type of text, and control a number of other even more exotic aspects of the plot. These commands are part of the Graphics Environment Module. They are described in the Users Manual and explained in detail in the Command Reference Manual.

What Else Can I Do?


Fortunately (for you and for me) SAC2000 does a lot more than just reading, writing, and plotting data files! Some of SAC2000's analysis capabilities are briefly discussed below.

Filtering FFT and IFFT take the Fourier and inverse Fourier transform time series data.

LOWPASS, HIGHPASS, BANDPASS, and BANDREJ are a set of Infinite Impulse Response (IIR) filters. You may choose from Butterworth, Bessel, and Chebyshev Type I and II filters.
WIENER applies an adaptive Wiener filter.
FIR applies a Finite Impulse Response filter.
DECIMATE applies an anti-aliasing lowpass filter as it desamples data.
UNWRAP computes a spectral amplitude and an unwrapped phase.

Unary and Binary Operations

You may add a constant to each data point in a file using the ADD commands This is called a unary operation in SAC2000. Other unary commands include SUB, MUL, DIV, SQR, SQRT EXP, and LOG. You may also add two data files together using the ADDF command. This is called a binary operation in SAC2000. Other binary commands include SUBF, MULF, DIVF, and MERGE.

Correcting Signals

There are a number of commands available to correct or modify seismic signals.

RQ removes the seismic Q factor from spectral data.

RTM, RTREND, and RMEAN remove timing marks, the linear trend, and the mean, respectively, from time series data.

TAPER applies a symmetric taper to each end of the data.

ROTATE rotates a pair of data components through an specified angle in the plane of the components.

Phase Picking

APK applies an automatic event picking algorithm to seismic data. Output can be written to a HYPO formatted disk file or to a more general alphanumeric pick file. PLOTPK can also be used to pick and write phase information into these files.


This is only a partial list of SAC2000's analysis capabilities. The list grows with each release. A much more complete list is given in the Users Manual. Each command is described fully in the Command Reference Manual. If you have some ideas on commands or features that you think are missing, let us know. They just might wind up in the next version.