# BDS Satellite Clock Prediction Considering Periodic Variations
## 2 Materials and Methods
### Preprocessing of Clock Offsets  
The preprocessing of raw clock offsets is of great importance for periodic variation analysis and clock prediction. The gross errors and phase jumps are the main anomalies of the clock offsets, which cannot objectively reflect the characteristics of the satellite clocks and degrade the performance of clock prediction [33]. Such clock anomalies should be processed before periodic variation analysis and clock offset modeling. With high calculation efficiency and anti-error performance, the MAD method is usually used to detect gross errors [34]. When the clock frequency series satisfies Equation (1), the related clock offsets are considered abnormal:  
\[|y_{i}|>k \tag{1}\]  
where \(y_{i}\) represents the clock frequency series, \(i\) is the epoch, and \(k\) is the threshold value, which can be calculated by \(k=m+n\cdot MAD\). \(m\) denotes the median of the clock frequency series, \(MAD=Median\{|y_{i}-m|/0.6745\}\), and the factor \(n\) can be set to 3-5.  
The traditional MAD method is a preprocessing method corresponding to clock frequency series. Both gross errors and phase jumps of clock offsets in time domain will bring outliers in clock frequency series, which means the outliers detected by traditional MAD are caused by gross errors or phase jumps. If all the outliers are processed without distinguishing them, some effective clock offsets may be destroyed simultaneously. Therefore, it is necessary to identify the outliers caused by gross errors or phase jumps. In this paper, we use double MAD detection to distinguish the outliers. The detailed flowchart of the double MAD detection is shown in Figure 1.  
As shown in Figure 1, the double MAD detection performs two MAD detection. In the first MAD detection, the raw clock offsets are converted to clock frequency series, and the threshold value \(k\) is calculated. The outliers of clock frequency series can be easily detected by MAD detection. Then, store the clock offset outliers identified by the first MAD detection temporarily and eliminate the frequency outliers. After that, the clock offset series without gross errors are recovered by integral algorithm. In the second MAD detection, the new clock frequency series are recalculated, while the threshold \(k\) still uses the value obtained by the first MAD detection. In this case, the outliers of clock frequency series absolutely correspond to the phase jumps, and the clock offsets, which are accidentally removed during the first MAD detection, can be recovered. After double MAD detection, the outliers caused by gross errors and phase jumps are marked respectively.  
It should be noted that the gross errors and phase jumps identified by double MAD detection should be processed reasonably. In this paper, the gross errors are set to zero in the BDS satellite clock periodic variation analysis, while removed directly during modeling. The constant offset brought by phase jump is corrected to guarantee sufficient clock offset series for modeling. We use the mean of \(f_{2}\) without outliers to substitute the outliers of the clock frequency series. After that, the clock offsets before and after the phase jump are aligned.