Denoising and Trend Terms Elimination Algorithm of Accelerometer Signals

Acceleration-based displacement measurement approach is often used to measure the polish rod displacement in the oilfield pumping well. Random noises and trend terms of the accelerometer signals are the main factors that affect the measuring accuracy. In this paper, an efficient online learning algorithm is proposed to improve the measurement precision of polish rod displacement in the oilfield pumping well. To remove the random noises and eliminate the trend term of accelerometer signals, the ARIMA model and its parameters are firstly derived by using the obtained data of time series of acceleration sensor signals. Secondly, the period of the accelerometer signals is estimated through the Rife-Jane frequency estimation approach based on Fast Fourier Transform.With the obtainedmodel and parameters, the randomnoises are removed by employing the Kalman filtering algorithm. The quadratic integration of the period is calculated to obtain the polish rod displacement. Moreover, the windowed recursive least squares algorithm is implemented to eliminate the trend terms. The simulation results demonstrate that the proposed online learning algorithm is able to remove the random noises and trend terms effectively and greatly improves themeasurement accuracy of the displacement.


Introduction
Indicator diagram is an important method to analyze the operating state of the oilfield pumping unit and sucker rod [1,2].The vertical motion displacement of polish rod in oil well is an essential part of the indicator diagram.However, the acceleration sensor signals are always mixed with various noises which are mostly composed of random noises and trend terms [2][3][4].The random noises and trend terms errors induce huge integral signal waveform distortion which will greatly reduce the measurement accuracy of the indicator diagram displacement [3,5].Improving the measurement accuracy of the indicator diagram displacement is a key problem to be solved.
To solve the problem mentioned above, the morphological filtering algorithm was proposed by Li et al. [6] while a moving average filter algorithm was used by Guo et al. [7,8] to remove the noises of the acceleration sensor signals.Unfortunately, the performance of the morphological filtering algorithm is closely related to its structural elements and the algorithm is complex which impedes its practical engineering application.Although the moving average filter algorithm is simple and easy to use, the result of noise reduction is poor and the measurement accuracy of displacement measurement are unsatisfactory.In order to eliminate the trend term of the acceleration sensor signal, the commonly used method is firstly using least squares algorithm to fit the trend term dynamically and then using some techniques to remove it [5][6][7][8][9].In general, these techniques are batch process methods which are not suitable for real-time application.Therefore, a real-time online learning-based noise deduction and trend term rejection method is proposed in this work.Firstly, the actual online measurement acceleration sensor signal is analyzed based on online learning method to obtain the autoregressive moving average model (ARMA) and its parameters [8,10].Then, the accelerometer signal cycle can be obtained by using the Fast Fourier Transform Rife-Jane frequency estimation method.Secondly, the Kalman filtering techniques are used to eliminate the online measured acceleration signal random noise based on the state-space model parameters from the online learning method result.And then the polish rod displacement can be 2 Mathematical Problems in Engineering obtained through quadratic integration.The trend items can be online eliminated in real-time by use of the windowed recursive least squares method.
The structure of this paper is organized as follows.Section 2 introduces the acquisition method of the test signal model based on online learning.In Section 3, the real-time theoretical approaches of removing noise and trend terms of the acceleration sensor signals are presented.Section 4 presents the simulation and experimental results of the measured acceleration signal to validate the effectiveness of the algorithm.Section 5 draws the conclusions.

The Test Signal Model Based on Learning Method
In this section, the time series modeling methods of the test signal as well as the Rife-Jane frequency estimation method of the time series model are presented.The frequency estimation method is based on the Fast Fourier Transform.The test signal model and its parameters can be obtained with the help of the two methods.

Time Series
Modeling of the Test Signal.Time series analysis method [11][12][13] is a kind of modern statistical analysis method.The analysis method uses the parametric models to analyze and deal with the observed sequential random signal series.The contents of the time series model include acquisition, statistical analysis (stationary test and correlation analysis), the parametric pretreatment, model selection, model order determination, model coefficients estimation, and the feasibility validation of the model.Among the above contents, the determination of the model order, the estimation of the model coefficients, and the feasibility validation of the model are critical to the time series model.ARMA can be expressed as follows: where () is a random signal time series.() is a white noise sequence, and  is the model order of autoregressive (AR) model. is the model order of moving average (MA) model.  stands for the aggression coefficient of the AR model.  is the moving average coefficient. − is the delay operator.
When  = 0, the ARMA model (formula ( 1)) degenerates into the AR model.And the AR model can be expressed as When  = 0, ARMA model (formula (1)) degenerates into the MA model.And the AR model can be expressed as Obviously, the AR model and MA model can be seen as a special case of the ARMA model.The differences among the three models are the respective characteristics of the model autocorrelation and partial autocorrelation function.AR model has a tailing autocorrelation function and a truncated partial autocorrelation function.MR model has a truncated autocorrelation function and a tailing partial autocorrelation function.The autocorrelation function and the partial autocorrelation function of AMMR model are both tailing.Suppose a stationary time series is drawn; the model type can be determined by the tailing and truncated features of the autocorrelation and partial autocorrelation function.And the model order can be determined based on the AIC criteria.
AIC criteria consider both the interaction between the order and the residual of the model and the effect of the test data series length in the model which provides high accuracy for the estimation.AIC criteria are defined as follows: where   is the variance of the fitting residual error. and  denote, respectively, the orders of the autoregressive model and the moving average model. is the sample size.
According to the value of , , the AIC value was calculated and the ,  which lead to the minimum AIC value are selected as the order of the model.Once the model order is determined, the model coefficients can be estimated by using the least squares method [8,10,14].
The signal time series model according to given time series can be established by using the modeling method.The model can objectively describe the system characteristics.And the model parameter can also be determined.

Rife-Jane Frequency Estimation Method.
The signal frequency can be obtained by use of Fast Fourier Transform (FFT).And the frequency accuracy is affected by the frequency resolution of FFT.If the signal frequency is not the integral multiple of the FFT frequency resolution, the barrier effects of the FFT will cause the spectral leakage, which will decrease the accuracy of the frequency estimation.Rife-Jane frequency estimation method can make up this defect [15][16][17].The Rife-Jane frequency calculation procedure is as follows.
Let () be the -point FFT of the series ().In view of the symmetry of the real FFT sequences, only /2 points of the discrete spectrum should be considered.Then, (5) can be obtained: ( The index values of the discrete frequencies at the maximum amplitude of series () can be denoted as .The signal frequency can be estimated with ,   = Δ.And Δ =   / is the FFT frequency resolution, that is, the interval between adjacent spectral lines.When the signal frequency is not exactly an integer multiple of Δ, the actual frequency lies in the FFT main lobe lines between two maximum spectral lines.The maximum spectral line amplitude can be denoted as  1 = (), and the second largest can be denoted as According to  =  2 / 1 , the relative error of the actual frequency and coarse frequency can be obtained: The symbol of formula ( 6) is based on the left side or right side of the second largest spectral amplitude compared to maximum spectral amplitude.The signal actual frequency can be estimated with this method.

Real-Time Elimination Method of the Noise and Trend Terms
In this section, the basic principles of Kalman filtering are described.The method of transforming from ARMA model to the state-space model is proposed.Moreover, the recursive least squares trend terms removal method is discussed.

Basic Principles of Kalman
Filtering.Kalman filtering principle uses the state-space model consisting of the state and observation equations to describe and study the system [18][19][20].And the principle uses the recursive characteristics of the system state equations to make the best estimate of the system state by use of the recursive algorithm according to the linear unbiased minimum mean square error estimation criteria.It is suitable for online real-time estimation and analysis of the system state for a small amount of computation and storage requirement.However, Kalman filter must be used based on the reasonable state-space model of the studied system to make the best result.So the state-space model must be built strictly based on the specific research system and the specific research aim (such as time variant characteristics or time invariant characteristics).According to the specific state-space model, three recursive filter formulas can be selected.The recursive filter formulas are Kalman filter, Kalman predictor, and Kalman smoother.In this paper, the Kalman filter is selected as the estimation model of the system state.
Let the system state   at time  be driven by the system noise sequence,   .And the driving mechanism can be described as the state equation And the measurement of   has linear characteristics.The measurement equation of   is where Φ /−1 is the transition matrix from time −1 to time .Γ  is the system noise driven matrix.  is the measurement matrix.  is the system measurement noise sequence.  is the system noise incentives sequences.At the same time,   and   should meet the following constraints: where   is the variance matrix of system noise series, which is a nonnegative matrix.  is the variance matrix of the system measurement noise series, which is a negative matrix.By theorem [9], it is assumed that the estimation   of the system state satisfies (7).  is the measuring amount of   which satisfies (8).The system noises matrix   and system measurement noises matrix   satisfy (9).The system noise variance matrix   is a nonnegative matrix.The system measurement noise variance matrix is a negative matrix.And the measuring amount at  time is   .The estimation of   is X .X can be estimated according to the following recursive procedure: Equations ( 7), ( 8), (9), and ( 10) are the basic discrete Kalman filter equations.As long as the initial values X0 and  0 are obtained, the state estimate X at time  ( = 1, 2, . ..) can be recursively obtained based on the measurement   at time point .Generally, the initial value can be obtained from the equation The numerical values of  and  are taken based on the engineering experience in the practical engineering applications.Therefore, if the state-space model and associated initial value is known, the Kalman filter recursive formula can be used for the real-time filtering.

Transform Method from ARMA Model to System State-Space Model.
If the test data time series have been obtained, the time series ARMA model can be formed based on the time series modeling.The ARMA model should be transferred to the system state-space model.And then the Kalman filtering state and measurement equations [18,20] can be established.
The ARMA(, ) model can be expressed as where   is the white noise about time,  = max(,  + 1).If  > , then   = 0.If  > , then   = 0. (Note:   is a time series that have a zero mean.)Then the above ARMA(,  − 1) model can be converted into a state-space model: where That is, the system state equation is ) . ( The measurement equation is Based on the above conversion, ARMA(, ) model can be converted to the corresponding system state-space model.
And the Kalman filter recursive formula can be used to filter time series in real time.

The Recursive Least Squares Method Principle for the Elimination of Trend
Term.Linear least squares method [21][22][23] is commonly used in eliminating the line state baseline shift and the trend term of high order polynomial in engineering application.The steps of eliminating the trend term are as follows.First, suppose that the trend term polynomials are established, and the polynomials can be solved with equations listed in the least squares principle.Second, the trend term coefficient matrix and fitting curve can be calculated based on matrix method.Finally, subtracting the trend term fitting curve from the original signal curve can eliminate the trend term error.
Recursive least squares method originates from the least squares method.In this paper, the recursive least squares algorithm is applied to eliminate the trend term.The recursive algorithms are derived as follows.
Suppose {  }, ( = 1, 2, . . ., ) is the time series with the sampling interval of ℎ; the -order polynomial,   , is used to fit the trend item.Assume where  is the size of the selected initial test data series.And  is the highest order of the fitting polynomial.Equation ( 16) can be expressed in the form of matrix as where The equation above can be obtained according to the least squares estimation principle: Let The recursive least squares equation based on the least squares estimation is derived as follows.
Firstly assume new test data is measured,  +1 , and it will build a new data series, {  }, ( = 1, 2, . . ., ,  + 1).So the model parameters should be estimated again.According to the above matrix arrangement form, the least squares estimation equation relative to data  +1 can be represented as where Using the subblock matrix multiplication and matrix theory inverse formula can derive the recurrence equation ( 23) of the recursive least squares method as follows.And the detailed derivation method can be seen in [8]: From (23), it can be seen that  +1 , the new estimation of the model parameters, is the correction of the primary estimation,   .And the correction term ( +1 ( +1 −  +1   )) of the model parameters is the weighted processing of the difference of the new signal ( +1 ) and its estimation.The weighted coefficient is  +1 .The current estimation of the new signal data  +1 can be expressed as Suppose the first  observation data of the test series {  } are known;   and   can be calculated by using the recursive operation equation (23). +1 ,  +1 ,  +1 ,and x+1 can be obtained in the same way.Each step estimation result (x +1 ) of the recursive calculation processing is the trend term of the new signal data,  +1 , where  +1 = [1, ( + 1)ℎ, (( + 1)ℎ) 2 , . . ., (( + 1)ℎ)  ].The trend term can be eliminated by subtracting the estimation result (x +1 ) from the new signal data ( +1 ).

Simulation and Verification
A semiphysical simulation platform of pumping is built to simulate the working state of the field pumping unit.The online real-time recursive least squares algorithm to eliminate the noise and trend term of the acceleration signal is used to deal with the random noise and trend term.And the polish rod displacement of the semiphysical simulation platform of pumping can be calculated.Data processing can be divided into two phases: online real-time learning phase and eliminating phase of the noise and trend term.

Online Real-Time Learning Phase.
Firstly, an acceleration signals series shall be measured from the semiphysical simulation platform in the online real-time learning phase.
Then the time series model and parameters can be obtained by using the time series analysis techniques.Finally, the period of the acceleration signal is obtained by using the FFT transform.The Kalman model parameters, initial value, and signal period are all obtained to eliminate the noise and trend term of the acceleration signal.A series of acceleration signals are collected from the semiphysical simulation platform.The series are shown in Figure 1 (the zero mean has not been processed).The sampling interval is 50 ms.
The acceleration data in Figure 1 should be stationary pretreated for stationed uncertainty of the signal.The stationary test methods include Data Figure test, autocorrelation test, characteristic root tests, and some other test methods.In this paper, the best test guidelines [24,25] and nonparametric tests [26] stationary test methods are selected to test the stationarity of the acceleration sensor signal data.
Upon stationary test, it can be found that the acceleration sensor signal in Figure 1 is nonstationary.After a differential operation of the signal, the sequence stationary becomes acceptable.And the acceptable differentiated sequence is shown in Figure 2.
Based on the tailing or truncated characteristics of the autocorrelation function and partial autocorrelation function, the acceleration signal data in Figure 2 can be treated and modeled with the time series model method.And the time series model of differenced acceleration signal data is   Using (26) to fit the learning data, the result can be seen in Figure 3.It can be seen from Figure 3 that the fitting data from the ARIMA model can well fit the original data, which verifies the correctness of the ARIMA model.
The denoised signal is zero mean processed.The spectrogram can be obtained by using FFT algorithm.Let the sampling frequency of the signal series be 20 Hz.The subscript and amplitude of the maximum and second maximum amplitude signal point in the spectrogram can be obtained.Then the acceleration signals frequency can also be calculated, 0.2469, by using the frequency estimation method in Section 2.1.So one complete period have 81 points.And the integration and eliminating the trend terms of the acceleration signal are done by adding windows of 81 points in the subsequent signal processing.

Real-Time Elimination of the Random Noise and Trend
Term.The measured acceleration signal is treated with the Kalman filter to eliminate the random noises.And the denoised acceleration signal plot can be seen in Figure 4.
It can be seen from Figure 4 that the glitch of the original data charts disappeared.And the denoises signal chart is smooth.So the majority of the random noise is filtered out.
The displacement is obtained by integrating the acceleration signal with adding windows of 81 points in one complete period.The trend terms of velocity and acceleration signals are eliminated by using the recursive least squares method.Firstly, the integrated acceleration signal can be calculated and the trend terms of acceleration signals are However, the same acceleration signals are also filtered by using the recursive least squares method without adding windows and the simulation results are shown in Figure 6.
It can be seen that the trend terms of velocity are eliminated and the trend terms of displacement are eliminated from the global aspect as well.But the plots of velocity and displacement have obvious fluctuation tendency among adjacent local periods of the curves.The reason is that though the whole signal data of acceleration and velocity have been zero mean treated, the signal data of acceleration and velocity of each period have not been zero mean treated.So there will be some local trend terms of the displacement and velocity among adjacent local periods of the curves.And the displacement measurement error is relatively large.
Comparing the results of the two methods, we can see that the windowed method is more effective in eliminating trend items.
The maximum displacement of pumping rod movement is less than 1.60 m in the semiphysical simulation platform.Using the method studied in this paper combined with period windowing method, selecting the data of six consecutive periods, using Kalman filtering, taking integral operation,  and eliminating trend term can obtain the displacement values of each period.And the displacements of each period are shown in Table 1.
Table 1 shows the displacements of each period, that is, the relative displacements between the highest and lowest points.And the relative displacements are very close to the actual values.The relative measurement error is less than 3%.The limit of the indicator diagram displacement error in the actual project is less than 5%.So this result can meet the requirements of the actual project.It also further validates the effectiveness of the real-time method to eliminate the noise and trend term of the acceleration signal.

Conclusions
This paper presents a real-time method to remove noises and eliminate trend terms based on online learning method and the platform pumping semiphysical simulation system verifies the feasibility and practicality of the proposed method.The new online real-time method can be summarized as follows.Firstly, the ARIMA model of the acceleration signal is constructed based on the time series analysis method.Secondly, the period of the acceleration signal is calculated by using the Rife-Jane frequency estimation method and the effect on the estimation precision of the acceleration signal period caused by the barrier effect is inhibited.Thirdly, the random noises of the acceleration signal are eliminated by using the Kalman filter algorithm and the recursive least squares method is used to online eliminate in real-time the trend term of the acceleration signal.The experimental results show that this method can effectively remove the noise of the acceleration signal and the trend terms of the displacement.It can control the displacement error within 3% which is 2% less than the actual displacement engineering requirements error (5%).In summary, the new method can greatly improve the measurement accuracy of the dynamometer displacement.

Figure 1 :
Figure 1: Acceleration signal data for online treatment.

Figure 3 :
Figure 3: Comparison chart of the fitting data and the original data.

Figure 4 :
Figure 4: Comparison charts of the processed data and the original data.

Table 1 :
Displacement of each period.