template_gen¶
Function to generate template waveforms and information to go with them for theapplication of cross-correlation of seismic data for the detection of repeatingevents.
Part of the EQcorrscan module to read nordic format s-filesEQcorrscan is a python module designed to run match filter routines forseismology, within it are routines for integration to seisan and obspy.With obspy integration (which is necessary) all main waveform formats can beread in and output.
This main section contains a script, LFE_search.py which demonstrates the usageof the built in functions from template generation from picked waveformsthrough detection by match filter of continuous data to the generation of lagtimes to be used for relative locations.
The match-filter routine described here was used a previous Matlab code for theChamberlain et al. 2014 G-cubed publication. The basis for the lag-timegeneration section is outlined in Hardebeck & Shelly 2011, GRL.
Code generated by Calum John Chamberlain of Victoria University of Wellington,2015.
Note
- Pre-requisites:
gcc - for the installation of the openCV correlation routine
python-cv2 - Python bindings for the openCV routines
python-joblib - used for parallel processing
- python-obspy - used for lots of common seismological processing
- requires:
- numpy
- scipy
- matplotlib
NonLinLoc - used outside of all codes for travel-time generation
Copyright 2015 Calum Chamberlain
This file is part of EQcorrscan.
EQcorrscan is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
EQcorrscan is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with EQcorrscan. If not, see <http://www.gnu.org/licenses/>.
-
template_gen.
_template_gen
(picks, st, length, swin, prepick=0.05, plot=False)[source]¶ Function to generate a cut template in the obspy Stream class from a given set of picks and data, also in an obspy stream class. Should be given pre-processed data (downsampled and filtered)
Parameters:
-
template_gen.
extract_from_stack
(stack, template, length, pre_pick, pre_pad, Z_include=False, pre_processed=True, samp_rate=False, lowcut=False, highcut=False, filt_order=False)[source]¶ Function to extract a new template from a stack of previous detections. Requires the stack, the template used to make the detections for the stack, and we need to know if the stack has been pre-processed.
Parameters: - stack (:class:obspy.Stream) – Waveform stack from detections. Can be of any length and can have delays already included, or not.
- template (:class:obspy.Stream) – Template used to make the detections in the stack. Will use the delays of this for the new template.
- length (float) – Length of new template in seconds
- pre_pick (float) – Extract additional data before the detection, seconds
- pre_pad (float) – Pad used in seconds when extracting the data, e.g. the time before the detection extracted. If using clustering.extract_detections this half the length of the extracted waveform.
- Z_include (bool) – If True will include any Z-channels even if there is no template for this channel, as long as there is a template for this station at a different channel. If this is False and Z channels are included in the template Z channels will be included in the new_template any-way.
- pre_processed (bool) – Have the data been pre-processed, if True (default) then we will only cut the data here.
- samp_rate (float) – If pre_processed=False then this is required, desired sampling rate in Hz, defaults to False.
- lowcut (float) – If pre_processed=False then this is required, lowcut in Hz, defaults to False
- highcut (float) – If pre_processed=False then this is required, highcut in Hz, defaults to False
- filt_order (int) – If pre_processed=False then this is required, filter order, defaults to False
Returns: :class:obspy.Stream Newly cut template
-
template_gen.
from_contbase
(sfile, contbase_list, lowcut, highcut, samp_rate, filt_order, length, prepick, swin, debug=0)[source]¶ Function to read in picks from sfile then generate the template from the picks within this and the wavefiles from the continous database of day-long files. Included is a section to sanity check that the files are daylong and that they start at the start of the day. You should ensure this is the case otherwise this may alter your data if your data are daylong but the headers are incorrectly set.
Parameters: - sfile (string) – sfilename must be the path to a seisan nordic type s-file containing waveform and pick information, all other arguments can be numbers save for swin which must be either P, S or all (case-sensitive).
- contbase_list (List of tuple of string) – List of tuples of the form [‘path’, ‘type’, ‘network’] Where path is the path to the continuous database, type is the directory structure, which can be either Yyyyy/Rjjj.01, which is the standard IRIS Year, julian day structure, or, yyyymmdd which is a single directory for every day.
- lowcut (float) – Low cut (Hz), if set to None will look in template defaults file
- lowcut – High cut (Hz), if set to None will look in template defaults file
- samp_rate (float) – New sampling rate in Hz, if set to None will look in template defaults file
- filt_order (int) – Filter level, if set to None will look in template defaults file
- length (float) – Extract length in seconds, if None will look in template defaults file.
- prepick (float) – Pre-pick time in seconds
- swin (str) – Either ‘all’, ‘P’ or ‘S’, to select which phases to output.
- debug (int) – Level of debugging output, higher=more
-
template_gen.
from_sfile
(sfile, lowcut, highcut, samp_rate, filt_order, length, swin, debug=0)[source]¶ Function to read in picks from sfile then generate the template from the picks within this and the wavefile found in the pick file.
Parameters: - sfile (string) – sfilename must be the path to a seisan nordic type s-file containing waveform and pick information.
- lowcut (float) – Low cut (Hz), if set to None will look in template defaults file
- lowcut – High cut (Hz), if set to None will look in template defaults file
- samp_rate (float) – New sampling rate in Hz, if set to None will look in template defaults file
- filt_order (int) – Filter level, if set to None will look in template defaults file
- swin (str) – Either ‘all’, ‘P’ or ‘S’, to select which phases to output.
- length (float) – Extract length in seconds, if None will look in template defaults file.
- debug (int) – Debug level, higher number=more output.