cctm

General utility functions used to calculate misfit and adjoint sources for the cross correlation traveltime misfit function

Module Contents

Functions

calculate_cc_shift(d, s, dt[, use_cc_error, ...])

Calculate cross-correlation traveltime misfit (time shift, amplitude

calculate_cc_adjsrc(s, tshift, dlna, dt[, sigma_dt, ...])

Calculate adjoint source and misfit of the cross correlation traveltime

calculate_dd_cc_shift(d, s, d_2, s_2, dt[, ...])

Calculate double difference cross-correlation traveltime misfit

calculate_dd_cc_adjsrc(s, s_2, tshift, dlna, dt[, ...])

Calculate double difference cross corrrelation adjoint sources.

cc_correction(s, cc_shift, dlna)

Apply a correction to synthetics by shifting in time by cc_shift samples

calculate_cc_error(d, s, dt, cc_shift, dlna[, ...])

Estimate error for dt and dlna with uncorrelation assumption. Used for

xcorr_shift(d, s)

Determine the required time shift for peak cross-correlation of two arrays

subsample_xcorr_shift(d, s)

Calculate the correlation time shift around the maximum amplitude of the

cctm.calculate_cc_shift(d, s, dt, use_cc_error=True, dt_sigma_min=1.0, dlna_sigma_min=0.5, **kwargs)[source]

Calculate cross-correlation traveltime misfit (time shift, amplitude anomaly) and associated errors, for a given window. This is accessed by both the CC and MTM measurement methods.

Note

Kwargs not used but allows Config class to pass relevant parameters without explicitely naming them in the function call

Parameters
  • d (np.array) – observed data to calculate cc shift and dlna

  • s (np.array) – synthetic data to calculate cc shift and dlna

  • dt (float) – time sampling rate delta t units seconds

  • use_cc_error (bool) – use cross correlation errors for normalization

  • dt_sigma_min (float) – minimum travel time error allowed

  • dlna_sigma_min (float) – minimum amplitude error allowed

Return type

tuple (float, float, float, float)

Returns

(time shift [s], amplitude anomaly, time shift error [s], amplitude anomaly error)

cctm.calculate_cc_adjsrc(s, tshift, dlna, dt, sigma_dt=1.0, sigma_dlna=0.5, **kwargs)[source]

Calculate adjoint source and misfit of the cross correlation traveltime misfit function. This is accessed by both the CC and MTM measurement methods.

Note

Kwargs not used but allows Config class to pass relevant parameters without explicitely naming them in the function call

Parameters
  • s (np.array) – synthetic data array

  • tshift (float) – measured time shift from calculate_cc_shift

  • dlna (float) – measured amplitude anomaly from calculate_cc_shift

  • dt (float) – delta t, time sampling rate of s

  • sigma_dt (float) – traveltime error from calculate_cc_shift

  • sigma_dlna (float) – amplitude anomaly error from calculate_cc_shift

Return type

(float, float, np.array, np.array)

Returns

(tshift misfit, dlna misfit, tshift adjsrc, dlna adjsrc)

cctm.calculate_dd_cc_shift(d, s, d_2, s_2, dt, use_cc_error=True, dt_sigma_min=1.0, dlna_sigma_min=0.5, **kwargs)[source]

Calculate double difference cross-correlation traveltime misfit (time shift, amplitude anomaly) and associated errors, for a given window. Slight variation on normal CC shift calculation

TODO
  • DD dlna measurement was not properly calculated in the RDNO version

Assumes d, s, d_2 and s_2 all have the same sampling rate

Note

Kwargs not used but allows Config class to pass relevant parameters without explicitely naming them in the function call

Parameters
  • d (np.array) – observed data to calculate cc shift and dlna

  • s (np.array) – synthetic data to calculate cc shift and dlna

  • dt (float) – time sampling rate delta t units seconds

  • d_2 (np.array) – 2nd pair observed data to calculate cc shift and dlna

  • s_2 (np.array) – 2nd pair synthetic data to calculate cc shift and dlna

  • use_cc_error (bool) – use cross correlation errors for normalization

  • dt_sigma_min (float) – minimum travel time error allowed

  • dlna_sigma_min (float) – minimum amplitude error allowed

Return type

tuple (float, float, float, float)

Returns

(time shift [s], amplitude anomaly, time shift error [s], amplitude anomaly error)

cctm.calculate_dd_cc_adjsrc(s, s_2, tshift, dlna, dt, sigma_dt=1.0, sigma_dlna=0.5, **kwargs)[source]

Calculate double difference cross corrrelation adjoint sources.

TODO
  • Add dlna capability to this function

Note

Kwargs not used but allows Config class to pass relevant parameters without explicitely naming them in the function call

Parameters
  • s (np.array) – synthetic data array

  • s_2 (np.array) – second synthetic data array

  • tshift (float) – measured dd time shift from calculate_dd_cc_shift

  • dlna (float) – measured dd amplitude anomaly from calculate_dd_cc_shift

  • dt (float) – delta t, time sampling rate of s

  • sigma_dt (float) – traveltime error from calculate_cc_shift

  • sigma_dlna (float) – amplitude anomaly error from calculate_cc_shift

Return type

(float, float, np.array, np.array, np.array, np.array)

Returns

(tshift misfit, dlna misfit, tshift adjsrc, dlna adjsrc, tshift adjsrc 2, dlna adjsrc 2)

cctm.cc_correction(s, cc_shift, dlna)[source]

Apply a correction to synthetics by shifting in time by cc_shift samples and scaling amplitude by dlna. Provides the ‘best fitting’ synthetic array w.r.t data as realized by the cross correlation misfit function

Parameters
  • s (np.array) – synthetic data array

  • cc_shift (int) – time shift (in samples) as calculated using cross a cross correlation

  • dlna (float) – amplitude anomaly as calculated by amplitude anomaly eq.

Return type

(np.array, np.array)

Returns

(time shifted synthetic array, amplitude scaled synthetic array)

cctm.calculate_cc_error(d, s, dt, cc_shift, dlna, dt_sigma_min=1.0, dlna_sigma_min=0.5)[source]

Estimate error for dt and dlna with uncorrelation assumption. Used for normalization of the traveltime measurement

Parameters
  • d (np.array) – observed time series array to calculate error for

  • s (np.array) – synthetic time series array to calculate error for

  • dt (float) – delta t, time sampling rate

  • cc_shift (int) – total amount of cross correlation time shift in samples

  • dlna (float) – amplitude anomaly calculated for cross-correlation measurement

  • dt_sigma_min (float) – minimum travel time error allowed

  • dlna_sigma_min (float) – minimum amplitude error allowed

cctm.xcorr_shift(d, s)[source]

Determine the required time shift for peak cross-correlation of two arrays

Parameters
  • d (np.array) – observed time series array

  • s (np.array) – synthetic time series array

cctm.subsample_xcorr_shift(d, s)[source]

Calculate the correlation time shift around the maximum amplitude of the synthetic trace s with subsample accuracy.

Parameters
  • d (obspy.core.trace.Trace) – observed waveform to calculate adjoint source

  • s (obspy.core.trace.Trace) – synthetic waveform to calculate adjoint source