5.2.11.1.1. eqcorrscan.utils.pre_processing.dayproc

eqcorrscan.utils.pre_processing.dayproc(st, lowcut, highcut, filt_order, samp_rate, starttime, parallel=True, num_cores=False, ignore_length=False, seisan_chan_names=False, fill_gaps=True, ignore_bad_data=False, fft_threads=1)[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.core.stream.Stream) – Stream to process (can be trace).

  • lowcut (float) – Low cut in Hz for bandpass.

  • highcut (float) – High cut in Hz for bandpass.

  • filt_order (int) – Corners for bandpass.

  • samp_rate (float) – Desired sampling rate in Hz.

  • starttime (obspy.core.utcdatetime.UTCDateTime) – Desired start-date 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.

  • ignore_length (bool) – See warning below.

  • seisan_chan_names (bool) – Whether channels are named like seisan channels (which are two letters rather than SEED convention of three) - defaults to True.

  • fill_gaps (bool) – Whether to pad any gaps found with zeros or not.

  • ignore_bad_data (bool) – If False (default), errors will be raised if data are excessively gappy or are mostly zeros. If True then no error will be raised, but an empty trace will be returned.

  • fft_threads (int) – Number of threads to use for pyFFTW FFT in resampling. Note that it is not recommended to use fft_threads > 1 and num_cores > 1.

Returns

Processed stream.

Return type

obspy.core.stream.Stream

Note

If your data contain gaps you should NOT fill those gaps before using the pre-process functions. The pre-process functions will fill the gaps internally prior to processing, process the data, then re-fill the gaps with zeros to ensure correlations are not incorrectly calculated within gaps. If your data have gaps you should pass a merged stream without the fill_value argument (e.g.: st = st.merge()).

Warning

Will fail if data are less than 19.2 hours long - this number is arbitrary and is chosen to alert the user to the dangers of padding to day-long, if you don’t care you can ignore this error by setting ignore_length=True. Use this option at your own risk! It will also warn any-time it has to pad data - if you see strange artifacts in your detections, check whether the data have gaps.

Example

>>> import obspy
>>> if int(obspy.__version__.split('.')[0]) >= 1:
...     from obspy.clients.fdsn import Client
... else:
...     from obspy.fdsn import Client
>>> from obspy import UTCDateTime
>>> from eqcorrscan.utils.pre_processing import dayproc
>>> client = Client('NCEDC')
>>> t1 = UTCDateTime(2012, 3, 26)
>>> t2 = t1 + 86400
>>> bulk_info = [('BP', 'JCNB', '40', 'SP1', t1, t2)]
>>> st = client.get_waveforms_bulk(bulk_info)
>>> st_keep = st.copy()  # Copy the stream for later examples
>>> # Example of bandpass filtering
>>> st = dayproc(st=st, lowcut=2, highcut=9, filt_order=3, samp_rate=20,
...              starttime=t1, parallel=True, num_cores=2)
>>> print(st[0])
BP.JCNB.40.SP1 | 2012-03-26T00:00:00.000000Z - 2012-03-26T23:59:59.950000Z | 20.0 Hz, 1728000 samples
>>> # Example of lowpass filtering
>>> st = dayproc(st=st, lowcut=None, highcut=9, filt_order=3, samp_rate=20,
...              starttime=t1, parallel=True, num_cores=2)
>>> print(st[0])
BP.JCNB.40.SP1 | 2012-03-26T00:00:00.000000Z - 2012-03-26T23:59:59.950000Z | 20.0 Hz, 1728000 samples
>>> # Example of highpass filtering
>>> st = dayproc(st=st, lowcut=2, highcut=None, filt_order=3, samp_rate=20,
...              starttime=t1, parallel=True, num_cores=2)
>>> print(st[0])
BP.JCNB.40.SP1 | 2012-03-26T00:00:00.000000Z - 2012-03-26T23:59:59.950000Z | 20.0 Hz, 1728000 samples