bundles / scipy 1.18.0 / scipy / signal / _short_time_fft / ShortTimeFFT / nearest_k_p
function
scipy.signal._short_time_fft:ShortTimeFFT.nearest_k_p
Signature
def nearest_k_p(self, k: int, left: bool = True) → intSummary
Return nearest sample index k_p for which t[k_p] == t[p] holds.
Extended Summary
The nearest next smaller time sample p (where t[p] is the center position of the window of the p-th slice) is p_k = k // hop. If hop is a divisor of k then k is returned. If left is set then p_k * hop is returned else (p_k+1) * hop.
This method can be used to slice an input signal into chunks for calculating the STFT and iSTFT incrementally.
Parameters
k: intSample index for which the nearest slice center index is sought.
left: bool, optionalIf
Truethen the nearest smaller index is returned, else the nearest larger index is returned. Defaults toTrue.
Returns
: intNearest sample index k_p for which
t[k_p] == t[p]holds.
See also
- ShortTimeFFT
Class this method belongs to.
- T
Sampling interval of input signal and of the window (
1/fs).- delta_t
Time increment of STFT (
hop*T)- fs
Sampling frequency (being
1/T)- hop
Time increment in signal samples for sliding window.
- t
Times of STFT for an input signal with
nsamples.
Aliases
scipy.signal.ShortTimeFFT.nearest_k_p