2Seismic Analysis Code (SAC) Basic Data Manipulation
3SACSeismic Analysis Code was developed at Lawrence Livermore National Laboratory and University of California in the early 1980's.It is a command-driven program generally implemented on many types of UNIX operating systems and has become a standard data manipulation tool in seismology.Its binary data format is one of the principle data formats used today in storing and manipulating seismological time series data.
4SAC was designed as an aid to research seismologists in the study of seismic events. As such, it is used for quick preliminary analyses, for routine processing, for testing new techniques, for detailed research, and for creating publication quality graphics.ceri% sacSEISMIC ANALYSIS CODE [09/04/2008 (Version 101.2)]Copyright 1995 Regents of the University of CaliforniaSAC>
5What can it do? Interactively read seismogram data Perform many standard data processing operations, such asFilteringTime picksAmplitude picksCorrelationFourier transformsSeismic instrument correctionsParticle motion rotationTrace envelopesSpectral ratiosLinear regressionsFrequency-wavenumber analysisCreate a variety of plots of the data and resulting analysis
6SAC’s competitors (analysis) Various versions of DATASCOPE (now Antelope)MATSEIS/Coral other Matlab based programsSEISANXPICKSeismic UNIXothers
7SAC’s competitors (data format) SEED (Standard for the Exchange of Earthquake Data)SEISAN (widely used in Central and South America/Europe)CSS (Center for Seismic Studies, associated with treaty verification)SUDS (Seismic Unified Data System, from Willie Lee PC based system/USGS)SEG-Y (the standard for seismic reflection data)AH (Ad Hoc, pre-SEED shows up from AVO/HVO, etc. in archives)Others (new ones crop up every 5-10 years to address the chaotic state of affairs.)
8Commands SAC commands fall into three main categories Parameter-setting: change values of internal SAC parametersAction-producing: perform some operation on the signals currently in selected memory based upon the values of these parametersData-set: determine which files are in active (selected) memory and therefore will be acted upon
9Commands HELP calls up a list of all commands help command can be used to view manual pages
10DefaultsIn order to make SAC quick to learn and easy to use, default values for all operational parameters were carefully chosen.At the same time, almost all of these parameters are under direct user control.SAC can be reinitialized to this default state at any time by executing the INICM command.
11Data Format and HeaderEach signal or seismogram is stored in a separate binary or alphanumeric data file.SAC can read data in a variety of formats:SAC Binary Format (most common)CSS formatSDD formatASCII formatsEach data file contains a header that describes the contents of that file.
12listhdr (lh): lists the headers of the files in memory. SAC> listhdrFILE: ccm_sumatra_.bhe - 1NPTS =B = e+00E = e+04IFTYPE = TIME SERIES FILELEVEN = TRUEDELTA = e-02IDEP = UNKNOWNDEPMIN = e+06DEPMAX = e+06DEPMEN = e+02OMARKER = (origin )KZDATE = DEC 26 (361), 2004KZTIME = 01:09:52.684IZTYPE = BEGIN TIMEKSTNM = CCMCMPAZ = e+01CMPINC = e+01STLO = e+01DIST = e+03AZ = e+02BAZ = e+02LOVROK = TRUENVHDR = 6LPSPOL = TRUELCALDA = TRUEKCMPNM = BHEKNETWK = USlisthdr (lh): lists the headers of the files in memory.
13TimeThe SAC header contains a reference or zero time, stored as six integers (NZYEAR, NZJDAY, NZHOUR, NZMIN, NZSEC, NZMSEC), but normally printed in an equivalent alphanumeric format (KZDATE and KZTIME).SAC> lh #list headerFILE: GRAT.EHZ.NM – 1 #this is a partial headerNPTS =B = e+00E = e+03IFTYPE = TIME SERIES FILEDELTA = e-02KZDATE = APR 06 (097), 2008KZTIME = 02:59:59.320
14Event and Station Info SAC header can store station and event info SAC> lhFILE: WMQ.BHZ.D :KSTNM = WMQSTLA = e+01STLO = e+01STEL = e+02EVLA = e+00EVLO = e+01EVDP = e+01
15Once the event and station information are store, the program automatically calculates and stores distance (km), azimuth (degrees), backazimuth (degrees), and great circle arc length (degrees)DIST = e+03AZ = e+02BAZ = e+02GCARC = e+01
16Phase InfoSAC can be used to pick and store phase information in header variables A & T0-T9. The Omarker is reserved to for the origin time. All pick and origin times are stored in secs from the zero time of the file.OMARKER = 0AMARKER #not set in this exampleT0MARKER #not set in this exampleT1MARKER = (P)T2MARKER = (S)T4MARKER = (pP)T6MARKER = (sP)
17Data File Command Module This module is used to read, write, and access SAC data files.READ (r): reads data files from disk into memorySAC> r *.SAC #read any files that end in .SACUses standard UNIX wildcards: reads all files whose filenames end in “.SAC”
18Data File Command Module WRITE (w): writes the data currently in memory to diskYou can write manipulated data into a range of file formats or simply overwrite the current set of files (so be careful, you have been warned!)
19Let’s try it (and also jump ahead to graphics action module to plot (“p”) it) – SEISMIC ANALYSIS CODE [8/8/2001 (Version )]Copyright 1995 Regents of the University of CaliforniaSAC> read ccm_sumatra_.bhzSAC> plot
20Let’s try it (and also jump ahead to graphics action module to plot (“p”) it) – SEISMIC ANALYSIS CODE [09/04/2008 (Version 101.2)]Copyright 1995 Regents of the University of CaliforniaSAC> read ccm_sumatra_.bhzSAC> plot
21This seismogram is 20,000 seconds long, with samples 20 times per second. It has over 3,890,000 points and would take almost an hour to draw at 9600 baud, which was the rate of computers when SAC originally written.
22Enter QDP (Quick and Dirty Plot mode) to the rescue. Look at the lower right corner. There is a box there with the number 779.This tells us that SAC is displaying every 779th point (that’s one point every 39 seconds).
23Since we are on a modern computer we can afford to plot all the data So we turn the QDP “feature” offSAC> qdp offSAC> plotThis plot is now “good”.
24So far there is one file in memory So far there is one file in memory. If we simply read in another one – it will clobber what we have there.If we need to read in more data (say we have processed the data we’ve read in and now want a spectral ratio of the processed data with the original data) we have to use the “more” option to read in the additional data.SAC>read more filename
25In general SAC does commands to all the files in memory. If the command is starting from scratch (like a read) it clobbers what is already there.Some commands require certain pairs of files
26Let’s try a few more things. Here I have to be a little more careful when I specify the file name. I want to read in all 3 components of the seismogram.SAC> ls *sumatra*bh*ccm_sumatra_.bhe ccm_sumatra_.bhn ccm_sumatra_.bhz ccm_sumatra_bhz.ai ccm_sumatra_bhz.ps ccm_sumatra_bhz.tifSAC> r *sumatra*bh?ccm_sumatra_.bhe ccm_sumatra_.bhn ccm_sumatra_.bhz
27Try the plot command.SAC> plotWaitingSAC plots the traces one at a time, in the order they are stored in memory. Each time you enter a <CR> it plots the next trace.(and says Waiting if there are more traces to display, or the prompt if not).
28New command – plot1 ( “p1”). SAC> plot1SAC>This command plots all the data in memory on one plot.
29Say I want to process these three traces together. Notice that the three traces do not start at the same time (and we will see that they are not the same lengths, either).
30We can fix the time alignment using synchronize (“synch”): which modifies the headers of the files in memory so that they all have the same reference time.SAC> synchSAC> plot1
32Data File Command Module CUT: defines how much of a data file is to be read.Need to reread the data after specifying a cutSAC> cut t #cuts 5 s before, 30 s after t1 pickSAC> rWMQ.BHZ.D :
33READHDR (rh) and WRITEHDR (wh): read and write headers without the data LISTHDR (lh): list the header contentsCHNHDR: change header valuesCOPYHDR: copy header values from one file to the others in memory
34example:SAC> r WMQ* SAC> chnhdr a SAC> lh picks FILE: WMQ.BHZ_10.Q.2004:18:52: NPTS = 1401 B = e+02 E = e+02 OMARKER = 0 AMARKER = T1MARKER = (Pi) SAC> wh #only overwrite the header because not changes were made to the time series
35Graphics Action Module PLOT (p): plots each signal in memory on a separate plot.PLOT1 (p1): plots a set of signals on a single plot with a common x axis and separate y axes.PLOT2 (p2): plots a set of signals on a single plot with common x and y axes (i.e. an overlay plot).
36SAC> r WMQ. AAK. WMQ. BHZ_10. Q. 2004:18:52:27 AAK. BHZ_00. Q SAC> r WMQ* AAK* WMQ.BHZ_10.Q.2004:18:52:27 AAK.BHZ_00.Q.2004:18:52:53 SAC> r more BJT* BJT.BHZ_00.Q.2004:18:50:19 SAC> plot Waiting
39Graphics There are three graphics ``devices'' currently supported. SGF is a general purpose device driver representing a large class of actual physical devices.XWINDOWS is a general windowing system running on most high-resolution, bit-mapped graphics workstations.SUNWINDOW, is a windowing system that was available on the Sun in SunOS 4.X.
40Xwindows or XX is widely used on the graphics workstation and offers one of the best frameworks for developing portable window-based applications.Should be the default graphics device.Can be turned on using the begin device (bg) commandsac> bd x
41SGF (SAC Graphics File) SAC Graphics File contains all the information needed to generate a single plot on any graphics device.Each plot is stored in a separate file. The file names are of the form ``Fnnn.SGF'' where ``nnn'' is the plot number, beginning with ``001''.Can be turned on usingsac> bd sgf
42To create a postscript plot, you would turn on the sgf device, create your plot, and then run a conversion program called sgftopsSAC> bd sgfSAC> p1 rel #plot waveform to file f001.sgfSAC> sgftops f001.ps newplot.psSAC> ls newplot.psnewplot.psSAC> bd x #or ed sgf