5.6. pre_processing¶
Utilities module for the EQcorrscan package written by Calum Chamberlain of Victoria University Wellington. These functions are designed to do the basic processing of the data using obspy modules (which also rely on scipy and numpy).
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/>.
-
pre_processing.
_check_daylong
(tr)[source]¶ Function to check the data quality of the daylong file - check to see that the day isn’t just zeros, with large steps, if it is then the resampling will hate it.
Parameters: tr (obspy.Trace) – Trace to check if the data are daylong. Return qual: bool
-
pre_processing.
dayproc
(st, lowcut, highcut, filt_order, samp_rate, starttime, debug=0, parallel=True, num_cores=False)[source]¶ Wrapper for dayproc to parallel multiple traces in a stream.
Works in place on data. This is employed to ensure all parts of the data are processed in the same way.
Parameters: - st (obspy.Stream) – Stream to process (can be trace)
- highcut (float) – High cut in Hz for bandpass
- filt_order (int) – Corners for bandpass
- samp_rate (float) – Desired sampling rate in Hz
- debug (int) – Debug output level from 0-5, higher numbers = more output
- starttime (obspy.UTCDateTime) – Desired start of trace
- parallel (bool) – Set to True to process traces in parallel, this is often faster than serial processing of traces: defaults to True
- num_cores (int) – Control the number of cores for parallel processing, if set to False then this will use all the cores.
Returns: obspy.Stream
Note
Will convert channel names to two characters long.
-
pre_processing.
process
(tr, lowcut, highcut, filt_order, samp_rate, debug, starttime=False, full_day=False)[source]¶ Basic function to bandpass, downsample and check headers and length of trace to ensure files start at the start of a day and are daylong.
Works in place on data. This is employed to ensure all parts of the data are processed in the same way.
Note
Usually this function is called via dayproc or shortproc.
Parameters: - tr (obspy.Trace) – Trace to process
- highcut (float) – High cut in Hz for bandpass
- filt_order (int) – Corners for bandpass
- samp_rate (float) – Desired sampling rate in Hz
- debug (int) – Debug output level from 0-5, higher numbers = more output
- starttime (obspy.UTCDateTime) – Desired start of trace
- full_day (bool) – Whether to expect, and enforce a full day of data or not.
Returns: obspy.Stream
Note
Will convert channel names to two charecters long.
-
pre_processing.
shortproc
(st, lowcut, highcut, filt_order, samp_rate, debug=0, parallel=False, num_cores=False)[source]¶ Basic function to bandpass and downsample.
Works in place on data. This is employed to ensure all parts of the data are processed in the same way.
Parameters: - st (obspy.Stream) – Stream to process
- highcut (float) – High cut for bandpass in Hz
- lowcut (float) – Low cut for bandpass in Hz
- filt_order (int) – Number of corners for bandpass filter
- samp_rate (float) – Sampling rate desired in Hz
- debug (int) – Debug flag from 0-5, higher numbers = more output
- parallel (bool) – Set to True to process traces in parallel, for small numbers of traces this is often slower than serial processing, defaults to False
- num_cores (int) – Control the number of cores for parallel processing, if set to False then this will use all the cores.
Returns: obspy.Stream
Note
Will convert channel names to two characters long.
Warning
If you intend to use this for processing templates you should consider how resampling will effect your cross-correlations. Minor differences in resampling between day-long files (which you are likely to use for continuous detection) and shorter files will reduce your cross-correlations!