## 2 Principles of Improved Harmonic Detection Methods
### Bartlett-Hann Algorithm Principle  
At present, research on harmonic detection methods based on discrete Fourier transform is mainly focused on finding window functions for fast decay of side lobes, and interpolation algorithms with higher performance. The Bartlett window is very similar to a triangular window as returned by the triang function--both are convolutions of two rectangles. However, the Bartlett window always has zeros at the first and last samples, while the triangular window is nonzero at those points. For odd values of n, the center n-2 points of Bartlett (n) are equivalent to triang (n-2) [16]. The formula for  
Figure 1: Three-layer wavelet decomposition reconstruction diagram.  
the triangular window is shown in Equation (2), and the formula for the Bartlett window is shown in Equation (3).  
\[\begin{array}{l}\textit{n is an odd number}:\\ \textit{w}(k)=\left\{\begin{array}{ll}\frac{2k}{n+1}&1\leq k\leq\frac{n+1}{2} \\ \frac{2(n-k+1)}{n+1}&\frac{n+1}{2}\leq k\leq n\end{array}\right\}&\textit{w}(k)= \left\{\begin{array}{ll}\frac{2k-1}{n}&1\leq k\leq\frac{n}{2}\\ \frac{2(n-k+1)}{n}&\frac{n}{2}\leq k\leq n\end{array}\right\}\\ \textit{n is an odd number}:\\ \textit{w}(k)=\left\{\begin{array}{ll}\frac{2(k-1)}{n-1}&1\leq k\leq\frac{n +1}{2}\\ 2-\frac{2(k-1)}{n-1}&\frac{n+1}{2}\leq k\leq n\end{array}\right\}&\textit{w}(k) =\left\{\begin{array}{ll}\frac{2(k-1)}{n-1}&1\leq k\leq\frac{n+1}{2}\\ \frac{2(n-k)}{n-1}&\frac{n}{2}\leq k\leq n\end{array}\right\}\\ \end{array}\right\}\end{array} \tag{2}\]  
The Bartlett-Hann window is like the [PERSON], Hanning, and Hamming windows. This window has a main lobe at the origin and side edges that are gradually decaying on both sides. In fact, it is a linear combination of weighted Bartlett and Hanning windows [13,17]. Its near side lobes are lower than the Bartlett and Hanning windows, and its far side lobes are lower than the Bartlett and Hamming windows. Bartlett-Hann windows do not increase the width of the main lobe of the window compared to Bartlett or Hanning windows. According to reference [17], the time-domain expression used to calculate the Bartlett-Hann window is shown in Equation (4):  
\[x(n)=0.62-0.48\big{|}(\frac{n}{N}-0.5)\big{|}+0.38\cos(2\pi(\frac{n}{N}-0.5)) \tag{4}\]  
where \(0\leq n\leq N\), the length of the window is \(L=N+1\). Its frequency domain expression is as shown in Equation (5):  
\[X(\mathrm{e}^{\mathrm{i}\omega})=\{0.24X_{\mathrm{b}}(\omega)+0.38X_{\mathrm{ R}}(\omega)+0.19X_{\mathrm{R}}(\omega-\frac{2\pi}{N})+0.19X_{\mathrm{R}}( \omega+\frac{2\pi}{N})\mathrm{e}^{-\mathrm{i}(\frac{N-1}{2})\omega} \tag{5}\]  
where \(X_{\mathrm{b}}(\omega)\) is the spectrum of the Bartlett window, and its expression is as shown in Equation (6):  
\[X_{b}(\omega)=\frac{2}{N}\bigg{[}\frac{\sin(\frac{N\omega}{4})}{\sin(\frac{ \omega}{2})}\bigg{]}^{2} \tag{6}\]  
\(X_{\mathrm{R}}(\omega)\) is the spectrum of a rectangular window, and its expression is as shown in Equation (7):  
\[X_{R}(\omega)=\frac{\sin(\frac{N\omega}{2})}{\sin(\frac{\omega}{2})} \tag{7}\]  
Compared with other windows, considering its main lobe width and side lobe attenuation speed, it is suitable for the window interpolation DFT algorithm, has better characteristics of suppressing spectral leakage, can reduce interference between harmonics, and improves the accuracy of signal analysis degree.