bundles / scipy 1.17.1 / scipy / signal / _short_time_fft / ShortTimeFFT / stft_detrend
function
scipy.signal._short_time_fft:ShortTimeFFT.stft_detrend
Signature
def stft_detrend ( self , x : np.ndarray , detr : Callable[[np.ndarray], np.ndarray] | Literal['linear', 'constant'] | None , p0 : int | None = None , p1 : int | None = None , * , k_offset : int = 0 , padding : PAD_TYPE = zeros , axis : int = -1 ) → np.ndarray Summary
Calculate short-time Fourier transform with a trend being subtracted from each segment beforehand.
Extended Summary
When the parameter detr is None, this method's behavior is identical to the ~ShortTimeFFT.stft method. Note that due to the detrending, the original signal cannot be reconstructed by the ~ShortTimeFFT.istft.
Parameters
x: np.ndarrayThe input signal as real or complex valued array. For complex values, the property
fft_modemust be set to 'twosided' or 'centered'.detr: 'linear' | 'constant' | Callable[[np.ndarray], np.ndarray] | NoneIf 'constant', the mean is subtracted, if set to "linear", the linear trend is removed from each segment. This is achieved by calling detrend. If
detris a function with one parameter,detris applied to each segment.p0: int | NoneThe first element of the range of slices to calculate. If
Nonethen it is set top_min, which is the smallest possible slice.p1: int | NoneThe end of the array. If
Nonethenp_max(n)is used.k_offset: intIndex 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 ofxis used. 'even' pads by reflecting the signal on the first or last sample and 'odd' additionally multiplies it with -1.axis: intThe axis of
xover which to compute the STFT. If not given, the last axis is used.
Returns
S: np.ndarrayA 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.axisdefines the frequency axis (default second to last). E.g., for a one-dimensionalx, a complex 2d array is returned, with axis 0 representing frequency and axis 1 the time slices.
See also
- invertible
Check if STFT is invertible.
- scipy.signal.ShortTimeFFT
Class this method belongs to.
- ~ShortTimeFFT.istft
Inverse short-time Fourier transform.
- ~ShortTimeFFT.stft
Short-time Fourier transform (without detrending).
Aliases
-
scipy.signal.ShortTimeFFT.stft_detrend