stft#
- ShortTimeFFT.stft(x, p0=None, p1=None, *, k_offset=0, padding='zeros', axis=-1)[source]#
Perform the short-time Fourier transform.
A two-dimensional matrix with
p1-p0columns is calculated. Thef_ptsrows represent value at the frequenciesf. The q-th column of the windowed FFT with the windowwinis centered at t[q]. The columns represent the values at the frequenciesf.- Parameters:
- xnp.ndarray
The input signal as real or complex valued array. For complex values, the property
fft_modemust be set to ‘twosided’ or ‘centered’.- p0int | None
The first element of the range of slices to calculate. If
Nonethen it is set top_min, which is the smallest possible slice.- p1int | None
The end of the array. If
Nonethen p_max(n) is used.- k_offsetint
Index of first sample (t = 0) in x.
- padding‘zeros’ | ‘edge’ | ‘even’ | ‘odd’
Kind of values which are added, when the sliding window sticks out on either the lower or upper end of the input x. Zeros are added if the default ‘zeros’ is set. For ‘edge’ either the first or the last value of x is used. ‘even’ pads by reflecting the signal on the first or last sample and ‘odd’ additionally multiplies it with -1.
- axisint
The axis of x over which to compute the STFT. If not given, the last axis is used.
- Returns:
- Snp.ndarray
A complex array is returned with the dimension always being larger by one than of x. The last axis always represents the time slices of the STFT. axis defines the frequency axis (default second to last). E.g., for a one-dimensional x, a complex 2d array is returned, with axis 0 representing frequency and axis 1 the time slices.
See also
delta_fWidth of the frequency bins of the STFT.
delta_tTime increment of STFT
fFrequencies values of the STFT.
invertibleCheck if STFT is invertible.
istftInverse short-time Fourier transform.
p_rangeDetermine and validate slice index range.
stft_detrendSTFT with detrended segments.
tTimes of STFT for an input signal with n samples.
scipy.signal.ShortTimeFFTClass this method belongs to.