## 3 Proposed Method
### Compensation Principle  
As a magnetic field sensor, the magnetic field measured by the fluxgate is susceptible to interference from external magnetic fields. Meanwhile, the fluxgate itself has the problem of diversionary error, which leads to errors in attitude information obtained by fluxgate measurement during flight. INS is not affected by the magnetic field, but the accuracy is not high. By introducing INS information into the T-L model, attitude information from fluxgate and INS can complement each other to make up for the deficiency of a single sensor. According to the T-L model, we need to describe the change in three components of the geomagnetic field in the aircraft coordinate system due to aircraft action. The international geomagnetic reference field (IGRF) is a general international model for describing the earth's main magnetic field through using the longitude, latitude, and altitude information [22]. At present, this model can be used to calculate the seven elements of the geomagnetic field at any point. So, according to the IGRF model, the geomagnetic field parameters (geomagnetic field inclination I, geomagnetic field declination D, and geomagnetic field intensity \(H_{e}\)) in the geodetic coordinate system can be calculated by using the longitude, latitude, and altitude information in the aircraft GPS [23]. The aircraft coordinate system can change with the change in roll angle, pitch angle, and heading angle, so it is necessary to convert the geomagnetic field in the geodetic coordinate system to the geomagnetic field in the aircraft coordinate system, as shown in Figure 2.  
Figure 2: Diagram of the coordinate system transformation. For description, this paper defines the geodetic coordinate system and the aircraft coordinate system as follows:  
Geodetic coordinate system: the north-east geodetic coordinate system, with the X-axis pointing to geographic north, the Y-axis pointing to geodetic east, and the Z-axis pointing to the earth's center. \(H_{e}\) denotes the geomagnetic field, \(H_{h}\) denotes the horizontal component of the geomagnetic field, and D and I denote the geomagnetic declination and geomagnetic inclination, respectively. Aircraft coordinate system: a rectangular coordinate system fixed on an aircraft with the origin at the aircraft's center. The X-axis is parallel to the fuselage axis and points to the flying head. The Y-axis is perpendicular to the longitudinal section of the fuselage and points to the right wings. The Z-axis is perpendicular to the plane where the fuselage is located and points to the bottom of the aircraft. The angle of roll, pitch, and yaw are \(\theta\), \(\varphi\), and \(\psi\), respectively. According to the IGRF model, the geomagnetic field parameters can be calculated by Equation (16). \[[H_{e},\ I,\ D]=IGRF(time,longitude,latitude,altitude) \tag{16}\]  
The XYZ three components of the geomagnetic field in the geodetic coordinate system are shown in the following equations:  
\[H_{geox}=\cos I\cos DH_{e} \tag{17}\]  
\[H_{geoy}=\cos I\sin DH_{e} \tag{18}\]  
\[H_{geox}=\sin IH_{e}. \tag{19}\]  
The XYZ three components of geomagnetic field vector in the aircraft coordinate system are set to (\(H_{airx}\), \(H_{airy}\), and \(H_{airz}\)). The XYZ three components of the geomagnetic field vector in the geodetic coordinate system are set to (\(H_{geox}\), \(H_{geoy}\), and \(H_{geoz}\)). The angle of roll, pitch, and yaw can directly be obtained by INS. According to the three-dimensional rotation matrix [24], the XYZ three components of the geomagnetic field in the aircraft coordinate system are expressed as follows:  
\[ \begin{bmatrix}H_{airx}\\ H_{airy}\\ H_{airz}\end{bmatrix} =\phi \begin{bmatrix}H_{geox}\\ H_{geoy}\\ H_{geoz}\end{bmatrix}  \tag{20}\]  
\[\phi= \begin{bmatrix}1&0&0\\ 0&\cos\theta&\sin\theta\\ 0&-\sin\theta&\cos\theta\end{bmatrix}\begin{bmatrix}\cos\varphi&0&-\sin\varphi \\ 0&1&0\\ \sin\varphi&0&\cos\varphi\end{bmatrix}\begin{bmatrix}\cos\psi&\sin\psi&0\\ -\sin\psi&\cos\psi&0\\ 0&0&1\end{bmatrix} .