Spectral transforms are used in order to estimate the frequency-domain representation of time-series. Several methods can be used and this module contains implementations of several algorithms for the calculation of spectral transforms.
The functions in this module are:
XXX
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
NW : float, unitless
Kmax : int
interp_from: int (optional) :
interp_kind: str (optional) :
|
---|---|
Returns : | v, e : tuple,
|
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
Returns the frequency response of the IIR or FIR filter described by beta and alpha coefficients.
Parameters : | b : beta sequence (moving average component) a : alpha sequence (autoregressive component) n_freqs : size of frequency grid sides : {‘onesided’, ‘twosided’}
|
---|---|
Returns : | fgrid, H(e^jw) : |
Notes
For a description of the linear constant-coefficient difference equation, see http://en.wikipedia.org/wiki/Z-transform
Compute the spectra of an n-tuple of time series and all of the pairwise cross-spectra.
Parameters : | time_series: float array :
method: dict, optional :
|
---|---|
Returns : | f: float array :
fxy: float array :
|
Computes the spectra of two timeseries and the cross-spectrum between them
Parameters : | x,y : float arrays
method: dict, optional :
|
---|---|
Returns : | f: float array :
fxx: float array :
fyy: float array :
fxy: float array :
|
The cross-spectrum between two tapered time-series, derived from a multi-taper spectral estimation.
Parameters : | tx, ty: ndarray (K, ..., N) :
weights: ndarray, or 2-tuple or list :
sides: str in {‘onesided’, ‘twosided’} :
|
---|
Notes
spectral densities are always computed as
S_{xy}^{mt}(f) = \frac{\sum_k [d_k^x(f)y_k^x(f)][d_k^y(f)(y_k^y(f))^{*}]}{[\sum_k d_k^x(f)^2]^{\frac{1}{2}}[\sum_k d_k^y(f)^2]^{\frac{1}{2}}}
Returns an estimate of the Cross Spectral Density (CSD) function between all (N choose 2) pairs of timeseries in s, using the multitaper method. If the NW product, or the BW and Fs in Hz are not specified by the user, a bandwidth of 4 times the fundamental frequency, corresponding to NW = 4 will be used.
Parameters : | s : ndarray
Fs: float, Sampling rate of the signal : BW: float, :
adaptive : {True, False}
low_bias : {True, False}
sides : str (optional) [ ‘default’ | ‘onesided’ | ‘twosided’ ]
|
---|---|
Returns : | (freqs, csd_est) : ndarrays
|
Returns an estimate of the PSD function of s using the multitaper method. If the NW product, or the BW and Fs in Hz are not specified by the user, a bandwidth of 4 times the fundamental frequency, corresponding to NW = 4 will be used.
Parameters : | s : ndarray
Fs: float :
BW: float :
adaptive : {True/False}
jackknife : {True/False}
low_bias : {True/False}
sides : str (optional) [ ‘default’ | ‘onesided’ | ‘twosided’ ]
|
---|---|
Returns : | (freqs, psd_est, var_or_nu) : ndarrays
|
Takes an N-point periodogram estimate of the PSD function. The number of points N, or a precomputed FFT Sk may be provided. By default, the PSD function returned is normalized so that the integral of the PSD is equal to the mean squared amplitude (mean energy) of s (see Notes).
Parameters : | s : ndarray
Fs: float (optional) :
Sk : ndarray (optional)
N : int (optional)
sides : str (optional) [ ‘default’ | ‘onesided’ | ‘twosided’ ]
PSD normalize : boolean (optional, default=True) Normalizes the PSD |
---|---|
Returns : | (f, psd): tuple :
|
Notes
setting dw = 2*PI/N, then the integral from -PI, PI (or 0,PI) of PSD/(2PI) will be nearly equal to sxx(0), where sxx is the autocovariance function of s(n). By definition, sxx(0) = E{s(n)s*(n)} ~ (s*s.conj()).mean()
Takes an N-point periodogram estimate of all the cross spectral density functions between rows of s.
The number of points N, or a precomputed FFT Sk may be provided. By default, the CSD function returned is normalized so that the integral of the PSD is equal to the mean squared amplitude (mean energy) of s (see Notes).
Returns : | freqs, csd_est : ndarrays
|
---|
Notes
setting dw = 2*PI/N, then the integral from -PI, PI (or 0,PI) of PSD/(2PI) will be nearly equal to sxy(0), where sxx is the crosscovariance function of s1(n), s2(n). By definition, sxy(0) = E{s1(n)s2*(n)} ~ (s1*s2.conj()).mean()