Core Functions
- msnoise.move2obspy.myCorr(data, maxlag, plot=False, nfft=None)
This function takes ndimensional data array, computes the cross-correlation in the frequency domain and returns the cross-correlation function between [-maxlag:maxlag].
- Parameters:
data (
numpy.ndarray
) – This array contains the fft of each timeseries to be cross-correlated.maxlag (int) – This number defines the number of samples (N=2*maxlag + 1) of the CCF that will be returned.
- Return type:
- Returns:
The cross-correlation function between [-maxlag:maxlag]
- msnoise.move2obspy.myCorr2(data, maxlag, energy, index, plot=False, nfft=None, normalized=False)
This function takes ndimensional data array, computes the cross-correlation in the frequency domain and returns the cross-correlation function between [-maxlag:maxlag].
- Parameters:
data (
numpy.ndarray
) – This array contains the fft of each timeseries to be cross-correlated.maxlag (int) – This number defines the number of samples (N=2*maxlag + 1) of the CCF that will be returned.
- Return type:
- Returns:
The cross-correlation function between [-maxlag:maxlag]
- msnoise.move2obspy.pcc_xcorr(data, maxlag, energy, index, plot=False, nfft=None, normalized=False)
- Parameters:
data –
maxlag –
energy –
index –
plot –
nfft –
normalized –
- Returns:
- msnoise.move2obspy.whiten(data, Nfft, delta, freqmin, freqmax, plot=False, returntime=False)
This function takes 1-dimensional data timeseries array, goes to frequency domain using fft, whitens the amplitude of the spectrum in frequency domain between freqmin and freqmax and returns the whitened fft.
- Parameters:
data (
numpy.ndarray
) – Contains the 1D time series to whitenNfft (int) – The number of points to compute the FFT
delta (float) – The sampling frequency of the data
freqmin (float) – The lower frequency bound
freqmax (float) – The upper frequency bound
plot (bool) – Whether to show a raw plot of the action (default: False)
- Return type:
- Returns:
The FFT of the input trace, whitened between the frequency bounds
- msnoise.move2obspy.whiten2(fft, Nfft, low, high, porte1, porte2, psds, whiten_type)
This function takes 1-dimensional data timeseries array, goes to frequency domain using fft, whitens the amplitude of the spectrum in frequency domain between freqmin and freqmax and returns the whitened fft.
- Parameters:
data (
numpy.ndarray
) – Contains the 1D time series to whitenNfft (int) – The number of points to compute the FFT
delta (float) – The sampling frequency of the data
freqmin (float) – The lower frequency bound
freqmax (float) – The upper frequency bound
plot (bool) – Whether to show a raw plot of the action (default: False)
- Return type:
- Returns:
The FFT of the input trace, whitened between the frequency bounds
- msnoise.move2obspy.smooth(x, window='boxcar', half_win=3)
some window smoothing
- msnoise.move2obspy.getCoherence(dcs, ds1, ds2)
- msnoise.move2obspy.mwcs(current, reference, freqmin, freqmax, df, tmin, window_length, step, smoothing_half_win=5)
The current time series is compared to the reference. Both time series are sliced in several overlapping windows. Each slice is mean-adjusted and cosine-tapered (85% taper) before being Fourier- transformed to the frequency domain. \(F_{cur}(\nu)\) and \(F_{ref}(\nu)\) are the first halves of the Hermitian symmetric Fourier-transformed segments. The cross-spectrum \(X(\nu)\) is defined as \(X(\nu) = F_{ref}(\nu) F_{cur}^*(\nu)\)
in which \({}^*\) denotes the complex conjugation. \(X(\nu)\) is then smoothed by convolution with a Hanning window. The similarity of the two time-series is assessed using the cross-coherency between energy densities in the frequency domain:
\(C(\nu) = \frac{|\overline{X(\nu))}|}{\sqrt{|\overline{F_{ref}(\nu)|^2} |\overline{F_{cur}(\nu)|^2}}}\)
in which the over-line here represents the smoothing of the energy spectra for \(F_{ref}\) and \(F_{cur}\) and of the spectrum of \(X\). The mean coherence for the segment is defined as the mean of \(C(\nu)\) in the frequency range of interest. The time-delay between the two cross correlations is found in the unwrapped phase, \(\phi( u)\), of the cross spectrum and is linearly proportional to frequency:
\(\phi_j = m. u_j, m = 2 \pi \delta t\)
The time shift for each window between two signals is the slope \(m\) of a weighted linear regression of the samples within the frequency band of interest. The weights are those introduced by [Clarke2011], which incorporate both the cross-spectral amplitude and cross-coherence, unlike [Poupinet1984]. The errors are estimated using the weights (thus the coherence) and the squared misfit to the modelled slope:
\(e_m = \sqrt{\sum_j{(\frac{w_j \nu_j}{\sum_i{w_i \nu_i^2}})^2}\sigma_{\phi}^2}\)
where \(w\) are weights, \(\nu\) are cross-coherences and \(\sigma_{\phi}^2\) is the squared misfit of the data to the modelled slope and is calculated as \(\sigma_{\phi}^2 = \frac{\sum_j(\phi_j - m \nu_j)^2}{N-1}\)
The output of this process is a table containing, for each moving window: the central time lag, the measured delay, its error and the mean coherence of the segment.
Warning
The time series will not be filtered before computing the cross-spectrum! They should be band-pass filtered around the freqmin-freqmax band of interest beforehand.
- Parameters:
current (
numpy.ndarray
) – The “Current” timeseriesreference (
numpy.ndarray
) – The “Reference” timeseriesfreqmin (float) – The lower frequency bound to compute the dephasing (in Hz)
freqmax (float) – The higher frequency bound to compute the dephasing (in Hz)
df (float) – The sampling rate of the input timeseries (in Hz)
tmin (float) – The leftmost time lag (used to compute the “time lags array”)
window_length (float) – The moving window length (in seconds)
step (float) – The step to jump for the moving window (in seconds)
smoothing_half_win (int) – If different from 0, defines the half length of the smoothing hanning window.
- Return type:
- Returns:
[time_axis,delta_t,delta_err,delta_mcoh]. time_axis contains the central times of the windows. The three other columns contain dt, error and mean coherence for each window.