{ } Raw JSON

bundles / scipy latest / scipy / signal / _spectral_py / _spectral_helper

function

scipy.signal._spectral_py:_spectral_helper

source: /scipy/signal/_spectral_py.py :2046

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_like

Array or sequence containing the data to be analyzed.

y : array_like

Array 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, optional

Sampling frequency of the time series. Defaults to 1.0.

window : str or tuple or array_like, optional

Desired window to use. If window is 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. If window is array_like it will be used directly as the window and its length must be nperseg. Defaults to a Hann window.

nperseg : int, optional

Length 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, optional

Number of points to overlap between segments. If None, noverlap = nperseg // 2. Defaults to None.

nfft : int, optional

Length of the FFT used, if a zero padded FFT is desired. If None, the FFT length is nperseg. Defaults to None.

detrend : str or function or `False`, optional

Specifies how to detrend each segment. If detrend is a string, it is passed as the type argument to the detrend function. If it is a function, it takes a segment and returns a detrended segment. If detrend is False, no detrending is done. Defaults to 'constant'.

return_onesided : bool, optional

If True, return a one-sided spectrum for real data. If False return a two-sided spectrum. Defaults to True, but for complex data, a two-sided spectrum is always returned.

scaling : { 'density', 'spectrum' }, optional

Selects between computing the cross spectral density ('density') where Pxy has units of V²/Hz and computing the cross spectrum ('spectrum') where Pxy has units of V², if x and y are measured in V and fs is measured in Hz. Defaults to 'density'

axis : int, optional

Axis along which the FFTs are computed; the default is over the last axis (i.e. axis=-1).

mode: str {'psd', 'stft'}, optional

Defines what kind of return values are expected. Defaults to 'psd'.

boundary : str or None, optional

Specifies 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 to None.

padded : bool, optional

Specifies 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, if boundary is not None, and padded is True.

Returns

freqs : ndarray

Array of sample frequencies.

t : ndarray

Array of times corresponding to each data segment

result : ndarray

Array of output data, contents dependent on mode kwarg.

Notes

Adapted from matplotlib.mlab

Aliases

  • scipy.signal._spectral_py._spectral_helper