wonambi.trans.extern.dpss module
create dpss using nitime code. Scipy v1.1 will have dpss
- wonambi.trans.extern.dpss.autocorr(x, **kwargs)[source]
Returns the autocorrelation of signal s at all lags.
- Parameters:
x (ndarray) –
axis (time axis) –
all_lags ({True/False}) – whether to return all nonzero lags, or to clip the length of r_xy to be the length of x and y. If False, then the zero lag correlation is at index 0. Otherwise, it is found at (len(x) + len(y) - 1)/2
Notes
Adheres to the definition
\[\]R_{xx}[k]=E{X[n+k]X^{*}[n]}
where X is a discrete, stationary (ergodic) random process
- wonambi.trans.extern.dpss.autocov(x, **kwargs)[source]
Returns the autocovariance of signal s at all lags.
- Parameters:
x (ndarray) –
axis (time axis) –
all_lags ({True/False}) – whether to return all nonzero lags, or to clip the length of r_xy to be the length of x and y. If False, then the zero lag correlation is at index 0. Otherwise, it is found at (len(x) + len(y) - 1)/2
- Returns:
cxx (ndarray) – The autocovariance function
Notes
Adheres to the definition
\[\]C_{xx}[k]=E{(X[n+k]-E{X})(X[n]-E{X})^{*}}
where X is a discrete, stationary (ergodic) random process
- wonambi.trans.extern.dpss.crosscov(x, y, axis=-1, all_lags=False, debias=True, normalize=True)[source]
Returns the crosscovariance sequence between two ndarrays. This is performed by calling fftconvolve on x, y[::-1]
- Parameters:
x (ndarray) –
y (ndarray) –
axis (time axis) –
all_lags ({True/False}) – whether to return all nonzero lags, or to clip the length of s_xy to be the length of x and y. If False, then the zero lag covariance is at index 0. Otherwise, it is found at (len(x) + len(y) - 1)/2
debias ({True/False}) – Always removes an estimate of the mean along the axis, unless told not to (eg X and Y are known zero-mean)
- Returns:
cxy (ndarray) – The crosscovariance function
Notes
cross covariance of processes x and y is defined as
\[\]C_{xy}[k]=E{(X(n+k)-E{X})(Y(n)-E{Y})^{*}}
where X and Y are discrete, stationary (or ergodic) random processes
Also note that this routine is the workhorse for all auto/cross/cov/corr functions.
- wonambi.trans.extern.dpss.dpss_windows(N, NW, Kmax, interp_from=None, interp_kind='linear')[source]
Returns the Discrete Prolate Spheroidal Sequences of orders [0,Kmax-1] for a given frequency-spacing multiple NW and sequence length N.
- Parameters:
N (int) – sequence length
NW (float, unitless) – standardized half bandwidth corresponding to 2NW = BW/f0 = BW*N*dt but with dt taken as 1
Kmax (int) – number of DPSS windows to return is Kmax (orders 0 through Kmax-1)
interp_from (int (optional)) – The dpss can be calculated using interpolation from a set of dpss with the same NW and Kmax, but shorter N. This is the length of this shorter set of dpss windows.
interp_kind (str (optional)) – This input variable is passed to scipy.interpolate.interp1d and specifies the kind of interpolation as a string (‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic, ‘cubic’) or as an integer specifying the order of the spline interpolator to use.
- Returns:
v, e (tuple,) – v is an array of DPSS windows shaped (Kmax, N) e are the eigenvalues
Notes
Tridiagonal form of DPSS calculation from:
Slepian, D. Prolate spheroidal wave functions, Fourier analysis, and uncertainty V: The discrete case. Bell System Technical Journal, Volume 57 (1978), 1371430
- wonambi.trans.extern.dpss.fftconvolve(in1, in2, mode='full', axis=None)[source]
Convolve two N-dimensional arrays using FFT. See convolve.
This is a fix of scipy.signal.fftconvolve, adding an axis argument and importing locally the stuff only needed for this function
- wonambi.trans.extern.dpss.tridi_inverse_iteration(d, e, w, x0=None, rtol=1e-08)[source]
Perform an inverse iteration to find the eigenvector corresponding to the given eigenvalue in a symmetric tridiagonal system.
- Parameters:
d (ndarray) – main diagonal of the tridiagonal system
e (ndarray) – offdiagonal stored in e[:-1]
w (float) – eigenvalue of the eigenvector
x0 (ndarray) – initial point to start the iteration
rtol (float) – tolerance for the norm of the difference of iterates
- Returns:
e (ndarray) – The converged eigenvector
- wonambi.trans.extern.dpss.tridisolve(d, e, b, overwrite_b=True)[source]
Symmetric tridiagonal system solver, from Golub and Van Loan, Matrix Computations pg 157
- Parameters:
d (ndarray) – main diagonal stored in d[:]
e (ndarray) – superdiagonal stored in e[:-1]
b (ndarray) – RHS vector
- Returns:
x (ndarray) – Solution to Ax = b (if overwrite_b is False). Otherwise solution is stored in previous RHS vector b