Seismic Analysis Code (SAC)

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Importing TEM Data into IX1D v 3 using TEM2IX1D– A Tutorial © 2012 Interpex Limited All rights reserved Version 1.0.
Introduction to Programming using Matlab Session 2 P DuffourJan 2008.
Chapter 8 Improving the User Interface
Introduction to Matlab
Seismic Analysis Code (SAC)
Visual Basic for Applications. What it does Extends the features and built in functions of Excel – Create and run VB procedures – Some may be easy to.
Getting Started: Ansoft HFSS 8.0
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C Programming
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
ITEC113 Algorithms and Programming Techniques
UNESCO ICTLIP Module 4. Lesson 3 Database Design, and Information Storage and Retrieval Lesson 3. Information storage and retrieval using WinISIS.
Taking Core Products a Step Further USG Software and Customized Applications.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Using Objects and Properties
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Database Design IST 7-10 Presented by Miss Egan and Miss Richards.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
Lesson 1 – Microsoft Excel The goal of this lesson is for students to successfully explore and describe the Excel window and to create a new worksheet.
MATLAB File Management. MATLAB User File Management Matlab provides a group of commands to manage user files. For more information, type help iofun. pwd.
Introduction to Shell Script Programming
Fortran 1- Basics Chapters 1-2 in your Fortran book.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
CS 497C – Introduction to UNIX Lecture 7: General-Purpose Utilities Chin-Chih Chang
Linux+ Guide to Linux Certification, Third Edition
CS465 - UNIX The Bourne Shell.
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
CREATING TEMPLATES CREATING CUSTOM CHARACTERS IMPORTING BATCH DATA SAVING DATA & TEMPLATES CREATING SERIES DATA PRINTING THE DATA.
Key Applications Module Lesson 21 — Access Essentials
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Security Panel Application Introducing the Select Case Multiple-Selection Statement.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Praat LING115 November 4, Getting started Basic phonetic analyses with Praat –Creating sound objects Recording, reading from a file, creating from.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
Chapter Three The UNIX Editors.
CS 330 Programming Languages 10 / 02 / 2007 Instructor: Michael Eckmann.
You Need an Interpreter!. Closing the GAP Thus far, we’ve been struggling to speak to computers in “their” language, maybe its time we spoke to them in.
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
Agenda Positional Parameters / Continued... Command Substitution Bourne Shell / Bash Shell / Korn Shell Mathematical Expressions Bourne Shell / Bash Shell.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
Postgraduate Computing Lectures PAW 1 PAW: Physicist Analysis Workstation What is PAW? –A tool to display and manipulate data. Learning PAW –See ref. in.
Introduction to Programming Python Lab 5: Strings and Output 05 February PythonLab5 lecture slides.ppt Ping Brennan
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Linux Administration Working with the BASH Shell.
Introduction to Programming
Python: Experiencing IDLE, writing simple programs
SQL and SQL*Plus Interaction
Using SQL*Plus.
Shell Programming (ch 10)
Variables, Expressions, and IO
WEB PROGRAMMING JavaScript.
Introduction to Programming
JavaScript: Introduction to Scripting
Input and Output Python3 Beginner #3.
Introduction to Programming
Presentation transcript:

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 You can also use PPK to pick phases using the graphics cursor. (PPK is described in the section on Graphics Capabilities).

Event Analysis Module These 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.

SAC> ppk #opens an x window with all data loaded in memory SAC> 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 window zoom 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 header quit: type "q"

example

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.

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.

example: Creating a plot %vim plot1.macro r BJT.BHZ* BJT.BHN* BJT.BHE* xvport 0.1 0.6 qdp off xlim t1 -5 50 title on "Sumatra Event 2/13/2005 1:22:09 at BJT" xlabel on "Time, sec" ylabel on "Digital Counts" bd sgf p1 ed sgf sgftops f001.sgf plot1.ps 1 y

example: Creating a plot There are two ways to run the sac macro From within sac %sac SAC>macro plot1.macro or From the command line %sac plot1.macro (may not work) %sac < plot1.macro

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

order dependent arguments %vim prt.macro r $1 $2 $3 xvport 0.1 0.6 qdp off xlim t1 -5 50 xlabel on "Time, sec" ylabel on "Digital Counts" bd sgf p1 ed sgf sgftops f001.sgf plot1.ps 1 y sac>macro prt.macro BJT.BHZ.SAC BJT.BHN.SAC BJT.BHE.SAC

SGFTOPS: Converts an SGF file to a POSTSCRIPT formatted file. SGFTOPS sgf-file ps-file {width} {YES|NO} {scale} INPUT sgf- file

sgs-file: name of a SAC Graphics File 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.

YES|NO : Flag to apply additional scaling 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.

keyword driven arguments %vim plot3.macro $keys files plot r $files xvport 0.1 0.6 qdp off xlim t1 -5 50 title on "Sumatra Event 2/13/2005 1:22:09 at BJT" xlabel on "Time, sec" ylabel on "Digital Counts" bd sgf p1 ed sgf sgftops $plot plot3.ps 1 y sac>macro plot3.macro files BJT.BHZ.SAC BJT. BHN.SAC BJT.BHE.SAC plot f001.sgf

default arguments %vim plot3.macro $keys files plot $default plot f001.sgf r $files xvport 0.1 0.6 qdp off xlim t1 -5 50 title on "Sumatra Event 2/13/2005 1:22:09 at BJT" xlabel on "Time, sec" ylabel on "Digital Counts" bd sgf p1 ed sgf sgftops $plot plot3.ps 1 y sac>macro plot3.macro files BJT.BHZ.SAC BJT.BHN_SAC BJT.BHE.SAC

Missing keyword arguments argument query If 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.macro files? BJT.BHZ.SAC BJT.BHN.SAC BJT.BHE.SAC

Blackboard Variables The 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

Blackboard entries are created using the SETBB and EVALUATE commands. sac> setbb c1 2.45 sac> setbb c2 4.94 sac> 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

You can also set blackboard variables using the EVALUATE command sac>evaluate to c2 %c1 * 2 Setting bb variable c2

The value of a blackboard variable can be obtained using the GETBB command. sac> getbb c1 c2 c1 = 2.45 c2 = 4.9000001e+00

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.

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 ABC SAC> evaluate to temp1 &ABC,a + 10 #reference by file name SAC> evaluate to temp2 &1,depmax * 2 #reference by file number SAC> chnhdr t5 %temp1 SAC> chnhdr user0 %temp2

Variable Concatenation To prepend simply concatenate the text string with the argument or variable. sac> setbb temp BJT.BHZ.SAC sac> w XYZ.%temp XYZ.BJT.BHZ.SAC

Variable Concatenation To append you must repeat the delimiter ($, %, or &) after the argument or variable and before the text string. sac> w %temp%.XYZ BJT.BHZ.SAC.XYZ

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).

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 q EOF end

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.m end What is this awk line testing?

continued from previous… (page 3 or 3) echo qdp off >> sta.m echo gtext size tiny >> sta.m echo picks on >> sta.m echo fileid type list kstcmp kzdate kztime az gcarc >> sta.m echo bd x >> sta.m echo rmean >> sta.m echo rtrend >> sta.m echo ppk rel perplot 4 >> sta.m sac sta.m Run the new sac macro sta.m

Using shell scripts to run SAC #!/usr/bin/csh ch evla %evlat foreach file ( *.SAC ) ch kevnm %eqname echo $file wh sac << EOF >>! log cut o 0 8000 setbb eqname Sum_2002_EGF setbb evlat 2.84 setbb chg2 &1,o setbb evlon 95.38 ch allt -%chg2 setbb chg 6.002 w over q r $file EOF setbb old &1,o evaluate to new %old + %chg end ch o %new ch evlo %evlon

Notice importance of - Organization/structure - Naming conventions Take advantage of them to automate processing.

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.