3.6.1.1. quakemigrate.signal.onsets

The quakemigrate.onsets module handles the generation of Onset functions. The default method uses the ratio between the short-term and long-term averages.

Feel free to contribute more Onset function options!

copyright:2020, QuakeMigrate developers.
license:GNU General Public License, Version 3 (https://www.gnu.org/licenses/gpl-3.0.html)

3.6.1.1.1. quakemigrate.signal.onsets.base

A simple abstract base class with method stubs to enable users to extend QuakeMigrate with custom onset functions that remain compatible with the core of the package.

copyright:2020, QuakeMigrate developers.
license:GNU General Public License, Version 3 (https://www.gnu.org/licenses/gpl-3.0.html)
class quakemigrate.signal.onsets.base.Onset(**kwargs)[source]

Bases: abc.ABC

QuakeMigrate default onset function class.

sampling_rate

Desired sampling rate for input data; sampling rate at which the onset functions will be computed.

Type:int
pre_pad

Option to override the default pre-pad duration of data to read before computing 4-D coalescence in detect() and locate().

Type:float, optional
post_pad

Option to override the default post-pad duration of data to read before computing 4-D coalescence in detect() and locate().

Type:float
calculate_onsets()[source]

Generate onset functions that represent seismic phase arrivals

calculate_onsets()[source]

Method stub for calculation of onset functions.

gaussian_halfwidth(phase)[source]

Method stub for Gaussian half-width estimate.

pad(timespan)[source]

Determine the number of samples needed to pre- and post-pad the timespan.

Parameters:timespan (float) – The time window to pad.
Returns:
  • pre_pad (float) – Option to override the default pre-pad duration of data to read before computing 4-D coalescence in detect() and locate().
  • post_pad (float) – Option to override the default post-pad duration of data to read before computing 4-D coalescence in detect() and locate().
post_pad

Get property stub for pre_pad.

pre_pad

Get property stub for pre_pad.

3.6.1.1.2. quakemigrate.signal.onsets.stalta

The default onset function class - performs some pre-processing on raw seismic data and calculates STA/LTA onset (characteristic) function.

copyright:2020, QuakeMigrate developers.
license:GNU General Public License, Version 3 (https://www.gnu.org/licenses/gpl-3.0.html)
class quakemigrate.signal.onsets.stalta.CentredSTALTAOnset(**kwargs)[source]

Bases: quakemigrate.signal.onsets.stalta.STALTAOnset

QuakeMigrate default onset function class - uses a centred STA/LTA onset.

NOTE: THIS CLASS HAS BEEN DEPRECATED AND WILL BE REMOVED IN A FUTURE UPDATE

class quakemigrate.signal.onsets.stalta.ClassicSTALTAOnset(**kwargs)[source]

Bases: quakemigrate.signal.onsets.stalta.STALTAOnset

QuakeMigrate default onset function class - uses a classic STA/LTA onset.

NOTE: THIS CLASS HAS BEEN DEPRECATED AND WILL BE REMOVED IN A FUTURE UPDATE

class quakemigrate.signal.onsets.stalta.STALTAOnset(**kwargs)[source]

Bases: quakemigrate.signal.onsets.base.Onset

QuakeMigrate default onset function class - uses a classic STA/LTA onset.

p_bp_filter

Butterworth bandpass filter specification [lowpass (Hz), highpass (Hz), corners*] *NOTE: two-pass filter effectively doubles the number of corners.

Type:array-like, [float, float, int]
s_bp_filter

Butterworth bandpass filter specification [lowpass (Hz), highpass (Hz), corners*] *NOTE: two-pass filter effectively doubles the number of corners.

Type:array-like, [float, float, int]
p_onset_win

P onset window parameters [STA, LTA] (both in seconds)

Type:array-like, [float, float]
s_onset_win

S onset window parameters [STA, LTA] (both in seconds)

Type:array-like, [float, float]
sampling_rate

Desired sampling rate for input data, in Hz; sampling rate at which the onset functions will be computed.

Type:int
pre_pad

Option to override the default pre-pad duration of data to read before computing 4-D coalescence in detect() and locate(). Default value is calculated from the onset function parameters.

Type:float, optional
position

Compute centred STA/LTA (STA window is preceded by LTA window; value is assigned to end of LTA window / start of STA window) or classic STA/LTA (STA window is within LTA window; value is assigned to end of STA & LTA windows). Default: “classic”.

Centred gives less phase-shifted (late) onset function, and is closer to a Gaussian approximation, but is far more sensitive to data with sharp offsets due to instrument failures. We recommend using classic for detect() and centred for locate() if your data quality allows it. This is the default behaviour; override by setting this variable.

Type:str, optional
calculate_onsets()[source]

Generate onset functions that represent seismic phase arrivals

calculate_onsets(data, log=True, run=None)[source]

Returns a stacked pair of onset (characteristic) functions for the P and S phase arrivals.

Parameters:
  • data (SignalData object) – Light class encapsulating data returned by an archive query.
  • log (bool) – Calculate log(onset) if True, otherwise calculate the raw onset.
  • run
gaussian_halfwidth(phase)[source]

Return the phase-appropriate Gaussian half-width estimate based on the short-term average window length.

Parameters:phase ({'P', 'S'}) – Seismic phase for which to serve the estimate.
onset_centred

Handle deprecated onset_centred kwarg / attribute

post_pad

Post-pad is determined as a function of the max traveltime in the grid and the onset windows

pre_pad

Pre-pad is determined as a function of the onset windows

quakemigrate.signal.onsets.stalta.pre_process(sig, sampling_rate, lc, hc, order=2)[source]

Detrend raw seismic data and apply cosine taper and zero phase-shift Butterworth band-pass filter.

Parameters:
  • sig (array-like) – Data signal to be pre-processed.
  • sampling_rate (int) – Number of samples per second, in Hz.
  • lc (float) – Lowpass frequency of band-pass filter, in Hz.
  • hc (float) – Highpass frequency of band-pass filter, in Hz.
  • order (int, optional) – Number of filter corners. NOTE: two-pass filter effectively doubles the number of corners.
Returns:

fsig – Filtered seismic data.

Return type:

array-like

Raises:

NyquistException – If the high-cut filter specified for the bandpass filter is higher than the Nyquist frequency of the Waveform.signal data.

quakemigrate.signal.onsets.stalta.sta_lta_centred(a, nsta, nlta)[source]

Calculates the ratio of the average signal in a short-term (signal) window to a preceding long-term (noise) window. STA/LTA value is assigned to the end of the LTA / start of the STA.

Parameters:
  • a (array-like) – Signal array
  • nsta (int) – Number of samples in short-term window
  • nlta (int) – Number of samples in long-term window
Returns:

sta / lta – Ratio of short term average window to a preceding long term average window. STA/LTA value is assigned to end of LTA window / start of STA window – “centred”

Return type:

array-like

quakemigrate.signal.onsets.stalta.sta_lta_onset(fsig, stw, ltw, position, log)[source]

Calculate STA/LTA onset (characteristic) function from pre-processed seismic data.

Parameters:
  • fsig (array-like) – Filtered (pre-processed) data signal to be used to generate an onset function.
  • stw (int) – Short term window length (# of samples).
  • ltw (int) – Long term window length (# of samples)
  • position (str) –
    “centred”: Compute centred STA/LTA (STA window is preceded by LTA
    window; value is assigned to end of LTA window / start of STA window) or:
    ”classic”: classic STA/LTA (STA window is within LTA window; value
    is assigned to end of STA & LTA windows).

    Centred gives less phase-shifted (late) onset function, and is closer to a Gaussian approximation, but is far more sensitive to data with sharp offsets due to instrument failures. We recommend using classic for detect() and centred for locate() if your data quality allows it. This is the default behaviour; override by setting self.onset_centred.

  • log (bool) – Will return log(onset) if True, otherwise it will return the raw onset.
Returns:

onset – onset_raw or log(onset_raw); both are clipped between 0.8 and infinity.

Return type:

array-like