bundles / scipy latest / scipy / signal / _spectral_py / _spectral_helper
function
scipy.signal._spectral_py:_spectral_helper
Signature
def _spectral_helper ( x , y , fs = 1.0 , window = hann , nperseg = None , noverlap = None , nfft = None , detrend = constant , return_onesided = True , scaling = density , axis = -1 , mode = psd , boundary = None , padded = False ) Summary
Calculate various forms of windowed FFTs for PSD, CSD, etc.
Extended Summary
This is a helper function that implements the commonality between the stft, psd, csd, and spectrogram functions. It is not designed to be called externally. The windows are not averaged over; the result from each window is returned.
Parameters
x: array_likeArray or sequence containing the data to be analyzed.
y: array_likeArray or sequence containing the data to be analyzed. If this is the same object in memory as
x(i.e._spectral_helper(x, x, ...)), the extra computations are spared.fs: float, optionalSampling frequency of the time series. Defaults to 1.0.
window: str or tuple or array_like, optionalDesired window to use. If
windowis a string or tuple, it is passed to get_window to generate the window values, which are DFT-even by default. See get_window for a list of windows and required parameters. Ifwindowis array_like it will be used directly as the window and its length must be nperseg. Defaults to a Hann window.nperseg: int, optionalLength of each segment. Defaults to None, but if window is str or tuple, is set to 256, and if window is array_like, is set to the length of the window.
noverlap: int, optionalNumber of points to overlap between segments. If
None,noverlap = nperseg // 2. Defaults toNone.nfft: int, optionalLength of the FFT used, if a zero padded FFT is desired. If
None, the FFT length isnperseg. Defaults toNone.detrend: str or function or `False`, optionalSpecifies how to detrend each segment. If
detrendis a string, it is passed as thetypeargument to thedetrendfunction. If it is a function, it takes a segment and returns a detrended segment. IfdetrendisFalse, no detrending is done. Defaults to 'constant'.return_onesided: bool, optionalIf
True, return a one-sided spectrum for real data. IfFalsereturn a two-sided spectrum. Defaults toTrue, but for complex data, a two-sided spectrum is always returned.scaling: { 'density', 'spectrum' }, optionalSelects between computing the cross spectral density ('density') where
Pxyhas units of V²/Hz and computing the cross spectrum ('spectrum') wherePxyhas units of V², ifxandyare measured in V andfsis measured in Hz. Defaults to 'density'axis: int, optionalAxis along which the FFTs are computed; the default is over the last axis (i.e.
axis=-1).mode: str {'psd', 'stft'}, optionalDefines what kind of return values are expected. Defaults to 'psd'.
boundary: str or None, optionalSpecifies whether the input signal is extended at both ends, and how to generate the new values, in order to center the first windowed segment on the first input point. This has the benefit of enabling reconstruction of the first input point when the employed window function starts at zero. Valid options are
['even', 'odd', 'constant', 'zeros', None]. Defaults toNone.padded: bool, optionalSpecifies whether the input signal is zero-padded at the end to make the signal fit exactly into an integer number of window segments, so that all of the signal is included in the output. Defaults to
False. Padding occurs after boundary extension, ifboundaryis notNone, andpaddedisTrue.
Returns
freqs: ndarrayArray of sample frequencies.
t: ndarrayArray of times corresponding to each data segment
result: ndarrayArray of output data, contents dependent on mode kwarg.
Notes
Adapted from matplotlib.mlab
Aliases
-
scipy.signal._spectral_py._spectral_helper