<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Stacking Waveforms Examples
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
Step1:  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.
Step2:  To create a list of the linearly stacked waveforms, run STACK.lin_stack and the list is stored in STACK.LS
Step3:  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).
Step4:  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).
Step5:  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.
Step6:  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.
Step7:  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.
<ASSISTANT_TASK:>
Python Code:
from tools.stack import Stack
from obspy import read 
%matplotlib inline  
Explanation: Stacking Waveforms Examples
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.
End of explanation
# here is a list of all of the functions and variables that the Stack class contains
help(Stack)
# 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()
Explanation: 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.
End of explanation
# 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
Explanation: To create a list of the linearly stacked waveforms, run STACK.lin_stack and the list is stored in STACK.LS
End of explanation
STACK.phase_stack()
print 'List of Phase Stacked Seismic Waveforms: ', STACK.PS
Explanation: 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).
End of explanation
STACK.pw_stack()
print 'List of Phase-Weighted Stacked Seismic Waveforms: ', STACK.PWS
Explanation: 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).
End of explanation
STACK.plot_lin_stack(LS=None, show=True, save=False)
Explanation: 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.
End of explanation
STACK.plot_phase_stack(PS=None, show=True, save=False)
Explanation: 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.
End of explanation
STACK.plot_pw_stack(PWS=None, show=True, save=False)
Explanation: 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.
End of explanation
<END_TASK>