The following notebook contains examples for using the stack.py toolbox for stacking raw and band-pass filtered seismic waveforms. Currently the script can only operate with MSEED formats, but additional support for other formats such as: SAC, SEED and SUDS will likely be added in the future. The user specifies the input path to the raw waveform. This waveform should have more than one trace, e.g. BHZ, BHE and BHN in one. A Stack object is created with this input, and the output is specified with on of the containing functions.
Each trace in the stream is stacked in a specified way. Three options are currently available: Linear Stack, Phase Stack and Phase-Weighted Stack.
In [1]:
from tools.stack import Stack
from obspy import read
%matplotlib inline
The Stack object requires the MSEED path as the only necessary input. Other obtions include 'filter_waveform' which is default to False, and 'band_lims' which is defaulted to [1,10]. So if you wish to band-pass filter the waveform before stacking, set 'filter_waveform' to true and specify which frequency range you wish to filter; 'band_lims' contains [min. frequency, max. frequency] for the band-pass filter.
In [2]:
# here is a list of all of the functions and variables that the Stack class contains
help(Stack)
In [3]:
# set the path to the desired waveform, the example HOLS.mseed is provided.
example_path = 'tools/examples/HOLS.mseed'
# plot the original waveform to show what form it's in.
st = read(example_path); st.plot()
To create a list of the linearly stacked waveforms, run STACK.lin_stack and the list is stored in STACK.LS
In [4]:
# create the stack object
STACK = Stack(example_path, filter_waveform=True, band_lims=[1,10])
STACK.lin_stack()
print 'List of Linearly Stacked Seismic Waveforms: ', STACK.LS
To create a list of the phase stacked waveforms, run STACK.phase_stack and the list is stored in STACK.PS using the method from Schimmel and Paulssen (1997).
In [5]:
STACK.phase_stack()
print 'List of Phase Stacked Seismic Waveforms: ', STACK.PS
To create a list of the phase-weighted stacked waveforms, run STACK.pw_stack and the list is stored in STACK.PWS using the method from Schimmel and Paulssen (1997).
In [6]:
STACK.pw_stack()
print 'List of Phase-Weighted Stacked Seismic Waveforms: ', STACK.PWS
To create a plot of the linearly stacked waveforms, run STACK.plot_lin_stack. Options are to save or show the waveforms, as well as to plot from the initialised stack, or another STACK.LS that has been created previously. If save=True, the the waveform will be saved to the same location as the example, but changed the named to ?.lin_stack.jpg where ? is the basename without the extension of the original MSEED input file.
In [7]:
STACK.plot_lin_stack(LS=None, show=True, save=False)
To create a plot of the phase stacked waveforms, run STACK.plot_phase_stack. Options are to save or show the waveforms, as well as to plot from the initialised stack, or another STACK.PS that has been created previously. If save=True, the the waveform will be saved to the same location as the example, but changed the named to ?.phase_stack.jpg where ? is the basename without the extension of the original MSEED input file.
In [8]:
STACK.plot_phase_stack(PS=None, show=True, save=False)
To create a plot of the phase-weighted stacked waveforms, run STACK.plot_pw_stack. Options are to save or show the waveforms, as well as to plot from the initialised stack, or another STACK.PWS that has been created previously. If save=True, the the waveform will be saved to the same location as the example, but changed the named to ?.pw_stack.jpg where ? is the basename without the extension of the original MSEED input file.
In [9]:
STACK.plot_pw_stack(PWS=None, show=True, save=False)