## 4 Analysis of Spectral Shift Demodulation Methods for Simulation Data
The root mean square error (RMSE) determined for \(M\) wavelength shifts of the simulated spectrum was used to evaluate the algorithms and methods of spectrum filtering and enhancement:  
\[RMSE=\sqrt{\frac{\sum_{m=1}^{M}(\Delta\lambda_{t}(m)-\Delta\lambda_{e}(m))^{2}}{M}}, \tag{23}\]  
where \(\Delta\lambda_{t}\) is the real value of the spectral shift, and \(\Delta\lambda_{e}\) is the wavelength shift calculated with the specified algorithm and preprocessing method. Figure 10 presents the characteristics of the dependence of the RMSE value on the SNR value for the FCP method and its modifications. The modifications consist of the initial processing of the spectrum by raising its value to the second power. The second proposed modification is the calculation of the FPC for the cross-correlation function. However, the most effective is the calculation of the shift using the FPC for the cross-correlation function raised to the second power (Figure 10). In the analysis of various types of measurement data, preliminary smoothing is often used. For data containing shapes in the form of various types of peaks, such as spectra in spectroscopy, Savitzky-Golay (SG) filters [35] cope very well with the smoothing task. They can perform filtration with the simultaneous lack or slight distortion of the spectrum, manifested as a decrease in the intensity of the peaks. The effect of using SG filters is shown in Figure 11. With the appropriate selection of the degree of the approximating polynomial, the effect of filtration is comparable to the application of the cross-correlation function before calculating the FPC. The calculations were performed for polynomial degrees from one to seven and different lengths of the filter impulse response. The most beneficial was the use of filters with a small approximating polynomial degree. This means significant smoothing and blurring (broadening) of the spectrum. Figure 11 shows graphs for two sample filters for which the filtration effect was the most beneficial. After filtering, the individual spectrum values should be raised to the second power. Numerical analysis was then performed on the spectra that were filtered nonlinearly using both geometric mean filters and the developed combination of mean arithmetic and geometric filters. Figure 12 presents the effect of nonlinear filtration on demodulation. Greater benefits were obtained using the combined arithmetic-geometric method. It was possible to obtain an RMSE level comparable to the use of preliminary cross-correlation. This effect was obtained for a filter operating range \(K=30\), which was equivalent to an impulse response length of the linear filter of 60. In each case, after filtering, the spectrum value should be raised to the second power. Figure 10: Effect of squared FBG spectrum on the RMSE value when demodulating the spectral shift using fast phase correlation and cross-correlation methods. The selection of the filter impulse response length, as in the case of any smoothing filtering, is made on the basis of multiple trials. Often, the result of smoothing filtering is assessed in terms of its visual effect. In the case of FBG spectra, the filter response length depends on the spectral resolution of the measurement and the half-width of the grid. For linear filters, the filter is selected through frequency analysis and cut-off frequency. For nonlinear filters, concepts such as the frequency response or transmittance cannot be used. Therefore, specific input data sequences must be analysed, and, based on them, conclusions about the filtration properties can be drawn. For the analysed spectra, we were interested in the effect of filters on reducing the RMSE of wavelength demodulation methods. Therefore, the visual effects of filtration presented in Figures 1-8 do not necessarily translate directly into an improvement in the quality of spectra demodulation. The cross-correlation method itself is a method that reduces noise. The fast phase correlation method is also relatively resistant to the noise content of data.