ertk.utils.frame_array
- ertk.utils.frame_array(x: ndarray, frame_size: int, frame_shift: int, pad: bool = False, axis: int = 0, copy: bool = True) ndarray
Frames an array over a given axis with optional padding and copying.
- Parameters:
- x: np.ndarray
Array to frame.
- frame_size: int
Width of frame.
- frame_shift: int
Amount each window is moved for subsequent frames.
- pad: bool
If the frames don’t neatly fit the axis length, this indicated whether to pad or cut the remaining length. Default is
Falsewhich means any remaining length is cut. Ifpad=Truethen any remaining length is padded with zeros and an additional frame is produced. If frames neatly fit into the axis length then this option has no effect.- axis: int
Axis to frame over. Default is 0.
- copy: bool
Whether to copy and return a contiguous array (more memory usage). Default is
Trueso that a contiguous copy is retured. Note: ifcopy=Falseit is assumed that the input array is contiguous so that a view with modified strides can be properly created.
- Returns:
- frames: np.ndarray
The resulting frames. If
copy=Falsethen these are read-only views into x, otherwise a contiguous array is returned.