## 3 Method
### Working Conditions Classification  
The working condition of the spacecraft is defined as the set of the environment state (temperature, electromagnetic radiation intensity), mission state (acceleration, deceleration, attitude adjustment), and life cycle (service time) of the spacecraft, covering all the factors that may affect the threshold of spacecraft anomaly detection. The performance of spacecraft anomaly detection can be improved by classifying the working conditions of the spacecraft. In the whole life cycle of a spacecraft, it will face different working conditions. Under different working conditions, the sequence of spacecraft data will have different statistical characteristics, and the threshold of anomaly detection will also change, so it is necessary to classify and process the CMG data under different working conditions.  
The CMG data is the full-cycle data of the CMG on an on-orbit spacecraft from the time it was put into use to the time it failed. The data is sampled once every 10 days, which is 155 days in total. The CMG data is divided into 16 channels, including the gimbal motor current, rotor motor current, shaft temperature, speed, and other parameters. Since the data characteristics of each channel are different, the Sinc-LSTM network trains the anomaly detection task model separately for each channel data after pre-training. In the working condition classification stage, the data of each channel are first divided into hourly segments, and there are a total of \(155\times 24=3720\) segments. The data size of each segment after segmentation is about 16 channels and 6450 rows.  
The automatic clustering algorithm based on density peak (DPC) is selected as the adaptive working condition classification method. The clustering algorithm based on density peak determines a certain category by calculating the density of the surrounding points and the distance from the surrounding points. According to the algorithm, for the center point of each class, the density of its surrounding points should be greater than the density of other points of the class. At the same time, the center point of this class should be far enough away from the center points of other classes. The specific formula of local density is as follows.  
\[\rho_{i}=\sum_{j}\chi\big{(}d_{ij}-d_{c}\big{)} \tag{2}\]  
where, if \(x<0\), then \(\chi(x)=1\), in other cases, \(\chi(x)=0\). Meanwhile, \(d_{c}\) is the cutoff distance. \(\rho_{i}\) is the number of points whose distance from the point \(i\) is less than \(d_{c}\). The specific formula to calculate the distance is as follows.  
\[\delta_{i}=\left\{\begin{array}{l}\min\big{(}d_{ij}\big{)},s,t,\rho_{j}>\rho _{i}\\ \max\big{(}d_{ij}\big{)},s,t,\rho_{j}\leq\rho_{i}\end{array}\right. \tag{3}\]  
That is, when the density of a point is not the maximum, the point is not the center point, then the distance is set as the distance from it to the nearest point with larger \(\rho_{i}\); when the density of a point is the maximum, it means that the point is the center point, then the corresponding distance of the point is set as the distance from it to the farthest point.  
With density \(\rho_{i}\) as the horizontal axis and distance \(\delta_{i}\) as the vertical axis, draw a point map. The point closer to the upper right corner has the largest local density and the largest distance, which can be identified as the center point of the cluster. The algorithm can divide the data into appropriate clusters without iterative computation, and it does not need a preset center point, so it has fewer empirical components. After clustering analysis using the DPC algorithm, data segments with different statistical characteristics can be grouped together to play the role of working condition classification, and at the same time, it is convenient to set adaptive threshold judgment for data under different working conditions during subsequent anomaly detection.