eqcorrscan.core.lag_calc.lag_calc

eqcorrscan.core.lag_calc.lag_calc(detections, detect_data, template_names, templates, shift_len=0.2, min_cc=0.4, min_cc_from_mean_cc_factor=None, horizontal_chans=['E', 'N', '1', '2'], vertical_chans=['Z'], cores=1, interpolate=False, plot=False, plotdir=None, export_cc=False, cc_dir=None)[source]

Cross-correlation derived picking of seismic events.

Overseer function to take a list of detection objects, cut the data for them to lengths of the same length of the template + shift_len on either side. This will output a obspy.core.event.Catalog of picked events. Pick times are based on the lag-times found at the maximum correlation, providing that correlation is above the min_cc.

Parameters
  • detections (list) – List of eqcorrscan.core.match_filter.Detection objects.

  • detect_data (obspy.core.stream.Stream) – All the data needed to cut from - can be a gappy Stream.

  • template_names (list) – List of the template names, used to help identify families of events. Must be in the same order as templates.

  • templates (list) –

    List of the templates, templates must be a list of

    obspy.core.stream.Stream objects.

  • shift_len (float) – Shift length allowed for the pick in seconds, will be plus/minus this amount - default=0.2

  • min_cc (float) – Minimum cross-correlation value to be considered a pick, default=0.4.

  • min_cc_from_mean_cc_factor (float) – If set to a value other than None, then the minimum cross-correlation value for a trace is set individually for each detection based on: min(detect_val / n_chans * min_cc_from_mean_cc_factor, min_cc).

  • horizontal_chans (list) – List of channel endings for horizontal-channels, on which S-picks will be made.

  • vertical_chans (list) – List of channel endings for vertical-channels, on which P-picks will be made.

  • cores (int) – Number of cores to use in parallel processing, defaults to one.

  • interpolate (bool) – Interpolate the correlation function to achieve sub-sample precision.

  • plot (bool) – To generate a plot for every detection or not, defaults to False

  • plotdir – Path to plotting folder, plots will be output here.

  • export_cc (bool) – To generate a binary file in NumPy for every detection or not, defaults to False

  • cc_dir (str) – Path to saving folder, NumPy files will be output here.

Returns

Catalog of events with picks. No origin information is included. These events can then be written out via obspy.core.event.Catalog.write(), or to Nordic Sfiles using eqcorrscan.utils.sfile_util.eventtosfile() and located externally.

Return type

obspy.core.event.Catalog

Note

Picks output in catalog are generated relative to the template start-time. For example, if you generated your template with a pre_pick time of 0.2 seconds, you should expect picks generated by lag_calc to occur 0.2 seconds before the true phase-pick. This is because we do not currently store template meta-data alongside the templates.

Warning

Because of the above note, origin times will be consistently shifted by the static pre_pick applied to the templates.

Warning

This routine requires only one template per channel (e.g. you should not use templates with a P and S template on a single channel). If this does occur an error will be raised.

Note

S-picks will be made on horizontal channels, and P picks made on vertical channels - the default is that horizontal channels end in one of: ‘E’, ‘N’, ‘1’ or ‘2’, and that vertical channels end in ‘Z’. The options vertical_chans and horizontal_chans can be changed to suit your dataset.

Note

Individual channel cross-correlations are stored as a obspy.core.event.Comment for each pick, and the summed cross-correlation value resulting from these is stored as a obspy.core.event.Comment in the main obspy.core.event.Event object.

Note

The order of events is preserved (e.g. detections[n] == output[n]), providing picks have been made for that event. If no picks have been made for an event, it will not be included in the output. However, as each detection has an ID associated with it, these can be mapped to the output resource_id for each Event in the output Catalog. e.g.

detections[n].id == output[m].resource_id

if the output[m] is for the same event as detections[n].

Note

The correlation data that are saved to the binary files can be useful to select an appropriate threshold for your data.