FFT

class gpype.backend.transform.fft.FFT[source]

Bases: IONode

Fast Fourier Transform node for frequency domain analysis.

Performs windowed FFT on input data with configurable window size, overlap, and window functions. Uses rolling buffer for continuous processing and proper amplitude scaling for spectral analysis.

A channel’s unit is unchanged: the output is a one-sided amplitude spectrum, in the same unit as the input signal, not a power spectral density, so no unit conversion applies (D-BATCH-43).

DEFAULT_WINDOW_FUNCTION = 'boxcar'

Applied when the author does not choose. Declared rather than left as a literal in the constructor body, so the catalog can publish it without building an FFT to find out.

DEFAULT_OVERLAP = 0.5
class Configuration[source]

Bases: Configuration

Configuration class for FFT parameters.

class Keys[source]

Bases: Keys

Configuration key constants for the FFT.

WINDOW_SIZE = 'window_size'

Window size configuration key

WINDOW_FUNCTION = 'window_function'

Window function configuration key

OVERLAP = 'overlap'

Overlap configuration key

FRAME_SIZE = 'frame_size'

Buffer length, defaulting to the window size. Accepted through kwargs and stored, so it is declared here rather than travelling in the configuration undocumented.

__init__(window_size, window_function=None, overlap=None, **kwargs)[source]

Initialize FFT transform node.

Parameters:
  • window_size (int) – Size of the FFT window in samples. Must be > 1.

  • window_function (str) – Name of the window function to apply. Defaults to ‘boxcar’ (rectangular window).

  • overlap (float) – Overlap ratio between consecutive windows, ranging from 0.0 to 1.0. Defaults to 0.5.

  • **kwargs – Additional configuration parameters passed to IONode.

Raises:
  • ValueError – If window_size is None, not an integer, or <= 1.

  • ValueError – If overlap is not a float or outside [0, 1] range.

setup(data, port_context_in)[source]

Set up the FFT node and initialize windowing components.

Parameters:
  • data (dict[str, ndarray]) – Initial data dictionary for port configuration.

  • port_context_in (dict[str, dict]) – Input port context information.

Returns:

Output port context with updated frame size for FFT output.

Return type:

dict[str, dict]

Raises:

ValueError – If input frame size is not 1.

step(data)[source]

Process one frame of data and compute FFT when ready.

Parameters:

data (dict[str, ndarray]) – Dictionary containing input data arrays with shape (1, channel_count) for each frame.

Returns:

Dictionary containing FFT amplitude spectrum when

decimation step is reached, None otherwise. Output shape is (frequency_bins, channel_count) where frequency_bins is (window_size // 2 + 1).

Return type:

dict[str, ndarray]