scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParameters
_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)

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.

Notes

Adapted from matplotlib.mlab

versionadded

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 :None:None:`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 :None:None:`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:None:`None`, noverlap = nperseg // 2 . Defaults to :None:None:`None`.

nfft : int, optional

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

detrend : str or function or `False`, optional

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

return_onesided : bool, optional

If :None:None:`True`, return a one-sided spectrum for real data. If :None:None:`False` return a two-sided spectrum. Defaults to :None:None:`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 :None:None:`Pxy` has units of V**2/Hz and computing the cross spectrum ('spectrum') where :None:None:`Pxy` has units of V**2, if x and y are measured in V and :None:None:`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:None:`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 :None:None:`False`. Padding occurs after boundary extension, if boundary is not :None:None:`None`, and :None:None:`padded` is :None:None:`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.

Calculate various forms of windowed FFTs for PSD, CSD, etc.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/signal/_spectral_py.py#1579
type: <class 'function'>
Commit: