relmt.amp module#

Functions to estimate relative waveform amplitudes

relmt.amp.info(amplitudes, width=80)[source]#

Print statistics of amplitude list to screen

Parameters:
relmt.amp.order_by_ccsum(mtx_abc)[source]#

Order waveforms by pairwise summed cross-correlation coefficients

Parameters:

mtx_abc (ndarray) – Waveform of shape (3, samples) of events a, b, and c

Returns:

iord (ndarray) – Indices (3,) that order \(u_a, u_b, u_c\) by cc

relmt.amp.p_misfit(mtx_ab, Aab)[source]#

Misfit of the P waveform reconstruction

The residual norm of the reconstruction devided by the norm of the predicted waveform \(u_a\):

\[\Psi_P = || A^{ab} u_b - u_a || / || u_a ||\]
Parameters:
  • mtx_ab (ndarray) – Waveform matrix of shape (2, samples) holding events a and b

  • Aab (float) – Relative ampltiude between events a and b

Returns:

floatNormalized reconstruction misfit

relmt.amp.p_reconstruction_correlation(mtx_ab)[source]#

Correlation coefficient of the P-wave reconstruction

Parameters:

mtx_ab (ndarray) – Waveform matrix of shape (2, samples) holding events a and b

Returns:

floatNormalized reconstruction misfit

Note

The cross correlation coefficient is independent of the absolute amplitude, so we do not require the relative amplitude Aab for P-waves

relmt.amp.paired_p_amplitudes(ab, mname, shape, dtype, hdr, highpass, lowpass, a, b, realign=False)[source]#

Compute relative P amplitude ratios for one event pair in arr

..note:

The here implemented approach allows to filter each event pair individually allowing for more flexibility than principal_p_amplitudes() when comparing large differences in magnitude

Parameters:
  • ab (tuple[int, int]) – Indices of waveforms in shared memory

  • mname (str) – Name of the array buffer in memory

  • shape (tuple[int, int, int]) – Shape of the array in memory

  • dtype (type) – data type of the array in memory

  • hdr (Header) – Header with metadata, including sampling rate, phase start and end, taper length, and event information

  • highpass (float) – Highpass filter frequency in Hz

  • lowpass (float) – Lowpass filter frequency in Hz

  • a (int) – Number of event a

  • b (int) – Number of event b

  • realign (bool) – Re-align seismograms after applying filter

Returns:

P amplitude ratio

relmt.amp.pca_amplitude_2p(mtx_ab)[source]#

Calculate the relative amplitude of a pair of P-waves

The relative amplitudes \(A^{ab}\) that predicts waveform \(u_a\) from waveform \(u_b\), such that:

\[A^{ab} u_b = u_a\]
Parameters:

mtx_ab (ndarray) – Waveform matrix of shape (2, samples) holding events a and b

Returns:

floatRelative ampltiude between events a and b

relmt.amp.pca_amplitude_3s(mtx_abc, order=True)[source]#

Relative amplitudes between triplet of S-waves.

Given waveforms of three events, determine which two waveforms \(b\) and \(c\) are most different from each other and compute the relative amplitudes \(B^{abc}\) and \(B^{acb}\) that predict the third waveform :math:’u_a’, such that:

\[B^{abc} u_b + B^{acb} * u_c = u_a\]
Parameters:
  • mtx_abc (ndarray) – Waveform matrix of shape (3, samples) holding events a, b and c

  • order (bool) – If True, order the waveforms by pairwise summed cross-correlation coefficients before computing the relative amplitudes. If False, use the order of the input matrix.

Returns:

  • Babc – Relative ampltiude between event a and b, given the third event is c

  • Bacb – Relative ampltiude between event a and c, given the third event is b

  • iord – Resulting (3,) row indices into mtx_abc of events a, b and c

  • sigmas(3,) first three singular values of the seismogram decomposition

relmt.amp.pca_amplitudes_p(mtx)[source]#

Calculate the relative amplitude of all P-wave pairs in mtx as the relative contribution of the principal seismogram

Parameters:

mtx (ndarray) – (events, samples) waveform matrix

Returns:

ndarray – * (events * (events - 1) / 2, ) relative ampltiude between all pairwise * event combinations.

relmt.amp.pca_amplitudes_s(mtx)[source]#

Calculate the relative amplitude of all P-wave pairs in mtx as the relative contribution of the principal seismogram

Parameters:

mtx (ndarray) – (events, samples) waveform matrix

Returns:

  • Babc, Bacb(events * (events - 1) / 2, ) relative ampltiude between all tripletwise event combinations.

  • iord(events * (events - 1) / 2, 3)

  • sigmas(3,) first three singular values of seismogram decomposition

relmt.amp.principal_p_amplitudes(arr, hdr, highpass, lowpass)[source]#

Compute relative P amplitude ratios for all event combinations in arr

Apply a common filter to all events and meassure amplitude ratio as the ratio of principal seismogram contribtions.

..note:

The here implemented approach may be more stable against noise than paired_p_amplitudes(), but requires a common filter for all events

Parameters:
  • arr (ndarray) – Waveform matrix of shape (events, components, samples) holding all events

  • hdr (Header) – Header with metadata, including sampling rate, phase start and end, taper length, and event information

  • highpass (float) – Highpass filter frequency in Hz

  • lowpass (float) – Lowpass filter frequency in Hz

Returns:

list[P_Amplitude_Ratio]List of relative P amplitude ratios for all event pairs

relmt.amp.principal_s_amplitudes(arr, hdr, highpass, lowpass)[source]#

Compute relative S amplitude ratios for all event combinations in arr

Apply a common filter to all events and meassure amplitude ratio as the ratio of principal seismogram contribtions.

..note:

The here implemented approach may be more stable against noise than triplet_s_amplitudes(), but requires a common filter for all events

Parameters:
  • arr (ndarray) – Waveform matrix of shape (events, components, samples) holding all events

  • hdr (Header) – Header with metadata, including sampling rate, phase start and end, taper length, and event information

  • highpass (float) – Highpass filter frequency in Hz

  • lowpass (float) – Lowpass filter frequency in Hz

Returns:

list[S_Amplitude_Ratios]List of relative S amplitude ratios for all event triplet combinations

relmt.amp.s_misfit(mtx_abc, Babc, Bacb)[source]#

Misfit of the S waveform reconstruction

The residual norm of the reconstruction devided by the norm of the predicted waveform \(u_a\):

\[\Psi_S = || B^{abc} u_b + B^{acb} u_c - u_a || / || u_a ||\]
Parameters:
  • mtx_abc (ndarray) – Waveform matrix of shape (3, samples) holding events a, b and c

  • Babc (float) – Relative ampltiude between event a and b, given the third event is c

  • Bacb (float) – Relative ampltiude between event a and c, given the third event is b

Returns:

floatNormalized reconstruction misfit

relmt.amp.s_reconstruction_correlation(mtx_abc, Babc, Bacb)[source]#

Correlation coefficient of the S-wave reconstruction

Parameters:

mtx_abc (ndarray) – Waveform matrix of shape (3, samples) holding events a, b and c

Returns:

floatCorrelation coefficient

Note

For S-waves, the shape of the reconstucted waveform depends on the relative linear scaling

Parameters:
relmt.amp.synthetic_p(moment_tensors, event_dict, station_dictionary, phase_dictionary, p_pairs)[source]#

Generate synthetic relative amplitude meassurements.

Either compute all possible event combinations from the supplied phase dictionary and mment tensors, or supply explicit p_pairs and s_tripltes (e.g. from existing core.P_Amplitude_Ratio and core.S_Amplitude_Ratios objects).

Parameters:
  • moment_tensors (dict[int, MT]) – Dictionary of moment tensors indexed by event ID.

  • event_dict (dict[int, Event]) – Dictionary of events with locations

  • station_dictionary (dict[str, Station]) – Dictionary of stations with locations indexed by station name.

  • phase_dictionary (dict[str, Phase]) – Dictionary of phases with take-off angles indexed by phase name.

  • p_pairs (list[tuple[str, int, int]]) – List of tuples of the form (station, event_a, event_b) for P-wave relative amplitude pairs.

Returns:

  • p_ratios(len(p_pairs),) arrays of synthetic P- …

  • p_sigmas(len(p_pairs), 2) First two singular values of the P-amplitude decomposition

relmt.amp.synthetic_s(moment_tensors, event_dict, station_dictionary, phase_dictionary, s_triplets, keep_order=False)[source]#

Generate synthetic relative amplitude meassurements.

Either compute all possible event combinations from the supplied phase dictionary and mment tensors, or supply explicit p_pairs and s_tripltes (e.g. from existing core.P_Amplitude_Ratio and core.S_Amplitude_Ratios objects).

Parameters:
  • moment_tensors (dict[int, MT]) – Dictionary of moment tensors indexed by event ID.

  • event_dict (dict[int, Event]) – Dictionary of events with locations

  • station_dictionary (dict[str, Station]) – Dictionary of stations with locations indexed by station name.

  • phase_dictionary (dict[str, Phase]) – Dictionary of phases with take-off angles indexed by phase name.

  • s_triplets (list[tuple[str, int, int, int]]) – List of tuples of the form (station, event_a, event_b, event_c) for S-wave relative amplitude triplets.

  • keep_order (bool) – If False, order the waveforms by pairwise summed cross-correlation coefficients before computing the relative S amplitudes. If True, use the order of the input triplets. In any case, the applied order will be returned in the orders variable.

Returns:

  • s_ratios(len(s_triplets, 2) … and S-relative amplitude measurements.

  • orders(len(s_triplets, 3) array of indices that order the S waveforms according to greatest differences in waveforms.

  • s_sigmas(len(s_triplets), 3) first three singular values of the S-amplitude decomposition

relmt.amp.triplet_s_amplitudes(abc, mname, shape, dtype, hdr, highpass, lowpass, a, b, c, realign=False)[source]#

Compute relative S amplitude ratios for one event triplet in arr

Use

..note:

The here implemented approach allows to filter each event pair individually allowing for more flexibility than principal_s_amplitudes() when comparing large differences in magnitude

Parameters:
  • abc (tuple[int, int, int]) – Indices to events a, b, c

  • mname (str) – Name of the array buffer in memory

  • shape (tuple[int, int, int]) – Shape of the array in memory

  • dtype (type) – data type of the array in memory

  • hdr (Header) – Header with metadata, including sampling rate, phase start and end, taper length, and event information

  • highpass (float) – Highpass filter frequency in Hz

  • lowpass (float) – Lowpass filter frequency in Hz

  • a (int) – Number of event a

  • b (int) – Number of event b

  • c (int) – Number of event c

  • realign (bool) – Re-align seismograms after applying filter

Returns:

list[S_Amplitude_Ratios]S amplitude ratios