4.2.1.6. eqcorrscan.core.template_gen.from_sac

eqcorrscan.core.template_gen.from_sac(sac_files, lowcut, highcut, samp_rate, filt_order, length, swin, prepick, all_horiz=False, delayed=True, plot=False, debug=0)[source]

Generate a multiplexed template from a list of SAC files.

Function to read picks and waveforms from SAC data, and generate a template from these. Usually sac_files is a list of all single-channel SAC files for a given event, a single, multi-channel template will be created from these traces.

All files listed in sac_files should be associated with a single event.

Parameters:
  • sac_files (list) osbpy.core.stream.Stream of sac waveforms, or list of paths to sac waveforms.
  • lowcut (float) Low cut (Hz), if set to None will look in template defaults file
  • highcut (float) 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.
  • prepick (float) Length to extract prior to the pick in seconds.
  • all_horiz (bool) To use both horizontal channels even if there is only a pick on one of them. Defaults to False.
  • debug (int) Debug level, higher number=more output.
  • plot (bool) Turns template plotting on or off.
  • delayed (bool) If True, each channel will begin relative to it’s own pick-time, if set to False, each channel will begin at the same time.
Returns:

obspy.core.stream.Stream Newly cut template

Note

This functionality is not supported for obspy versions below 1.0.0 as references times are not read in by SACIO, which are needed for defining pick times.

Example

>>> from eqcorrscan.core.template_gen import from_sac
>>> import glob
>>> # Get all the SAC-files associated with one event.
>>> sac_files = glob.glob('eqcorrscan/tests/test_data/SAC/2014p611252/*')
>>> template = from_sac(sac_files=sac_files, lowcut=2.0, highcut=10.0,
...                     samp_rate=25.0, filt_order=4, length=2.0,
...                     swin='all', prepick=0.1, all_horiz=True)
>>> print(template[0].stats.sampling_rate)
25.0
>>> print(len(template))
15