seismic analysis code (sac)

34

Upload: gore

Post on 24-Feb-2016

78 views

Category:

Documents


0 download

DESCRIPTION

Seismic Analysis Code (SAC). Blackboard Variables & Macros. Event Analysis Module. This module is used to pick seismic phases. An automatic phase picking algorithm can be applied using APK. Event Analysis Module. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Seismic Analysis Code (SAC)
Page 2: Seismic Analysis Code (SAC)

Seismic Analysis Code (SAC)

Blackboard Variables & Macros

Page 3: Seismic Analysis Code (SAC)

Event Analysis Module

This module is used to pick seismic phases.

An automatic phase picking algorithm can be applied using APK.

Page 4: Seismic Analysis Code (SAC)

Event Analysis Module

You can also use PPK to pick phases using the graphics cursor. (PPK is described in the section on Graphics Capabilities).

Page 5: Seismic Analysis Code (SAC)

Event Analysis ModuleThese picks can be saved in HYPO format using the

OHPF (open HYPO pick file) and CHPF (close HYPO pick file) commands; WHPF writes auxiliary cards into the HYPO pick file.

These picks can also be saved in a more general Alphanumeric format using the OAPF (open alphanumeric pick file) and CAPF (close alphanumeric pick file) commands.

The picks are also saved in the headers.

Page 6: Seismic Analysis Code (SAC)

SAC> ppk #opens an x window with all data loaded in memorySAC> ppk perplot 6 #open 6 files at a time

# cheat sheet:click on window to make it active zoom in: type "x" to define left side time window, followed by a left click of

mouse to define the right side time windowzoom out: type "o"p arrival: type "a", or "p" at the time where you think the p wave arrival in.

s arrival: type "t0", or "s" at the time where you think the s wave arrival in.other phases: type “tX” to place that time in your preferred headerquit: type "q"

Page 7: Seismic Analysis Code (SAC)

example

Page 8: Seismic Analysis Code (SAC)

What is a SAC macro?A SAC macro is a file that contains a set of SAC

commands to be executed together.

As well as regular commands and inline functions, a SAC macro file can contain references to SAC header variables and blackboard variables that are evaluated and substituted into the command before it is executed.

Page 9: Seismic Analysis Code (SAC)

What is a SAC macro?

SAC macros can also have arguments that are evaluated as the macro is executed.

Control flow features such as ``if tests'' and ``do loops'' are also available. These features let you control and alter the order of execution of commands within a macro.

Page 10: Seismic Analysis Code (SAC)

example: Creating a plot%vim plot1.macro

r BJT.BHZ* BJT.BHN* BJT.BHE*xvport 0.1 0.6qdp offxlim t1 -5 50title on "Sumatra Event 2/13/2005 1:22:09 at BJT"xlabel on "Time, sec"ylabel on "Digital Counts"bd sgfp1ed sgfsgftops f001.sgf plot1.ps 1 y

Page 11: Seismic Analysis Code (SAC)

example: Creating a plotThere are two ways to run the sac macro

From within sac

%sacSAC>macro plot1.macro or

From the command line

%sac plot1.macro (may not work)

%sac < plot1.macro

Page 12: Seismic Analysis Code (SAC)

r BJT.BHZ* BJT.BHN* BJT.BHE*xvport 0.1 0.6qdp offxlim t1 -5 50title on "Sumatra Event 2/13/2005 1:22:09 at BJT"xlabel on "Time, sec"ylabel on "Digital Counts"bd sgfp1ed sgfsgftops f001.sgf plot1.ps 1 y

Page 13: Seismic Analysis Code (SAC)

order dependent arguments

%vim prt.macror $1 $2 $3xvport 0.1 0.6qdp offxlim t1 -5 50xlabel on "Time, sec"ylabel on "Digital Counts"bd sgfp1ed sgfsgftops f001.sgf plot1.ps 1 y

sac>macro prt.macro BJT.BHZ.SAC BJT.BHN.SAC BJT.BHE.SAC

Page 14: Seismic Analysis Code (SAC)

SGFTOPS: Converts an SGF file to a POSTSCRIPT formatted file.

SGFTOPS sgf-file ps-file {width} {YES|NO} {scale} INPUT sgf-file

Page 15: Seismic Analysis Code (SAC)

sgs-file: name of a SAC Graphics File.

ps-file : The desired name for the POSTSCRIPT file.

width : A number specifying the width or thickness of lines in the output file. This is an integer in the range 1 to 8. Default is 1.

Page 16: Seismic Analysis Code (SAC)

YES|NO : Flag to apply additional scaling.

A value of YES turns scaling on, NO ignores the additional scale parameter.

scale : An additional scale factor. Can be used for making large or full-size maps.

Page 17: Seismic Analysis Code (SAC)

keyword driven arguments%vim plot3.macro

$keys files plotr $filesxvport 0.1 0.6qdp offxlim t1 -5 50title on "Sumatra Event 2/13/2005 1:22:09 at BJT"xlabel on "Time, sec"ylabel on "Digital Counts"bd sgfp1ed sgfsgftops $plot plot3.ps 1 y

sac>macro plot3.macro files BJT.BHZ.SAC BJT. BHN.SAC BJT.BHE.SAC plot f001.sgf

Page 18: Seismic Analysis Code (SAC)

default arguments%vim plot3.macro

$keys files plot$default plot f001.sgfr $filesxvport 0.1 0.6qdp offxlim t1 -5 50title on "Sumatra Event 2/13/2005 1:22:09 at BJT"xlabel on "Time, sec"ylabel on "Digital Counts"bd sgfp1ed sgfsgftops $plot plot3.ps 1 y

sac>macro plot3.macro files BJT.BHZ.SAC BJT.BHN_SAC BJT.BHE.SAC

Page 19: Seismic Analysis Code (SAC)

Missing keyword arguments

argument queryIf you fail to enter a value for an argument on

the execute line and it has no default value, SAC will ask you to enter a value from the terminal.

SAC> macro plot3.macrofiles? BJT.BHZ.SAC BJT.BHN.SAC BJT.BHE.SAC

Page 20: Seismic Analysis Code (SAC)

Blackboard VariablesThe blackboard feature can be used to

temporarily store and retrieve information.

A blackboard entry consists of a name and a value.

They are used extensively in macros

Page 21: Seismic Analysis Code (SAC)

Blackboard entries are created using the SETBB and EVALUATE commands.

sac> setbb c1 2.45sac> setbb c2 4.94sac> bp butter co %c1 %c2

sac>evaluate %c1 * 2 #default is to print to terminal

4.9000001e+00

The % is used to indicate a blackboard variable

Page 22: Seismic Analysis Code (SAC)

You can also set blackboard variables using the EVALUATE command

sac>evaluate to c2 %c1 * 2Setting bb variable c2

Page 23: Seismic Analysis Code (SAC)

The value of a blackboard variable can be obtained using the GETBB command.

sac> getbb c1 c2 c1 = 2.45 c2 = 4.9000001e+00

Page 24: Seismic Analysis Code (SAC)

• Blackboard variables can also be saved in a disk file using the WRITEBBF command

• and later restored into SAC using the READBBF command.

• UNSETBBV: deletes a variable from the blackboard.

Page 25: Seismic Analysis Code (SAC)

Header variables SAC header variables can also be evaluated and substituted

directly in commands much like blackboard variables.

You must specify which file (by name or number) and which variable to be evaluated.

You must precede this specification with an ampersand (``&'') and you must separate the file and variable with a comma

SAC> read ABCSAC> evaluate to temp1 &ABC,a + 10 #reference by file nameSAC> evaluate to temp2 &1,depmax * 2 #reference by file numberSAC> chnhdr t5 %temp1SAC> chnhdr user0 %temp2

Page 26: Seismic Analysis Code (SAC)

Variable ConcatenationTo prepend simply concatenate the text string

with the argument or variable.sac> setbb temp BJT.BHZ.SACsac> w XYZ.%tempXYZ.BJT.BHZ.SAC

Page 27: Seismic Analysis Code (SAC)

Variable Concatenation

To append you must repeat the delimiter ($, %, or &) after the argument or variable and before the text string.

sac> w %temp%.XYZBJT.BHZ.SAC.XYZ

Page 28: Seismic Analysis Code (SAC)

Using various programs to write SAC macros

SAC macros are essentially just a set of ordered commands and therefore you can create sac macros using other programs (shell scripts, fortran, C, matlab, etc).

Page 29: Seismic Analysis Code (SAC)

Example using csh (page 1 of 3)

#!/usr/bin/csh# Script to bring up SAC files for a given station that have a P

arrival# and repick the P arrival if necessary# usage: sta.csh [NAME]\rm sta.log

set sta=$1

foreach file (*.$sta*BHZ*) sac <<EOF >! sta.log r $file lh b e t1 qEOFend

Page 30: Seismic Analysis Code (SAC)

continued from previous… (page 2 of 3)

echo "xlim t1 -20 70" >! sta.m

#more sta.log …. An example of what sta.log should look like# FILE: BJT.BHE_00.Q.2005.01:23:41 - 3# --------------------------------## b = 1.456230e+02# e = 1.438873e+03# t1 = 4.480804e+02

awk '{if (/FILE/) f=$2; if ($1=="b") b=$3; if ($1=="e") e=$3; \ if (/t1/ && $3>b && $3<e) \

print "r more",f}' sta.log >>! sta.mend

What is this awk line testing?

Page 31: Seismic Analysis Code (SAC)

continued from previous… (page 3 or 3)

echo qdp off >> sta.mecho gtext size tiny >> sta.mecho picks on >> sta.mecho fileid type list kstcmp kzdate kztime az gcarc >> sta.mecho bd x >> sta.mecho rmean >> sta.mecho rtrend >> sta.mecho ppk rel perplot 4 >> sta.m

sac sta.m Run the new sac macro sta.m

Page 32: Seismic Analysis Code (SAC)

Using shell scripts to run SAC#!/usr/bin/cshforeach file ( *.SAC )echo $file

sac << EOF >>! logsetbb eqname Sum_2002_EGFsetbb evlat 2.84 setbb evlon 95.38setbb chg 6.002

r $file setbb old &1,oevaluate to new %old + %chgch o %newch evlo %evlon

ch evla %evlatch kevnm %eqnamewh

cut o 0 8000r $filesetbb chg2 &1,och allt -%chg2w over qEOF

end

Page 33: Seismic Analysis Code (SAC)

Notice importance of

- Organization/structure

- Naming conventions

Take advantage of them to automate processing.

Page 34: Seismic Analysis Code (SAC)

Try to automate as much as possible.

- Saves time if have to do it over and over.

- Documents what you did – you can reproduce it exactly.