skdh.utility.windowing.compute_window_samples#
- skdh.utility.windowing.compute_window_samples(fs, window_length, window_step)#
Compute the number of samples for a window. Takes the sampling frequency, window length, and window step in common representations and converts them into number of samples.
- Parameters:
- fsfloat
Sampling frequency in Hz.
- window_lengthfloat
Window length in seconds. If not provided (None), will do no windowing. Default is None
- window_step{float, int}
Window step - the spacing between the start of windows. This can be specified several different ways (see Notes). Default is 1.0
- Returns:
- length_nint
Window length in samples
- step_nint
Window step in samples
- Raises:
- ValueError
If window_step is negative, or if window_step is a float not in (0.0, 1.0]
Notes
Computation of the window step depends on the type of input provided, and the range. - window_step is a float in (0.0, 1.0]: specifies the fraction of a window to skip to get to the start of the next window - window_step is an integer > 1: specifies the number of samples to skip to get to the start of the next window
Examples
Compute the window length and step in samples for a 3s window with 50% overlap, with a sampling rate of 50Hz
>>> compute_window_samples(50.0, 3.0, 0.5) (150, 75)
Compute the window length for a 4.5s window with a step of 1 sample, and a sampling rate of 100Hz
>>> compute_window_samples(100.0, 4.5, 1) (450, 1)