FFT Analysis¶
This example illustrates how to perform spectral analysis on a quaternionic signal using qsp-fft.
Note
This is a conceptual example. Code snippets are illustrative. Verify against the current package API before use.
Overview¶
Classical FFT analysis computes the frequency content of a real or complex-valued signal. qsp-fft extends this to quaternionic inputs, allowing spectral analysis of signals that carry multi-axis or geometric information.
Scenario¶
You have a quaternionic signal from a multi-axis sensor and want to analyze its frequency content to identify dominant components before applying a filter.
Example¶
# Conceptual example — not a tested API call
import qsp_core
import qsp_fft
import numpy as np
# Load or construct a quaternionic signal
# Shape: (N, 4) array of [w, x, y, z] components
raw = np.load("sensor_data.npy")
signal = qsp_core.QuaternionSignal(raw, sample_rate_hz=500.0)
# Compute the quaternionic FFT
spectrum = qsp_fft.transform(signal)
# Inspect frequency bins
freqs = qsp_fft.frequencies(signal)
magnitudes = qsp_fft.magnitude(spectrum)
# Find the dominant frequency component
dominant_idx = np.argmax(magnitudes)
dominant_freq = freqs[dominant_idx]
print(f"Dominant frequency: {dominant_freq:.2f} Hz")
Visualizing the spectrum¶
# Conceptual — use your preferred plotting library
import matplotlib.pyplot as plt
plt.plot(freqs, magnitudes)
plt.xlabel("Frequency (Hz)")
plt.ylabel("Magnitude")
plt.title("Quaternionic Signal Spectrum")
plt.grid(True)
plt.show()
Notes¶
- The
transformfunction operates on the full quaternionic signal; individual component transforms are also available. - Zero-padding and windowing can be applied before the transform — consult the
qsp-fftAPI for options. - Negative frequency components have specific meaning in the quaternionic case; refer to the concepts documentation for context.