2 SAC ( “Seismic Analysis Code” ) was originally developed at Lawrence Livermore National Laboratory It is an interactive program for analyzing time-series data with emphasis placed on tools used to study seismic events. The most common uses for SAC include:Seismic phase pickingFourier transformsFilteringSignal stackingParticle motion (hodograms)SAC is a large program. It is comparatively user-hostile but not too difficult to get startedThe user manual is not particularly useful but the online manual is ok. Like a lot of freeware, once you have a feel for what you are doing, it gets much easier. Don't worry.Start simple, learn more complex tools only as you need them.Let's get started!
3 Sequence of numbers (e.g., a trace) What is a SAC file?It consists of a “header” followed by a series of numbers (a vector of floats).Most commonly the series of numbers represents a single function, usually a time series of ground motion as recorded by a seismometer. This is not always the case but we will talk about other SAC file content later.HeaderSequence of numbers (e.g., a trace)SAC is one of several “common” data formats used in seismology, and most seismologists have tools at their disposal to convert from one format to another. Other common formats include SEG-Y, SEED, SUDS, AH, SEISAN. Different formats are targeted at different anticipated uses. For instance, SEG-Y is most usually anticipated in exploration-type seismology (oil company reflection /refraction studies). AH is seldom used, being a rather 'niche' format developed in two different flavors at the Lamont-Doherty Earth Observatory and the U.S. Geological Society. But you may come across it when dealing with legacy data.The nice thing about SAC is that the header format is of a consistent, fixed length and is well-defined; it contains no surprises. Everyone “speaks” it.
4 What is a SAC header?A SAC header is simply a sequence of values of particular types and particular sizes, stored in a fixed order. The header stores information about the time, sampling, etc. of the data and on the location of the station and event. If you want to use a SAC file, you read the header, followed by the data vector (often called the “trace.”)Here is the layout ofpart of the header in aSAC file. We see herethat each variable is spe-cified with its location.We see a lot of “float”type header variables,followed by a few of type“int.” SAC headers alsocontain variables that arecharacter strings so wecan store the name of astation, for instance. Manyof these variables youwill not need to knowabout, but some will be important in your work.
5 So let's start up SAC......OK that was pretty easy. Let's look for a SAC file in the directory we are sitting in.IMPORTANT POINT TO REMEMBER: Some of the Unix/Linux commands you have learned can actually be invoked from within SAC. Like “ls” to make a directory listing.We now have the file in memory. We can look at it graphically, we can look at its header, or we can do something to it (filter, FFT, chop it into pieces, save it to disk after messing with it....)
6 Let's look at our header: Note the command “lh” is an ab-breviation for “list header.” ManySAC commands can be spelled outbut most of them also have a short-hand that saves typing. Importantheader variables include NPTS (thenumber of points, or samples, in thefile), DELTA (sample rate – here itis 100 samples per second, or deltaof 1/100).Hmmm. KZDATE,that's pretty self-explanatory. ThenKCMPNM (component name) EHZ.That tells me it's a vertical sensor.Oh, look, STLA, STLO, STEL:station lat, long and elevation.NETWORK = UW. Probably St. Helens.
7 Shall we take a look to see if it looks like a seismogram?
8 Let's examine the plot:* Horizontal axis (time) is reportedin seconds. Is this correct, consid-ering the NPTS and DELTA?* Look at the information in theupper right hand of the box. SACreports the station name and com-ponent and the time of the tracestart. Does this look correct?The Y-axis is usually reported in “points,”which is the digitized voltage output by theseismometer. This is related to vertical groundvelocity for this instrument (always a good guessbut the header actually told us this). If we wanted to see ground displacement wecould integrate (SAC will do this) or differentiate to see accelereation (SAC willalso do this).
10 In other words, manythings you mightwant to do to yourdata, you could doin SAC. You canType “help” followedby a guess at the com-mand and you mightget lucky.More useful would beto refer to the SAC usermanual, which can befound online byGoogling.
11 See the “command reference manual” links? If you know what you're See the “command reference manual” links? If you know what you'relooking for, go to “alphabetical.” If you're hunting for something thatyou want to do but don't know the command, search under “functional.”
13 Now, let's try to do something more useful. Let's say we want to look at the spectrum of our event.We can see that it is mostly lowerfrequencies but at the beginningthere is some low-amplitudehigher-frequency signal superimposedon the low-frequency (long-period).To look at the frequency, we have toperform a Fourier transform.Ordinarily when taking a FFT one should demean the data to remove any DCoffset (which transforms into a huge zero-frequency spike) and taper the windowto avoid high-amplitude truncations of the time series (which produces spectralleakage), but this example trace looks like someone has already done this. Solet's just look at the spectrum.
14 I ask it to plot the spectrum for me, but only show the amplitude spectrum (no phase).SAC default isa log-log plotof the signalamplitude as afuntion of fre-quency. Wecan change thisto be log-linor lin-log orlin-lin, as wechoose.
15 We can ask for the spectral plot again, but using linear/linear axes. Note this time we did not say “am” for amplitude, because SAC will keep in memoryour previous parameter until we change it. Below is the resulting plot. It goes out to50 Hz in frequency because our data is sampled at DELTA = 0.01 second. Thisis worth remember-ing – you cannotresolve frequencieshigher than HALFyour sample rate.This is called the“Nyquist frequency”and it tells you themaximum signalfrequency contentyour data possess.
16 Our data does not seem to report anything useful above about 17 Hz and the signal details are all squashed up against the left-hand part of the plot. Let's limit our Xaxis to go from 0 to 17 Hz:NOW we canbegin to see somedetails of the spec-trum! It looks likethere is quite a lotof energy below3 Hz and a separatepeak above 3 Hz.Let's get rid of everythingabove 3 Hz by applying a“lowpass” filter and see what's left of the seismogram.
17 Oops! What happened?“Illegal operation on spectral file....” Oh, of course. We don't have our original tracein memory any more, we have a spectrum. The filter operation is done on the seis-mogram itself. So we read it back into memory:Notice I just said “read,” without typing the filename. This is because SAC remem-Bers what it read before. NOW we can perform our filtering operation on the trace.If it were not demeaned and tapered already, we would do this. As it is, we can justlowpass it:
18 Now let's plot the trace again with the xlimit turned off: Whoops! What happened? Our trace isonly 9 seconds long but our axis goes to17 seconds......oh, right. We asked forxlim of 0 to 17 when we were lookingat the spectrum. Leave it to SAC to rem-ember! Well, that's easy:Now let's plot the trace again with the xlimit turned off:
19 That's better! Let's compare the filtered trace (top) to the original one (bottom). It looks likewe eliminated the high-frequency signal thatappears in the early part of the trace. So nowwe decide we want to save the filtered versionof this waveform. Let's call it exFilt1.SAC justbecause....I'd like to compare the two without having toread and plot them separately. There are twoways to do this:
20 If I already have one trace in memory and want to Read another, if I just say “read” it will overwritethe current one. So I can read one in and then say“read more.”Alternatively I can say “read” followed by a list of the desired files. If I ask for“plot” it will plot them one at a time (move to the next plot by hitting the return key).If I want to see them both in a single plot, I need to say “plot1.”(shorthand for plot is p and plot1is p1 oh, BTW shorthand for readis r and, no surprise, write is w)
22 ….and so on. Notice what happened when I said “p2”
23 color on list black red; p2 Just for giggles let's look at the spectra for both:fft; plotsp am linlin;color on list black red; p2Interesting comparison. But this is the spectrum for the WHOLE traces.We know the high frequencies occur in the eraly part. Can we see a time-varying spectrum? Sure: it's called a spectrogram.
24 “ymax 17” tells it not to plot any frequncies above 17 Hz – we know this from looking atthe FFT.And here we have aspectrogram for seismictrace example1.SAC. Thespectrogram is only 8 sec-onds long because thedefault overlap of 100samples shortens it. Wecan adjust numerousparameters of the spec-trogram function as ex-plained in the interactive“help.” The spectrogramshows frequencies on theY axis and time on the Xaxis, amplitudes are color-coded as per the color bar on the left.
25 Let's read in several traces and identify some P-wave picks. SAC's picking fun-ction is called PPK.We enter the PPK modeby simply typing ppk thenwe interact with mouse andkeyboard to put picks on thetraces (actually into theirheaders).
26 Zoom is accomplishedby typing “X” for theleft-hand limit andclicking the first mousebutton for the right-handlimit.
27 Picks are made by positioning the cursor over the part of the trace you want to apply the pick, then typing “p” or “a” on the keyboard. A vertical line will appear on the trace you just picked. Tradi-tionally P-wave picks are assigned to the “a” header variable in SAC. We exit the PPK functionby typing “q” with the cursor some where in the graphics window. Picks are stored in memory; ifwe want to save them with the files, we must overwrite the files (“write”).
28 We can look at the picks as stored in the headers using the “lh” com-mand followed by the assignedheader variable (“a”). We canChange them as often as we likebefore saving the files with“write,”and we can always changeThem after we have written themto the files by reading in and goingthrough the pick procedure again.S-wave picks are typicallystored in variable T0.
29 Let's look at some multicomponent data. R = radialT = transverseZ = verticalSignals for a nearby shallowexplosion. How do we knowthe Z component was ac-tually recorded upside-down? Let's zoom in:
30 Hint: Explosions can be viewed to first order as radiating a spherical wavefront away from the source, that is compressional in all directions. What is wrong with our verticalcomponent?We would like to lookat the particle motion ofground movement at thisstation in the vertical-radial plane. SAC hasa function “ppm” to al-low us to do this.
31 Well, this is a mess.Let's look at a smallertime window.
32 By limiting the length of the time segment, we can see the details ofthe ground motion starting at thefirst-arriving P-wave.This capability is very useful for iden-tifying wave types in a seismogramsince P and S and surface waves havedistinct associated ground motions.
33 You have learned a little bit about UNIX / LINUX commands. You know that if you need to execute the same command overand over again, you can write a script that will do it for you.The same thing is true for SAC commands. We can write ascript of SAC commands that will execute without you havingto sit there and type over and over and over. We call this a SAC“macro.”We usually create our SAC macros in a shell script and then executethem from within SAC. For example: Say I have ten traces I wantto read, one at a time, and I want to pick each one and overwrite itbefore looking at the next one. My SAC macro will look somethinglike this:
34 I have called this file “pickmacro.” From within SAC I run the macro: And it starts showing me the traces, one at a time, entering PPK, waiting for me tomake my pick and quit (“q”) out of PPK, then it writes over the file and reads thenext one, and enters PPK for me.
35 SAC macros can be highly complex and sophisticated, performing tasks as varied as making calculations based on header values to producing oil company type shot or receiver gathers, plotting spectral phase functions for surface wave dispersion analysis, and manipulating SAC graphics to produce figures for publication.Using your UNIX/Linux scripting skills you can generate a SAC macro in very short order that addresses long lists of waveforms on which you need to operate, with a minimum of typing.Following is an example of a c-shell script that generates a SAC macro to pick trace MGAT.CHz within each of 236 event directories:#!/bin/tcshcd /home/char/Montserrat/data/bin/ls |grep 9509 > templistecho "qdp off" > pickmacroforeach tracedir (`cat templist`)echo "read "$tracedir"/MGAT.CHz; ppk; write over;" >> pickmacroend/bin/rm templist
36 foxtrotterlanlgov:data char$ more pickmacro qdp offread /MGAT.CHz; ppk; write over;read /MGAT.CHz; ppk; write over;read /MGAT.CHz; ppk; write over;read /MGAT.CHz; ppk; write over;read /MGAT.CHz; ppk; write over;read /MGAT.CHz; ppk; write over;(etc.)This macro addresses 236 trace files – imagine how much typing it saves! Now we simply start up SAC and type “macro pickmacro” and we’re offSUMMARY: SAC is a seismic data analysis tool that is ubiquitous in the seismological community. If you are dealing with earthquake data you will almost certainly need to understand and use SAC. If you use other analysis tools, you will probably see that the tools invoke SAC capabilities or read SAC format files, so being acquainted with the structure of SAC data will be helpful.
Your consent to our cookies if you continue to use this website.