## 2 Methods
### Misalignment Error Calibration  
In this method, a high accuracy non-magnetic theodolite is used to precisely adjust the attitude of the magnetometer, so as to unify the observed diurnal variation into the geographic coordinate system. For this purpose, we need to calibrate misalignment error between the magnetometer and the theodolite. Figure 2 illustrates misalignment error between the magnetometer and the theodolite. As is shown, we define two coordinate systems: the magnetometer coordinate system (\(o_{m}-x_{m}y_{m}z_{m}\)) and the theodolite coordinate system (\(o_{t}-x_{t}y_{t}z_{t}\)), in which \(x_{m},y_{m},z_{m}\) and \(x_{t},y_{t},z_{t}\) denote three axes of the magnetometer and the theodolite respectively. According to the Euler-angle rotation method [13], three rotations can re-orient an object in any direction. This method can be applied to calibrate the misalignment error. Here,  
\[\text{rotation matrix}=\left[ \begin{array}{l}\text{rotated }y_{m}-\text{axis}\\ \text{rotated }x_{m}-\text{axis}\\ \text{rotated }z_{m}-\text{axis}\end{array} \right] \tag{15}\]The process can be described by the following rotation matrices. \[\mathbf{C}_{x_{m}-axis}=\left[ \begin{array}{ccc}1&0&0\\ 0&\cos\beta&-\sin\beta\\ 0&\sin\beta&\cos\beta\end{array} \right] \tag{16}\]  
\[\mathbf{C}_{y_{m}-axis}=\left[ \begin{array}{ccc}\cos\gamma&0&\sin\gamma\\ 0&1&0\\ -\sin\gamma&0&\cos\gamma\end{array} \right] \tag{17}\]  
\[\mathbf{C}_{z_{m}-axis}=\left[ \begin{array}{ccc}\cos\alpha&-\sin\alpha&0\\ \sin\alpha&\cos\alpha&0\\ 0&0&1\end{array} \right] \tag{18}\]  
where \(\alpha,\beta,\gamma\) denote the misalignment error angles. The final rotation matrix \(\mathbf{C}_{m}^{t}\) can be found by multiplying these together. \[\mathbf{C}_{m}^{t}=\mathbf{C}_{z_{m}-axis}\mathbf{C}_{x_{m}-axis}\mathbf{C}_{y_{m}-axis} \tag{19}\]  
With the known error angles, the transformation of measured data from the magnetometer coordinate system to the theodolite coordinate system is given by  
\[\left[ \begin{array}{c}x_{t}\\ y_{t}\\ z_{t}\end{array} \right]=\mathbf{C}_{m}^{t}\left[ \begin{array}{cc}x_{m}&y_{m}&z_{ m}\end{array} \right]^{T} \tag{20}\]  
In this paper, we adopted an approach to identify the three misalignment error angles by rotation. When rotating the magnetometer around one axis of the theodolite, the projection of geomagnetic field on the axis of the magnetometer aligned with the rotation axis is constant after calibrating misalignment error, which serves as the basis for calibration method. According to Equation (20), the measured data are substituted into the following equation to calibrate the misalignment error. \[\mathbf{h}=\mathbf{C}_{m}^{t}\mathbf{h}_{m} \tag{21}\]  
where \(\mathbf{h}_{m}\) denotes the measured data of the magnetometer rotating around one axis of the theodolite. Figure 2: Diagram of misalignment error between the non-magnetic theodolite and the magnetometer. Let  
\[\mathbf{v}=\left[ \begin{array}{c}v_{x}\\ v_{y}\\ v_{z}\end{array} \right]=\mathbf{h}(i)-\mathbf{h}(j)\ \ \ (i\
eq j) \tag{22}\]  
As analyzed above, \(v_{x}\) is constant during the rotation around \(x_{t}\)-axis. Similarly, \(v_{y}\) and \(v_{z}\) remain unchanged as well when rotating around \(y_{t}\)-axis and \(z_{t}\)-axis respectively. Thus, we can get  
\[v_{c}(i)-v_{c}(j)=0\ \ \ \ c\in\{x,y,z\} \tag{23}\]  
The objective function is defined as  
\[l(\alpha,\beta,\gamma)=\min_{c\in[x,y,z]}\sum_{i=1}^{n-1}\sum_{j=i+1}^{n}\left| v_{c}(i)-v_{c}(j)\right| \tag{24}\]  
This optimization design aims to estimate three misalignment error angles by minimizing the objective function. The optimization process solves this nonlinear system with multiple objectives using the least square method [14]. Rotating the magnetometer around one axis of the theodolite can only align this axis to the magnetometer's axis of the same direction, which means rotating the magnetometer around \(y_{t}\)-axis of the theodolite only ensures the alignment of \(y_{t}\)-axis to \(y_{m}\)-axis.