move2obspy.
whiten
(data, Nfft, delta, freqmin, freqmax, plot=False)¶This function takes 1dimensional 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: 


Return type:  
Returns:  The FFT of the input trace, whitened between the frequency bounds 
move2obspy.
myCorr
(data, maxlag, plot=False, nfft=None)¶This function takes ndimensional data array, computes the crosscorrelation in the frequency domain and returns the crosscorrelation function between [maxlag:maxlag].
Parameters: 


Return type:  
Returns:  The crosscorrelation function between [maxlag:maxlag] 
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 meanadjusted and cosinetapered (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 Fouriertransformed segments. The crossspectrum \(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 timeseries is assessed using the crosscoherency 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 overline 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 timedelay 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 crossspectral amplitude and crosscoherence, 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 crosscoherences 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}{N1}\)
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 crossspectrum! They should be bandpass filtered around the freqminfreqmax band of interest beforehand.
Parameters: 


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. 
move2obspy.
linear_regression
(xdata, ydata, weights=None, p0=None, intercept_origin=True, **kwargs)¶Use linear least squares to fit a function, f, to data.
This method is a generalized version of
scipy.optimize.minpack.curve_fit()
; allowing for Ordinary Least
Square and Weighted Least Square regressions:
linear_regression(xdata, ydata)
linear_regression(xdata, ydata,
intercept_origin=False)
linear_regression(xdata, ydata, weights)
linear_regression(xdata, ydata, weights,
intercept_origin=False)
If the expected values of slope (and intercept) are different from 0.0, provide the p0 value(s).
Parameters: 


Extra keword arguments will be passed to
scipy.optimize.minpack.curve_fit()
.
Return type:  tuple 

Returns:  (slope, std_slope) if intercept_origin is True ;
(slope, intercept, std_slope, std_intercept) if False . 
preprocessing.
preprocess
(db, stations, comps, goal_day, params, responses=None)¶Fetches data for each stations
and each comps
using the
data_availability table in the database.
To correct for instrument responses, make sure to set remove_response
to “Y” in the config and to provide the responses
DataFrame.
Example: 

>>> from msnoise.api import connect, get_params, preload_instrument_responses
>>> from msnoise.preprocessing import preprocess
>>> db = connect()
>>> params = get_params(db)
>>> responses = preload_instrument_responses(db)
>>> st = preprocess(db, ["YA.UV06","YA.UV10"], ["Z",], "20100901", params, responses)
>>> st
2 Trace(s) in Stream:
YA.UV06.00.HHZ  20100901T00:00:00.000000Z  20100901T23:59:59.950000Z  20.0 Hz, 1728000 samples
YA.UV10.00.HHZ  20100901T00:00:00.000000Z  20100901T23:59:59.950000Z  20.0 Hz, 1728000 samples
Parameters: 


Return type:  
Returns:  A Stream object containing all traces. 