SAC Tutorial Two

2.1 Writing Data Files

SAC commands work on data already in SAC's working memory, not data on disk. If you want to store data currently in SAC's memory into a file, use the WRITE command (abbreviated as W). The data files on disk are not modified by future changes to data in SAC's memory. In the example below, we will modify a file by multiplying the data in memory by a factor of two with the MUL command. 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. We'll try using the WRITE command to generate some data files in a new directory called sac.

[username@veracruz ~] mkdir sac
[username@veracruz ~] cd sac
[username@veracruz sac] sac

SAC> FG SINE 2 NPTS 200 DELTA 0.01
SAC> P
SAC> WRITE SINE.2.SAC
SAC> FG SINE 4
SAC> P
SAC> W SINE.4.SAC
SAC> MUL 2
SAC> P
SAC> W OVER
SAC> FG IMPULSE
SAC> P
SAC> W IMPULSE.SAC
SAC> LS

Do you see the 3 files you just created?

2.2 Reading Data Files

The READ command is then used to transfer data from disk to memory (abbreviated as R). Up to 200 data files can be in memory at the same time. 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.

SAC> READ SINE.2.SAC
SAC> P
SAC> R MORE SINE.2.SAC
SAC> P

Notice that the PLOT command only shows one data file at a time, asking for you to hit enter in between each data file. Several other plot formats are available. PLOT1 plots each file along a common x axis but with a separate y axes (abbreviated P1). By default all files are placed on the same plot. Try this with all of the data files using a wildcard to help read the files.

SAC> R *.SAC
SAC> PLOT1

PLOT2 is an overlay plot (abbreviated P2). Again all files are plotted together, this time using both a common x and a common y axis.

SAC> PLOT2

PLOTPK uses a format similiar to PLOT1 (abbreviated PPK). It lets you use the cursor to blow up parts of the plot, determine values of selected data points, pick phase arrival times, etc.

SAC> PPK

Place the cursor where you would like the zoomed in view to start and type X to mark it. Now move the cursor to where you want the zoomed view to end and type X again. The view should now be zoomed in to that range. Type Q to exit from the PPK command.

Now we should modify the data and write it to new file names. Using the data currently in memory, we can downsample the data by a factor of five using DECIMATE (it also applies an anti-aliasing filter). Then we can write the results back to disk using the PREPEND option to change the file names.

SAC> DECIMATE 5
SAC> W PREPEND DEC.
SAC> QUIT

% ls

Exercise 6.1

What are the new file names? How would you read them back into SAC? Store your answers in a file called readwrite.txt.

Summary

WRITE Writes data in memory to disk.
MUL Multiplies each data point by a constant.
READ Reads data from SAC data files on disk into memory.
PLOT1 Generates a multi-trace multi-window plot.
PLOT2 Generates a multi-trace single-window (overlay) plot.
PLOTPK Produces a plot for the picking of arrival times.
DECIMATE Downsamples data in memory, including an optional anti-aliasing filter.

 

brudzimr@muohio.edu, 19th June 2007