aimbat documentation - read the docs · aimbat documentation release 0.2.1 lay ... for efficiently...

67
AIMBAT Documentation Release 0.2.1 Lay Kuan Loh, Xiaoting Lou, & Suzan van der Lee August 08, 2016

Upload: docong

Post on 28-Jul-2018

236 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT DocumentationRelease 0.2.1

Lay Kuan Loh, Xiaoting Lou, & Suzan van der Lee

August 08, 2016

Page 2: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix
Page 3: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

Contents

1 Introduction 31.1 About AIMBAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Associated Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Authors’ Contacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Installing Dependencies 52.1 Getting your operating system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Github . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.3 MacPorts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.4 Python and its Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.5 Installing Basemap without MacPorts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.6 Fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.7 Possible Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

3 Installing AIMBAT 133.1 Getting the Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.2 Building the Pysmo Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.3 Example Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

4 Upgrading AIMBAT 154.1 Getting the latest version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.2 Possible Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

5 Getting Data 195.1 Obspy.fdsn for downloading data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195.2 Standing Order for Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195.3 Wilber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

6 SAC Input/Output procedures for AIMBAT 236.1 Converting from SAC to PKL files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236.2 Converting from PKL to SAC files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

7 Analyzing Data 257.1 Seismic Analysis Code (SAC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

8 Parameter Configuration 278.1 Backend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278.2 Configuration File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

i

Page 4: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

9 SAC Data Access 319.1 Python Object for SAC File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319.2 Python Pickle for SAC Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339.3 SAC Plotting and Phase Picking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359.4 SAC Phase Picking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

10 Measuring Teleseismic Body Wave Arrival Times 4510.1 Automated Phase Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4510.2 Picking Travel Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4610.3 What the Alignments Stand For . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5110.4 Post Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

11 Visualizing Stations on a map 53

12 Unit Testing 5512.1 Running the Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

13 Updating this manual 5713.1 Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5713.2 How to update this manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

14 Citations 59

15 Indices and tables 61

Bibliography 63

ii

Page 5: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

Contents:

Contents 1

Page 6: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

2 Contents

Page 7: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 1

Introduction

1.1 About AIMBAT

AIMBAT (Automated and Interactive Measurement of Body wave Arrival Times) is an open-source software packagefor efficiently measuring teleseismic body wave arrival times for large seismic arrays [LouVanDerLee2013]. It is basedon a widely used method called MCCC (Multi-Channel Cross-Correlation) [VanDecarCrosson1990]. The package isautomated in the sense of initially aligning seismograms for MCCC, which is achieved by an ICCS (Iterative CrossCorrelation and Stack) algorithm. Meanwhile, a GUI (graphical user interface) is built to perform seismogram qualitycontrol interactively. Therefore, user processing time is reduced while valuable input from a user’s expertise is retained.As a byproduct, SAC [GoldsteinDodge2003] plotting and phase picking functionalities are replicated and enhanced.

Modules and scripts included in the AIMBAT package were developed using Python programming language and itsopen-source modules on the Mac OS X platform since 2009. The original MCCC [VanDecarCrosson1990] codewas transcribed into Python. The GUI of AIMBAT was inspired and initiated at the 2009 EarthScope USArray DataProcessing and Analysis Short Course. AIMBAT runs on Mac OS X, Linux/Unix and Windows thanks to the platform-independent feature of Python. It has been tested on Mac OS 10.6.8 and 10.7, and Fedora 16.

The AIMBAT software package is distributed under the GNU General Public License Version 3 (GPLv3) as publishedby the Free Software Foundation.

TEST EDIT

1.2 Associated Documents

• Seismological Research Letters Paper

• PDF Version of Manual. Automatically generated from these online docs; please excuse minor issuesthat may arise from automated conversion.

1.3 Authors’ Contacts

• Lay Kuan Loh

Email: lloh at ece.cmu.edu

• Xiaoting Lou

Email: xlou at u.northwestern.edu

3

Page 8: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

• Suzan van der Lee

Email: suzan at earth.northwestern.edu

4 Chapter 1. Introduction

Page 9: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 2

Installing Dependencies

AIMBAT is built on top of standard Python and uses several extra Python libraries as well. This page guides the userthrough checking if the required libraries are already installed on the computer they want to install AIMBAT on, andhow to get them if not.

To install AIMBAT, you will need sudo/root privileges for the computer you are installing it on.

2.1 Getting your operating system

We assume that most users of AIMBAT will be using Macs. If our assumptions are wrong, please contact the authors,and if there is sufficient interest we will test and write documentation for installations on other operating systems aswell.

On a Mac, to find the version of your operating system, first click on the Apple icon on the top bar of your desktop, goto System Preferences, and click on Startup Disk. The operating system version should then be displayed.

5

Page 10: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

2.2 Github

Optional

The latest version of AIMBAT will be on Github, so it would be good to get Git on your computer. This is not strictlynecessary, as you could also download it as a zipfile from the AIMBAT website.

To check if you already have Git installed, open the terminal and type:

git --version

If Git is installed, the terminal should output a line describing the version number of Git installed on the computer,such as:

git version 1.8.5.2 (Apple Git-48)

If Git is not installed, the terminal will respond by telling you that it is not possible to issue this command:

6 Chapter 2. Installing Dependencies

Page 11: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

-bash: git: command not found

To install Git, download the package installer here. This would allow only command line usage of Git, so if you wantto use a GUI, we recommend Git for Mac.

2.3 MacPorts

Highly recommended

MacPorts is a package management system that will be very helpful to install some python libraries.

To check if MacPorts is installed already, in the terminal, type:

port version

If MacPorts is installed, you should see the terminal output the version number, for instance:

Version: 2.3.0

If MacPorts is not installed, you should see the terminal output that port is not a valid command:

-bash: port: command not found

To get MacPorts, download the package installer here and follow the instructions to install it. Be sure to get the rightversion of MacPorts for your operating system.

2.4 Python and its Dependencies

AIMBAT requires python 2.7 and above to run. Note that Python is usually installed by default on Mac computers.

AIMBAT requires the following packages to run:

1. Numpy: Used for manipulating numbers and datasets

2. Scipy: Used for data processing

3. Matplotlib: Used for the majority of the plots in AIMBAT and the GUI

4. Basemap: Used for plotting world maps

2.4.1 Checking if Python is installed

Open the terminal and type:

python --version

If Python is installed, the terminal will output the version number installed, for example:

Python 2.7.8

If Python is not installed, the terminal will output:

-bash: python: command not found

2.3. MacPorts 7

Page 12: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

2.4.2 If Python is not installed

Inside the terminal, once python is installed, type these commands in using sudo mode. Note you will need to enteryour admin password:

sudo port install py27sudo port install py27-numpysudo port install py27-scipysudo port install py27-matplotlibsudo port install py27-matplotlib-basemapsudo port install py27-ipythonsudo port install python_select

Installing the last two packages is optional. ipython is an enhanced interactive python shell. python_select isused to select default Python version by the following command:

port select --set python python27

2.4.3 If Python is already installed

If Python is already installed, first check if you have the four required dependencies. Open up the Python console bytyping:

python

in the terminal. You should see something like this as output:

Python 2.7.8 (default, Oct 3 2014, 02:34:26)[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwinType "help", "copyright", "credits" or "license" for more information.>>>

Now, check if the packages have been installed properly by typing the following in:

import numpyimport scipyimport matplotlibfrom mpl_toolkits.basemap import Basemap

If any of the packages are missing (e.g. scipy not installed), the python console will output an error. For instance:

Traceback (most recent call last):File "<stdin>", line 1, in <module>ImportError: No module named scipy

Otherwise, the python console will simply show that it is ready for the next command.

If any of the packages are missing, you can choose to install it by whatever means you are most comfortable with. Weprovide one possible way to do so using MacPorts below. In the terminal, type:

sudo port install py27

to get the python version installed in opt/local/bin where MacPorts installs everything. Select to use this versionof Python by typing:

sudo port install python_select

Now, install the missing packages by doing:

8 Chapter 2. Installing Dependencies

Page 13: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

sudo port install py27-numpysudo port install py27-scipysudo port install py27-matplotlibsudo port install py27-matplotlib-basemap

2.5 Installing Basemap without MacPorts

If you have already installed Basemap, which means that:

from mpl_toolkits.basemap import Basemap

comes out without an error in the Python console, you can skip this section. This is for users who do not want touse the MacPorts version of Python which has been installed to /opt/local/bin. We anticipate that users whoinstalled the official version of Python from the Python website may possible find this section useful.

Enthought Python (aka Canopy) should get you most of the dependencies needed, and should be downloaded here.You do need to get Geos though. The best way to get it is install Homebrew, and then install gdal, a package that hasGeos as a dependency. To get gdal, do:

brew install gdal

Now install Basemap. Download it here. Unzip the package, cd into the unzipped package and run:

sudo python setup.py buildsudo python setup.py install

To check it worked, at the terminal, run:

python

and then:

from mpl_toolkits.basemap import Basemap

If installed correctly, no errors will occur.

2.6 Fortran

GFortran must be installed for AIMBAT. Note that f90 or f77 are also acceptable.

To check if you already have GFortran, in the terminal type:

gfortran --version

which will print out the version number you have if it is already installed.

If GFortran is not installed, the terminal will respond with:

-bash: gfortran: command not found

GFortran is available here. Be sure to get the correct version for your operating system.

2.5. Installing Basemap without MacPorts 9

Page 14: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

2.7 Possible Issues

Here some common problems and possible resolutions. If your problem is not listed here, or you have a suggestion,please contact the authors.

2.7.1 Macports

Many of the issues encountered can be solved by upgrading all Python directories on your computer using MacPorts.To do this, in the command line type:

sudo port selfupdatesudo port upgrade outdated

This will first make sure your version of MacPorts is the most recent version, and will then go through all Pythonlibraries to make sure they are all upgraded. Be aware that this step can take upwards of an hour depending on howmany Python libraries you have installed and when they were last updated. If at any point a library fails to install, type:

sudo port clean <library>sudo port install <library>

For example, if the library libcaca outputs an error, type:

sudo port clean libcacasudo port install libcaca

You can then simply retype sudo port upgrade outdated and it will continue with the upgrade where it leftoff.

If this last step does not work (i.e. it still outputs an error), type sudo port -p upgrade outdated, whichwill ignore any errors the upgrade runs into and simply continue through the process. It is likely that these ignorederrors will not have any effect on AIMBAT itself.

You may also run into problems with AIMBAT if your Macport version is not compatible with your operating systemversion. For example, if you used Macports for OS X 10.8 to install AIMBAT, then upgraded your operating systemor OS X 10.9, you may find that AIMBAT no longer works properly. You will need to upgrade Macports to fix thiserror.

Do not uninstall MacPorts unless you know what you are doing. Uninstalling MacPorts may get rid of other programsyou installed using MacPorts. However, if you are sure you want to do so, see here for instructions.

2.7.2 Installing Python with Pip

Be careful with the operating system. For OS X 10.9 and above, Python 2.7 is not fully compatible and there may beproblems installing python with Pip. Best to use Enthought Canopy or Python 3 with OS X 10.9.

2.7.3 Setting the Python Path to the scripts

You are asked to add the path to the AIMBAT scripts in your file. To do that, you add them to the .bashrc file.There are other files you could add it to that work as well, such as the .profile or .bash_profile files. Youcan see the files by opening the terminal, going to your home directory and doing ls -a to see all the hidden files,and open them by doing vim .bashrc in vim, for instance. If the .bashrc file does not exist, vim .bashrcwill create it and open it for editing. To ensure you can open a script, you need to add:

10 Chapter 2. Installing Dependencies

Page 15: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

export PATH=$PATH:<path-to-folder-with-scripts>export PYTHONPATH=$PYTHONPATH:<path-to-folder-with-scripts>

to the .bashrc file. We recommend adding the paths to the .bashrc file.

2.7.4 Terminal Commands stop working

If ever the terminal commands such as ls stop working in the terminal, it could be that something went wrong with apath in the .bashrc or .profile files. If that happens, you may not be able to open them in vim as that commandwould have stopped working as well. Instead, in the terminal, do:

PATH=/bin:${PATH}PATH=/usr/bin:${PATH}

That should allow the commands to start working again. Figure out what you did wrong and remove that command.

2.7.5 Path to python files not found

After adding the path to your directory with scripts in .bashrc, you still need to source the .bashrc files in.profile, or the system may not find the directory. See here for more details on how the profile file is sourced.Note that this one will override the file in /etc/profile.

This is what the bashrc and profile files should look like on your home directory:

2.7. Possible Issues 11

Page 16: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

12 Chapter 2. Installing Dependencies

Page 17: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 3

Installing AIMBAT

3.1 Getting the Packages

AIMBAT is released as a sub-package of pysmo under the name pysmo.aimbat along with another sub-packagepysmo.sac. The latest stable release of AIMBAT is available for download at the official project webpage.

We are working on a new release of AIMBAT, available on Github. Download pysmo.aimbat and pysmo.sac fromGithub. You will now have two folders called aimbat and sac respectively.

You may want to download example code to run AIMBAT on as well.

3.2 Building the Pysmo Packages

You need to be an administrator on the computer you are installing AIMBAT on, as you need to run the commandswith sudo.

3.2.1 Building pysmo.sac

Python module Distutils is used to write a setup.py script to build, distribute, and install pysmo.sac. cd intothe sac directory on the command line and run:

sudo python setup.py buildsudo python setup.py install

If you successfully installed the sac module, in the python console, after you type:

from pysmo import sac

there should be no errors.

3.2.2 Installing pysmo.aimbat

Three sub-directories are included in the aimbat directory:

• example: Example SAC files

• scripts: Python scripts to run at the command line

• src: Python modules to install

13

Page 18: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

The core cross-correlation functions are written in both Python/Numpy (xcorr.py) and Fortran (xcorr.f90).Therefore, we need to use Numpy’s Distutils module for enhanced support of Fortran extension. The usage issimilar to the standard Disutils.

Note that some sort of Fortran compiler must already be installed first. Specify them in place of gfortran in thefollowing commands.

cd into the aimbat directory and run:

sudo python setup.py build --fcompiler=gfortransudo python setup.py install

to install the src directory.

Add <path-to-folder>/aimbat/scripts to environment variable PATH in a shells start-up file for commandline execution of the scripts. Inside the ~/.bashrc file, add the lines

Bash Shell Users:

export PATH=$PATH:<path-to-folder>/aimbat/scripts

C Shell Users:

setenv PATH=$PATH:<path-to-folder>/aimbat/scripts

Don’t forget to run source ~/.bashrc If AIMBAT has been installed, type from pysmo import aimbatin a Python shell, and no errors should appear.

If you have added the scripts correctly, typing part of the name of the script in the terminal should be sufficient toallow the system to autocomplete the name.

3.3 Example Data

Get the repository data-example from Github. There is some example code inside data-example/example_pkl_filesthat will be needed for later demonstrations.

14 Chapter 3. Installing AIMBAT

Page 19: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 4

Upgrading AIMBAT

4.1 Getting the latest version

The latest version of AIMBAT, currently version 0.1.3, is hosted on the pysmo repository on Github. We will periodi-cally be making updates to it.

To upgrade AIMBAT, first delete the old AIMBAT files on your computer.

Next, download the newest version of AIMBAT and SAC from github. Now, cd into the newest AIMBAT folder andrun:

sudo python setup.py build --fcompiler=gfortransudo python setup.py install

Also, cd into the newest SAC folder and run:

sudo python setup.py buildsudo python setup.py install

Now, go to the .profile file and add the scripts folder in the new AIMBAT version to your path.

15

Page 20: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

4.2 Possible Issues

Some users have reported errors with upgrading. If there are any problems running the updated AIMBAT, try thefollowing:

Get the location of the python site-packages directory by typing the following into the python console:

import sitesite.getsitepackages()

The path to the site packages directory is highlighted in the figure below.

16 Chapter 4. Upgrading AIMBAT

Page 21: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

cd into the site-packages directory and remove all the folders with the word pysmo in their names by typing:

sudo rm -rf <psymo-folder>

Now, reinstall the new version of AIMBAT.

If this still does not work, upgrade your Python libraries as detailed in section 2.7.1 of this manual and reinstall thenew verson of AIMBAT.

4.2. Possible Issues 17

Page 22: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

18 Chapter 4. Upgrading AIMBAT

Page 23: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 5

Getting Data

Note: Not necessary if you already have your own set ways of obtaining data. This section is added for completeness.

There are several ways to obtain seismic data from IRIS to input into AIMBAT. The authors used two ways to do it,and a further list of libraries for obtaining seismic data is provided in the sidebars here.

5.1 Obspy.fdsn for downloading data

5.1.1 Installing Obspy

We recommend using Macports to install Obspy as detailed in the Installation section here. If you have installedEnthought Canopy:

sudo port install py27-obspy

should install Obspy. If not, installing it with Homebrew also seems to work.

5.1.2 Did the installation work?

If the installation has worked, close the terminal you used to install Obspy on, and then open it again. Now, open thePython terminal in a new terminal by typing python, and type:

import obspy

If there are no errors, your installation has worked.

5.1.3 Using Obspy

Use the Obspy FDSN web service client for Obspy in Python. Once you have done so, check out the SAC-InputOutput libraries for loading the data to Python and saving it as SAC or Pickle files.

5.2 Standing Order for Data

Note: NOT needed for AIMBAT, but important to know about as it is a commonly used package for downloadingseismic data with the user’s specifications. Although Obspy also offers ways to download seismic data from IRIS,SOD allows for better fine-tuning of obtained data.

19

Page 24: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

From the SOD website:

Standing Order for Data is a framework to define rules to select seismic events, stations, and data. It thenallows you to apply processing to the events, stations, and data and currently contains a large set of rulesthat allow you to select with great precision in these items. The processes mainly consist of simple datatransformation and retrieval, but SOD defines hooks to allow you to cleanly insert your own processingsteps, either written in Java or an external program.

5.2.1 Installing SOD

First, download SOD.

Once you have gotten the folder for SOD, put it somewhere where you won’t touch it too much. What I did was putthe SOD folder in my home directory, though other places are acceptable as well, as long as it is not too easy to deleteit by accident.

Once you have it there, get the path to the sod folder’s bin and put it in your path folder.

20 Chapter 5. Getting Data

Page 25: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

Inside your home directory (you get there by typing cd), put the path to sod-3.2.3/bin by adding it to either the .bashrc,.bash_profile, or .profile files.

5.2.2 Example SOD recipe

Inside the repository data-example, there is a folder sod_requests. The file within it called sod_request.xml, which isavailable here, is an example of a sod request recipe that will download data from IRIS. To run it, cd into the foldercontaining sod_request.xml and do:

sod sod_request.xml

Downloading the data (output as SAC files) may take a while. This receipt filters the data, and outputs the foldersprocessedSeismograms and seismograms, which contain the filtered and unfiltered data.

5.3 Wilber

Another resource for downloading SAC data is Wilber, created by IRIS (Incorporated Research Institutions for Seis-mology) and located at their website here (manual located here). When selecting which events or stations to study,keep in mind that distances between 30 and 90 degrees will result in the best data when studying P waves.

For P waves, select the BHZ (vertical) channel, and for S waves select the other two BH- channels for a given station(usually BH1/BH2 or BHE/BHN). Make sure to choose appropriate time windows for the type of wave you arestudying when prompted.

After downloading SAC data from Wilber, the theoretical arrival times for each SAC file must be added. One way todo this is using taup_setsac, which is part of the TauP software package available here.

5.3. Wilber 21

Page 26: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

22 Chapter 5. Getting Data

Page 27: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 6

SAC Input/Output procedures for AIMBAT

6.1 Converting from SAC to PKL files

Place the SAC files you want to convert to a pickle (PKL) file into the same folder. Suppose, for instance, they areBHZ channels. Note that the SAC files must be of the same channel. cd into that folder, and run:

sac2pkl.py -s *.BHZ.sac

The output should be a PKL file in the same folder as the sac files.

6.2 Converting from PKL to SAC files

cd into the folder containing the PKL file that you wish to convert into SAC files, and run:

sac2pkl.py --p2s <name-of-file>.pkl

The SAC files contained within will output into the same folder as the PKL file is stored in.

23

Page 28: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

24 Chapter 6. SAC Input/Output procedures for AIMBAT

Page 29: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 7

Analyzing Data

7.1 Seismic Analysis Code (SAC)

AIMBAT uses Seismic Analysis Code (SAC) formatting for some of the files it runs and outputs. To get SAC, youwill need to fill out a software request form available on the IRIS website.

25

Page 30: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

26 Chapter 7. Analyzing Data

Page 31: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 8

Parameter Configuration

8.1 Backend

Matplotlib works with six GUI (Graphical User Interface) toolkits:

1. WX

2. Tk

3. Qt(4)

4. FTK

5. Fltk

6. macosx

The GUI of AIMBAT uses the following to support interactive plotting:

1. GUI neutral widgets

2. GUI neutral event handling API (Application Programming Interface)

AIMBAT uses the default toolkit Tk and backend TkAgg.

Visit these pages for an explanation of the backend and how to customize it.

8.2 Configuration File

Other parameters for the package can be set up by a configuration file ttdefaults.conf, which is interpreted bythe module ConfigParser. This configuration file is searched in the following order:

1. file ttdefaults.conf in the current working directory

2. file .aimbat/ttdefaults.conf in your HOME directory

3. a file specified by environment variable TTCONFIG

4. file ttdefaults.conf in the directory where AIMBAT is installed

Python scripts in the <pkg-install-dir>/pysmo-aimbat-0.1.2/scripts can be executed from thecommand line. The command line arguments are parsed by the optparse module to improve the scripts’ exitabil-ity. If conflicts existed, the command line options override the default parameters given in the configuration filettdefaults.conf. Run the scripts with the -h option for the usage messages.

27

Page 32: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

8.2.1 Example of AIMBAT configuration file ttdefaults.conf

ttdefaults.conf Description[sacplot]colorwave = blue Color of waveformcolorwavedel = gray Color of waveform which is deselectedcolortwfill = green Color of time window fillcolortwsele = red Color of time window selectionalphatwfill = 0.2 Transparency of time window fillalphatwsele = 0.6 Transparency of time window selectionnpick = 6 Number of time picks (plot picks: t0-t5)pickcolors = kmrcgyb Colors of time pickspickstyles Line styles of time picks (use second one if ran out of color)figsize = 8 10 Figure size for plotphase.pyrectseis = 0.1 0.06 0.76 0.9 Axes rectangle size within the figureminspan = 5 Minimum sample points for SpanSelector to select time windowsrate = -1 Sample rate for loading SAC data. Read from first file if srate < 0

[sachdrs]twhdrs = user8 user9 SAC headers for time window beginning and endingichdrs = t0 t1 t2 SAC headers for ICCS time picksmchdrs = t2 t3 SAC headers for MCCC input and output time pickshdrsel = kuser0 SAC header for seismogram selection statusqfactors = ccc snr coh Quality factors: cross-correlation coefficient, signal-to-noise ratio, time domain

coherenceqheaders = user0 user1 user2 SAC Headers for quality factorsqweights = 0.3333 0.33330.3333

Weights for quality factors

[iccs] or Align/Refinesrate = -1 Sample rate for loading SAC data. Read from first file if srate < 0xcorr_modu = xcorrf90 Module for calculating cross-correlation: xcorr for Numpy or xcorrf90 for Fortranxcorr_func = xcorr_fast Function for calculating cross-correlationshift = 10 Sample shift for running coarse cross-correlationmaxiter = 10 Maximum number of iterationconvepsi = 0.001 Convergence criterion: epsilonconvtype = coef Type of convergence criterion: coef for correlation coefficient, or resi for residualstackwgt = coef Weight each trace when calculating array stackfstack = fstack.sac SAC file name for the array stack

[mccc]srate = -1 Sample rate for loading SAC data. Read from first file if srate < 0ofilename = mc Output file name of MCCC.xcorr_modu = xcorrf90 Module for calculating cross-correlation: xcorr for Numpy or xcorrf90 for Fortranxcorr_func = xcorr_faster Function for calculating cross-correlationshift = 10 Sample shift for running coarse cross-correlationextraweight = 1000 Weight for the zero-mean equation in MCCC weighted lsqr solutionlsqr = nowe Type of lsqr solution: no weight#lsqr = lnco Type of lsqr solution: weighted by correlation coefficient, solved by lapack#lsqr = lnre Type of lsqr solution: weighted by residual, solved by lapackrcfile = .mcccrc Configuration file for MCCC parameters (deprecated)evlist = event.list File for event hypocenter and origin time (deprecated)

28 Chapter 8. Parameter Configuration

Page 33: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

signaltapertype = hanning Taper typetaperwidth = 0.1 Taper width

8.2. Configuration File 29

Page 34: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

30 Chapter 8. Parameter Configuration

Page 35: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 9

SAC Data Access

NOTE: All .sac files must include origin time, hypocenter, as well as station coordinates and elevation in theirheaders.

9.1 Python Object for SAC File

The pysmo.sac package is developed to read and write individual SAC files. The Python class sacfile of mod-ule sacio opens a SAC file and returns an object including data and all SAC header variables as their attributes.Modifications of object attributes are saved to file. It is written purely in Python so that it also runs with Jython.

9.1.1 egsac.py

The <pkg-install-dir>/aimbat/scripts/egsac.py script gives a simple exampleto read, resample, and plot a seismogram using pysmo, Scipy, and Matplotlib. You cantype the codes in a Python/iPython shell, or run as a script in the data example directory<pkg-install-dir>/data-example/example_pkl_files/Event_2011.09.15.19.31.04.080,hereafter referred to as <example-event-dir>.

31

Page 36: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

9.1.2 Resampling Seismograms

In this example, a SAC file named TA.109C.\_\_.BHZ.sac is read in as a sacfile object. The time array is calcu-lated from SAC headers. The data array is resampled from interval 0.025 to 2.0 seconds using Scipy’s signalprocessingmodule.

Add the following codes to write the resampled seismogram to file TA.109C.\_\_.BHZ.sac:

sacobj.delta = deltanewsacobj.npts = nptsnewsacobj.data = y2

32 Chapter 9. SAC Data Access

Page 37: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

9.2 Python Pickle for SAC Files

The pysmo.sacio module converts SAC files to sacfile objects. Any modification of the objects are instantlywritten to files. In data processing, the user may want to abandon changes made earlier, which brings the need of abuffer for the sacfile objects.

The SacDataHdrs class in the pysmo.aimbat.sacpickle module is written on top of pysmo.sacio toserves this purpose by reading a SAC file and returning a sacdh object that is very similar to the sacfile object.Essentially, the sacdh object is a copy of the sacfile object in the memory, except that SAC headers ‘t0-t9’,‘user0-user9’, and ‘kuser0-kuser2’ are saved in three Python lists.

A gsac object of the SacGroup class consists of a group of sacdh objects from event-based SAC data files,earthquake hypocenter information, and station locations. An additional step is required to save changes in the gsacobject to files.

In order to avoid frequent SAC file I/O, the pickle/cPickle module is used for serializing and de-serializing thegsac object structure. Thus the data processing efficiency is improved because reading and writing of SAC files aredone only once each before and after data processing. Script sac2pkl.py does the conversions between SAC filesand Python pickles.

Its usage message can be printed out by running at command line:

sac2pkl.py -h

and the result is displayed in the figure below. For example, in the data example directory <example-event-dir>,run:

sac2pkl.py -s *Z -o 20110915.19310408.bhz.pkl -d 0.025

to read 163 vertical component seismograms at a sample interval of 0.025 s and convert to a gsac object, which issaved in the pickle file 20110915.19310408.bhz.pkl.

To save disk space, compressed pickle files in gz and bz2 formats can be generated by:

sac2pkl.py -s *Z -o 20110915.19310408.bhz.pkl -d 0.025 -z gzsac2pkl.py -s *Z -o 20110915.19310408.bhz.pkl -d 0.025 -z bz2

at the cost of more CPU time.

After processing, run:

sac2pkl.py 20110915.19310408.bhz.pkl -p

9.2. Python Pickle for SAC Files 33

Page 38: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

to convert the pickle file to SAC files.

See the doc string of pysmo.aimbat.sacpickle by typing in a python console:

from pysmo.aimbat import sacpickleprint sacpickle.\_\_doc\_\_

and also the documentation on pickle for more information about the Python data structure, pickling, and unpickling.

34 Chapter 9. SAC Data Access

Page 39: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

9.3 SAC Plotting and Phase Picking

SAC plotting and phase picking functionalities are replicated and enhanced based on the GUI neutral widgets(such as Button and SpanSelector) and the event (keyboard and mouse events such as key\_press\_event andmouse\_motion\_event handling API of Matplotlib.

They are implemented in two modules, pysmo.aimbat.plotphase and pysmo.aimbat.pickphase, whichare used by corresponding scripts sacplot.py and sacppk.py executable at command line. Their help messagesare displayed in the figures below.

9.3. SAC Plotting and Phase Picking 35

Page 40: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

36 Chapter 9. SAC Data Access

Page 41: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

9.3.1 SAC Plotting

Options “-i, -z, -d, -a, and -b” of sacplot.py set the seismogram plotting baseline as file index, zero, epicentraldistance in degrees, azimuth, and back-azimuth, respectively. The user can run sacplot.py directly with theoptions, or run individual scripts sacp1.py, sacp2.py, sacprs.py, sacpaz.py, and sacpbaz.py, whichpreset the baseline options and plot seismograms in SAC p1 style, p2 style, record section, and relative to azimuth andback-azimuth. The following commands are equivalent:

9.3. SAC Plotting and Phase Picking 37

Page 42: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

sacplot.py -i, sacp1.pysacplot.py -z, sacp2.pysacplot.py -d, sacprs.pysacplot.py -a, sacpaz.pysacplot.py -b, sacpbaz.py

Input data files need to be supplied to the scripts in the form of either a list of SAC files or a pickle file that includes mul-tiple SAC files. For example, a bhz.pkl file is generated from 22 vertical component seismograms TA.[1-K]*Zby running:

sac2pkl.py TA.[1-K]*BHZ -o bhz.pkl -d0.025

in the data example directory <example-event-dir>. Then the two commands are equivalent:

sacp1.py TA.[1-K]*Z

or:

sacp1.py bhz.pkl

For large numbers of seismograms, the pickle file is suggested because of faster loading.

Besides using the standard sacplot.py script, the user can modify its getAxes function in their own script tocustomize figure size and axes attributes. Script egplot.py is such an example in which SAC p1, p2 styles andrecord section plotting are drawn in three axes in the same figure canvas. Run:

egplot.py TA.[1-K]*Z -f1 -C

at command line to produce the figure below.

38 Chapter 9. SAC Data Access

Page 43: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

The “-C” option uses random color for each seismogram. The “-f1” option fills the positive signals of waveform with

9.3. SAC Plotting and Phase Picking 39

Page 44: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

less transparency. In the script, “opts.ynorm” sets the waveform normalization and “opts.reltime=0” sets the time axisrelative to time pick t0.

An improvement over SAC is that the program outputs the filename when the seismogram is clicked on by the mouse.This is enabled by the event handling API and is mostly introduced for use in SAC p2 style plotting when seismogramsare plotted on top of each other. It is especially useful when a large number of seismograms create difficulties inlabeling.

Another improvement is easier window zooming enabled by the SpanSelector widget and the event handling API.Select a time span by mouse clicking and dragging to zoom in a waveform section. Press the ‘z’ key to zoom out tothe previous time range.

9.4 SAC Phase Picking

SAC plotting (pysmo.aimbat.plotphase) does not involve change in data files, but phase picking(pysmo.aimbat.pickphase) does. A GUI is built for the user to interactively pick phase arrival times. Thefigure below is an example screen shot running:

sacppk.py 20110915.19310408.bhz.pkl -w

in the data example directory <example-event-dir>.

Following SAC convention, the user can set a time pick by pressing the ‘t’ key and number keys ‘0-9’. Thex location of the mouse position is saved to corresponding SAC headers ‘t0-t9’. Time window zooming inpysmo.aimbat.pickphase is implemented in the same way as in pysmo.aimbat.plotphase to re-place SAC’s combination of the ‘x’ key and mouse click. Zooming out key is set to ‘z’ because the ‘o’ key isused for another purpose by Matplotlib. The filename printing out by mouse clicking feature is also available inpysmo.aimbat.pickphase.

A major improvement over SAC is picking a time window in addition to time picks. Pressing the ‘w’ key to save thecurrent time axis range to two user-defined SAC header variables. A transparent green span is plotted within the timewindow, as shown in the figure below.

40 Chapter 9. SAC Data Access

Page 45: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

Another major improvement involves quality control with convenient operations to (de)select seismograms. In theGUI above, there are two divisions of selected and deleted seismograms. Selected seismograms with a positive tracenumber are displayed with blue wiggles, while deleted seismograms with negative trace numbers are plotted in gray.The user can simply click on a certain seismogram to switch the selection status, either to exclude it or bring it backfor inclusion. The trace selection status is stored in a user-defined SAC header variable.

In SAC, command ppk p 10 plots 10 seismograms on each page. Pressing the ‘b’ and ‘n’ keys to navigate throughpages. The number of seismograms plotted on each page is controlled by command line option:

-m maxsel maxdel

for sacppk.py. The Prev and Next buttons are for page navigation and the Save Button saves the change in timepicks and time window to files. The default values for maxsel and maxdel are 25 and 5, which means a maximum of30 seismograms on each page.

In the figure displayed, there are 26 seismograms on the first page because only 1 seismogram is deleted. On the nextpage, there are 30 selected seismograms. To plot 50 seismograms on each page, run:

sacppk.py 20110915.19310408.bhz.pkl -w -m 45 5

9.4. SAC Phase Picking 41

Page 46: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

and there would be 4 total pages and 13 seismograms on the last page.

To plot seismograms relative to time pick t0 and fill the positive and negative wiggles of waveform, run:

sacppk.py 20110915.19310408.bhz.pkl -w -r0 -f1

To sort seismograms by epicentral distance in increase and decrease orders, run:

sacppk.py 20110915.19310408.bhz.pkl -w -sdistsacppk.py 20110915.19310408.bhz.pkl -w -sdist-

Sorting by azimuth and back-azimuth is similar:

sacppk.py 20110915.19310408.bhz.pkl -w -sazsacppk.py 20110915.19310408.bhz.pkl -w -sbaz

The help message of the iccs.py script is shown below:

The help message of the mccs.py script is shown below:

42 Chapter 9. SAC Data Access

Page 47: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

9.4. SAC Phase Picking 43

Page 48: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

44 Chapter 9. SAC Data Access

Page 49: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 10

Measuring Teleseismic Body Wave Arrival Times

The core idea in using AIMBAT to measure teleseismic body wave arrival times has two parts:

• automated phase alignment, to reduce user processing time, and

• interactive quality control, to retain valuable user inputs.

10.1 Automated Phase Alignment

The ICCS algorithm calculates an array stack from predicted time picks, cross-correlates each seismogram with thearray stack to find the time lags at maximum cross-correlation, then uses the new time picks to update the array stack inan iterative process. The MCCC algorithm cross-correlates each possible pair of seismograms and uses a least-squaresmethod to calculate an optimized set of relative arrival times. Our method combines ICCS and MCCC in a four-stepprocedure using four anchoring time picks 0𝑇𝑖, 1𝑇𝑖, 2𝑇𝑖, and 3𝑇𝑖.

1. Coarse alignment by ICCS

2. Pick phase arrival at the array stack

3. Refined alignment by ICCS

4. Final alignment by MCCC

The one-time manual phase picking at the array stack in step (b) allows the measurement of absolute arrival times.The detailed methodology and procedure can be found in [LouVanDerLee2013].

Table 10.1: Time picks and their SAC headers used in the procedure for measuring teleseismic body wave arrival times.

Step Algorithm Input OutputTime Window Time Pick Time Header Time Pick Time Header

1.ICCS 𝑊𝑎 0𝑇𝑖 T0 1𝑇𝑖 T1

2.ICCS 𝑊𝑏 2𝑇

′𝑖 T2 2𝑇𝑖 T2

4.MCCS 𝑊𝑏 2𝑇𝑖 T2 3𝑇𝑖 T3

The ICCS and MCCC algorithms are implemented in two modules pysmo.aimbat.algiccs andpysmo.aimbat.algmccc, and can be executed in scripts iccs.py and mccc.py respectively.

45

Page 50: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

10.2 Picking Travel Times

This section explains how to run the program ttpick.py to get the travel times you want.

10.2.1 Getting into the right directory

In the terminal, cd into the directory with all of the pkl files you want to run. You want to run either the BHT orBHZ files. BHT files are for S-waves and BHZ files are for P-waves. PKL is a bundle of SAC files. Each SAC file is aseismogram, but since there may be many seismograms from various stations for each event, we bundle them into aPKL file so we only have to import one file into AIMBAT, not a few hundred of them.

10.2.2 Running ttpick.py

Run ttpick.py -p P <path-to-pkl-file> for BHZ files or ttpick.py -p S<path-to-pkl-file> for BHT files. A GUI should pop up if you successfully ran it. Note that if youclick on the buttons, they will not work until you move your mouse off them; this is a problem we are hoping to fix.

You can get some example data to test this out by downloading the Github repository data-example. Now, cd into thefolder example_pkl_files, which has several pickle files for seismic events. Type:

ttpick.py -p P 20110915.19310408.bhz.pkl

and a python GUI should pop up.

At the top of the GUI is the scaled sum of all of the seismograms known as the array stack, which gives a characteristicwaveform of the event for the stations involved. Beneath this is a page of seismograms, with the corresponding stationand various quality factors listed on the right. CCC is the cross-correlation coefficient between that seismogram andthe array stack, SNR is the signal-to-noise ratio, and COH is the coherence between that seismogram and the arraystack.

46 Chapter 10. Measuring Teleseismic Body Wave Arrival Times

Page 51: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

10.2.3 Initial deselection of bad seismograms

Bad seismograms are those whose waveforms look nothing like the array stack above. By default, the seismogramsare sorted by quality, so bad seismograms will likely be at the top. In order to deselect these, click on the waveformsthemselves (not the fill) and wait a second or two for them to turn gray. The user can develop criteria for whichseismograms to deselect and which to keep. Simply deselecting all seismograms below a certain quality threshold candecrease time but may lead to good seismograms being deselected or bad seismograms remaining.

Remember to save your work periodically once you start picking your travel times. Otherwise, if AIMBAT crashes,you will lose your work.

10.2.4 Align

The first step after deselecting seismograms is to press Align. This will recalculate both the array stack and the T1picks for the seismograms, not including the deselected seismograms. Do not press Align after pressing Sync unlessyou wish to remove any T2 picks that have been made.

10.2.5 Sync, refine, and setting time window

After hitting the Align button, place the cursor on the array stack where the first motion of the seismogram, eitherup or down, occurs. Press t and 2 simultaneously on the keyboard to select the arrival time. Now press Sync. Usethe mouse to drag and select the desired time window on the seismogram on the array stack. This time window isthe portion of the seismogram on which cross-correlation will be run. The time window should begin 2-10 secondsbefore the first arrival and include a few seconds of the first motion of the waveform. The final time window shouldbe smaller than the default window to increase the accuracy of the cross-correlation.

Next, set the cursor over the array stack and press the w key. If the new time window has been saved, a message notingthe new size of the time window will be printed in the terminal. The entire width of the x-axis is now colored green

10.2. Picking Travel Times 47

Page 52: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

and will be stored as the time window to use for the cross-correlations. Press Save headers only if you wish tokeep this time window for future applications.

Now press Refine and all the seismograms will align with the smaller time window. Note that the Weightedaverage quality printed to the terminal may decrease significantly, but this is likely due to the fact that the timewindow is smaller than the original.

10.2.6 Filtering

If you wish to apply a filter to your data, hit the Filter button, and a window will pop up for you to use theButterworth filter to filter your data.

The defaults used for filtering are:

48 Chapter 10. Measuring Teleseismic Body Wave Arrival Times

Page 53: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

Variable DefaultOrder 2Filter Type BandpassLow Frequency 0.05 HzHigh Frequency 0.25 Hz

You can change the order and filter type by selecting the option you want. In order to set corner frequencies for thefilter, select the low frequency and the high frequency you want on the lower figure by clicking. Press Apply to filterthe seismograms when you are satisfied with the filter parameters chosen.

10.2.7 Finalize

Hit Finalize to run the multi-channel cross-correlation. Do not hit Align or Refine again, or all your previouspicks will be written over. A warning will pop up to check if you really do want to hit these two buttons if you do clickon them.

10.2.8 SACP2 to check for outlier seismograms

Hit SACP2 and go to the last figure, (d). Zoom in to have a better look. Zooming in doesn’t always work well; closeand reopen the SACP2 window if there are problems.

Click on the outliers that stray from the main group of stacked seismograms. The terminal will output the names ofthe seismograms that you clicked on, so you can return to the main GUI window and readjust the travel times. Note:hitting SACP2 before hitting Finalize will often cause AIMBAT to close, so make sure you have finalized beforeusing SACP2.

10.2. Picking Travel Times 49

Page 54: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

50 Chapter 10. Measuring Teleseismic Body Wave Arrival Times

Page 55: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

10.2.9 Go through the badly aligned seismograms and realign the travel times man-ually

By default, the worst seismograms are on the first page, and as you click through the pages, the quality of the seismo-grams gradually gets better. Keep using t2 to realign the arrival times so that the peaks of all the seismograms arenicely aligned. Remember to zoom in to have a better look.

However, you may wish to sort the seismograms in alphabetical order or by azimuth so that you can find the badseismogrrams and correct them more easily. Hit the Sort button and a window will pop up for you to choose whichsorting method to use. In this case, choose File to sort the files by station name alphabetically, or choose AZ to sortthe files by azimuth from the event epicenter. The seismograms are stretched to fit together, but they may be scaleddifferently.

10.3 What the Alignments Stand For

• T0: Theoretical Arrival

• T1: Pick from initial cross correlation

• T2: Travel Time pick

• T3: MCCC pick

• T4: Zoom in

10.4 Post Processing

10.4.1 Getting the output

In the same folder as the initial PKL file you ran ttpick.py on, you can find the output list with extension <eventname>.mcp, which contains the travel time arrivals.

10.3. What the Alignments Stand For 51

Page 56: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

mccc delay is t3+average arrival times, and t0_times are the theoretical arrival times. delay_times are obtained bytaking t3-t0.

10.4.2 Disclaimer about delay times

t0 depends on hypocenter location, origin time, and reference model. We compute the delay time by finding t3-t0, butit does not have elliptic, topological, or crust corrections.

10.4.3 Getting the stations of the seismograms chosen

Run getsta.py in the additional scripts (not on Github for now). It gives the unique list of stations where theseismograms came from. You need to run it with the list of all pkl files chosen after you saved to. To do this, type./getsta.py *.pkl.

10.4.4 Picking Travel Times does not work

If you run ttick.py <Event name>.bhz.pkl, a GUI will pop up for you to manually pick the travel timesby pressing the keyboard. If typing on the keyboard as directed does not allow you to pick travel times, it could be aproblem with the keyboard settings, or the matplotlib backend.

To fix this, first look for the .matplotlib directory. It is hidden in your home directory, so do ls -a to find it.

Once you have found the .matplotlib directory, cd into it, and then look for the matplotlibrc file. Inside thatfile, ensure the backend is set to:

backend : TkAgg

Make sure to comment out the other backends.

52 Chapter 10. Measuring Teleseismic Body Wave Arrival Times

Page 57: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 11

Visualizing Stations on a map

After running:

ttpick.py <sac-files>

Hit Map of Stations in order to get a visual respresentation of where exactly each station is. Dots representcircles used for computing delay times; black triangles represent discarded stations. Click on a dot to get the stationname in the terminal.

53

Page 58: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

54 Chapter 11. Visualizing Stations on a map

Page 59: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 12

Unit Testing

This section is mainly for those who wish to make tweaks to AIMBAT themselves. We have added some unit tests toAIMBAT to ensure that it is robust. See the Python Unit Testing Framework for more details.

12.1 Running the Tests

In the AIMBAT repository, cd into /src/pysmo/unit_tests and run:

python run_unit_tests.py

55

Page 60: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

56 Chapter 12. Unit Testing

Page 61: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 13

Updating this manual

This is for someone who wants to be a collaborator on AIMBAT only. This is NOT necessary for anyone who onlywants to use AIMBAT. AIMBAT will work fine if you do not install the dependencies listed here.

To be able to update the manual, download the source code from Github, and install the dependencies.

13.1 Dependencies

• Sphinx. Download and install from here. Don’t get the Python Wheel version unless you know what you aredoing

• LaTeX. Download it from here. Get the package installer.

• A browser. But if you are reading this, you already have it.

13.2 How to update this manual

On the master branch, cd into the github repository aimbat-docs <https://github.com/pysmo/aimbat-docs> and run:

sphinx-build -b html . builddirmake htmlmake latexpdf

The first two commands build the html for the webpage, while the last command makes a pdf version of the onlinedocumentation.

Now, commit the changes made in GitHub, and push the changes to the master branch. The changes should be visiblein the documentation within a few minutes.

57

Page 62: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

58 Chapter 13. Updating this manual

Page 63: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 14

Citations

59

Page 64: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

60 Chapter 14. Citations

Page 65: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

CHAPTER 15

Indices and tables

• genindex

• modindex

• search

61

Page 66: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

AIMBAT Documentation, Release 0.2.1

62 Chapter 15. Indices and tables

Page 67: AIMBAT Documentation - Read the Docs · AIMBAT Documentation Release 0.2.1 Lay ... for efficiently measuring teleseismic body wave arrival times for large seismic ... Linux/Unix

Bibliography

[GoldsteinDodge2003] Goldstein, P., D. Dodge, M. Firpo, and L. Minner (2003), SAC2000: Signal processing andanalysis tools for seismologists and engineers, International Geophysics, 81, 1613–1614.

[Hunder2007] Hunter, J. (2007), Matplotlib: A 2D Graphics Environment, Computing in Science & Engineering,3(9), 90–95.

[LouVanDerLee2013] AIMBAT: A Python/Matplotlib Tool for Measuring Teleseismic Arrival Times. Xiaoting Lou,Suzan van der Lee, and Simon Lloyd (2013), Seismol. Res. Lett., 84(1), 85-93, doi:10.1785/0220120033.

[VanDecarCrosson1990] VanDecar, J. C., and R. S. Crosson (1990), Determination of teleseismic relative phase ar-rival times using multi-channel cross-correlation and least squares, Bulletin of the Seismological Society of Amer-ica, 80(1), 150–169.

[BulandChapMan1983] Ray Buland and C. H. Chapman (1983), The Computation of Seismic Travel Times, Bulletinof the Seismological Society of America, 73(5), 1271-1302.

63