-
Notifications
You must be signed in to change notification settings - Fork 0
Digital Signal Processing
Sofia Engine's signal processing architecture (sofia_ai.signal and sofia_ai.features) is built on rigorous digital signal processing theory. All functions are pure, deterministic, and implemented in pure NumPy with zero external framework overhead.
Given a discrete time-series window
-
Mean (
$\bar{x}$ ):$$\bar{x} = \frac{1}{N} \sum_{n=0}^{N-1} x_n$$ -
Root Mean Square (RMS) (reflects overall vibration energy per ISO 10816):
$$\text{RMS}(\mathbf{x}) = \sqrt{\frac{1}{N} \sum_{n=0}^{N-1} x_n^2}$$ -
Peak (
$x_{pk}$ ) & Peak-to-Peak ($x_{p2p}$ ):$$x_{pk} = \max_{n} |x_n|, \quad x_{p2p} = \max_{n}(x_n) - \min_{n}(x_n)$$ -
Sample Variance (
$\sigma^2$ ) & Standard Deviation ($\sigma$ ):$$\sigma^2 = \frac{1}{N-1}\sum_{n=0}^{N-1}(x_n - \bar{x})^2, \quad \sigma = \sqrt{\sigma^2}$$
-
Sample Skewness (
$S$ ) (asymmetry of probability distribution):$$S = \frac{\frac{1}{N}\sum_{n=0}^{N-1}(x_n - \bar{x})^3}{\left(\frac{1}{N}\sum_{n=0}^{N-1}(x_n - \bar{x})^2\right)^{3/2}}$$ -
Sample Kurtosis (
$K$ ) (peakedness and heavy tails, sensitive to early bearing spalls):$$K = \frac{\frac{1}{N}\sum_{n=0}^{N-1}(x_n - \bar{x})^4}{\left(\frac{1}{N}\sum_{n=0}^{N-1}(x_n - \bar{x})^2\right)^2}$$
-
Crest Factor (
$CF$ ):$$CF = \frac{x_{pk}}{\text{RMS}(\mathbf{x})}$$ A healthy rotating machine exhibits$CF \approx 3.0 \text{ to } 3.5$ . Repetitive impacts from bearing rolling element impacts cause$CF > 5.0$ . -
Shape Factor (
$SF$ ):$$SF = \frac{\text{RMS}(\mathbf{x})}{\frac{1}{N}\sum_{n=0}^{N-1}|x_n|}$$ -
Impulse Factor (
$IF$ ):$$IF = \frac{x_{pk}}{\frac{1}{N}\sum_{n=0}^{N-1}|x_n|}$$ -
Margin Factor (
$MF$ ):$$MF = \frac{x_{pk}}{\left(\frac{1}{N}\sum_{n=0}^{N-1}\sqrt{|x_n|}\right)^2}$$ -
Zero Crossing Rate (
$ZCR$ ):$$ZCR = \frac{1}{N-1} \sum_{n=1}^{N-1} \mathbb{I}\left(x_n \cdot x_{n-1} < 0\right)$$
The discrete spectrum of the windowed signal is:
Where
Sofia Engine guarantees strict energy conservation across time and frequency representations:
When computing the one-sided Power Spectral Density (PSD)
- The DC component (
$k=0$ ) and Nyquist frequency ($k=N/2$ ) are retained without scaling. - Positive frequencies (
$0 < k < N/2$ ) are doubled ($2 \cdot |X_k|^2$ ) to preserve total power. - Coherent gain factor
$S_1 = \sum w_n$ and noise equivalent bandwidth factor$S_2 = \sum w_n^2$ are applied.
-
Spectral Centroid (
$f_c$ ) (center of spectral mass):$$f_c = \frac{\sum_{k=0}^{M-1} f_k P(f_k)}{\sum_{k=0}^{M-1} P(f_k)}$$ -
Spectral Spread (
$\sigma_f$ ) (spectral bandwidth around the centroid):$$\sigma_f = \sqrt{\frac{\sum_{k=0}^{M-1}(f_k - f_c)^2 P(f_k)}{\sum_{k=0}^{M-1} P(f_k)}}$$ -
Spectral Flatness (Wiener Entropy):
$$\gamma_\infty = \frac{\exp\left(\frac{1}{M}\sum_{k=0}^{M-1} \ln P(f_k)\right)}{\frac{1}{M}\sum_{k=0}^{M-1} P(f_k)}$$ $\gamma_\infty \to 0$ indicates a pure tone / harmonic peak;$\gamma_\infty \to 1$ represents uniform white noise. -
Band Energy (
$E_{[f_{low}, f_{high}]}$ ):$$E_{[f_{low}, f_{high}]} = \sum_{k: f_{low} \le f_k \le f_{high}} P(f_k) \Delta f$$
Bearing defect impacts produce structural resonances modulated at fault characteristic frequencies. Sofia computes the analytic signal
Where the Hilbert transform
In the frequency domain:
The demodulated instantaneous envelope is extracted as:
The spectrum of
For assets rotating at shaft speed
+-------------------------------+
| BEARING GEOMETRY |
| Nb = Number of rollers |
| d = Roller diameter |
| D = Pitch diameter |
| α = Contact angle |
+-------------------------------+
|
+--------------------+-------+--------------------+
| | |
v v v
Outer Race (BPFO) Inner Race (BPFI) Ball Spin (BSF)
-
Ball Pass Frequency Outer Race (BPFO):
$$\text{BPFO} = \frac{N_b}{2} f_r \left(1 - \frac{d}{D} \cos \alpha\right)$$ -
Ball Pass Frequency Inner Race (BPFI):
$$\text{BPFI} = \frac{N_b}{2} f_r \left(1 + \frac{d}{D} \cos \alpha\right)$$ -
Ball Spin Frequency (BSF):
$$\text{BSF} = \frac{D}{2d} f_r \left[1 - \left(\frac{d}{D}\cos \alpha\right)^2\right]$$ -
Fundamental Train Frequency (FTF / Cage):
$$\text{FTF} = \frac{1}{2} f_r \left(1 - \frac{d}{D}\cos \alpha\right)$$
-
Gear Mesh Frequency (GMF):
$$\text{GMF} = N_{teeth} \cdot f_r$$ -
Sideband Modulation: Faults on gear teeth manifest as sidebands spaced at running speed multiples:
$$f_{sideband} = \text{GMF} \pm k \cdot f_r, \quad k \in {1, 2, 3, \dots}$$
- Butterworth IIR Filtering: Implemented as second-order section (SOS) cascades to maintain numerical stability on low-precision floating point.
- Moving Average & Median Filters: Constant-memory rolling smoothing for transient artifact suppression.
-
Linear & Constant Detrending: Removes DC bias and baseline wander before FFT computation:
$$x_{detrended}[n] = x[n] - (\hat{a} \cdot n + \hat{b})$$ - Resampling: Decimation and band-limited linear interpolation supporting fractional rate conversion.