Statistical Decomposition and Machine Learning to Clean In Situ Spaceflight Magnetic Field Measurements

Robust in situ magnetic field measurements are critical to understanding the various mechanisms that couple mass, momentum, and energy throughout our solar system. However, the spacecraft on which magnetometers are often deployed contaminate the magnetic field measurements via onboard subsystems including reaction wheels and magnetorquers. Two magnetometers can be deployed at different distances from the spacecraft to determine an approximation of the interfering field for subsequent removal, but constant data streams from both magnetometers can be impractical due to power and telemetry limitations. Here we propose a method to identify and remove time‐varying magnetic interference from sources such as reaction wheels using statistical decomposition and convolutional neural networks, providing high‐fidelity magnetic field data even in cases where dual‐sensor measurements are not constantly available. For example, a measurement interval from the Parker Solar Probe outboard magnetometer experienced a 95.1% reduction in reaction wheel interference following application of the proposed technique.

source where the complex multipole terms cannot be neglected. In theory, a multipole source model can still be used to subtract the gradient; however, this requires careful pre-flight characterization of all possible interference sources which can be challenging or logistically impossible.
Recently, additional techniques have been developed in order to mitigate local magnetic interference onboard spacecraft. One simple approach is to simply apply a band-stop filter at the frequencies associated with the dominant interference source (e.g., reaction wheels). However, methods that utilize this approach can encounter problems during spacecraft maneuvers, as the reaction wheels diverge from their nominal rates, contaminate extremely large frequency bands, and can spectrally overlap with geophysical signals of interest. Advanced methods such as blind source separation (Hoffmann & Moldwin, 2022;Sheinker & Moldwin, 2016), independent component analysis (Imajo et al., 2021), maximum variance analysis (Constantinescu et al., 2020), and spectrum-based feature extraction (Bowen, Mallet, et al., 2020) have been shown to successfully identify and remove interference from magnetometer measurements when two or more sensors are available without relying on hand-tuned filters.
Recent advances in machine learning techniques have seen their widespread adoption in various space physics fields. For example,: Space weather forecasting (Camporeale, 2019), in situ magnetometer calibration (Styp-Rekowski et al., 2022), auroral image classification (Clausen & Nickisch, 2018), and plasma modeling (Bard & Dorelli, 2021). These machine learning tools have been used in a variety of other fields in order to improve the fidelity of contaminated measurements (Tian et al., 2019;E. Wang & Nealon, 2019). However, interference mitigation for on-orbit magnetic field data utilizing machine learning techniques has not been thoroughly explored.
This manuscript proposes a novel method for the integration of machine learning and statistical decomposition for magnetometer interference mitigation. The proposed method leverages potentially limited gradiometer data and provides the capability to automatically identify and remove magnetic noise caused by the host spacecraft during intervals when only a single magnetometer is constantly telemetering data. For example, a measurement interval from only the Parker Solar Probe outboard magnetometer will be shown to experience a 95.1% reduction in interference attributed to the spacecraft's reaction wheels following the application of the proposed algorithm.

Statistical Decomposition and Classification for Gradiometers
Singular Spectrum Analysis (SSA) is a statistical technique for the decomposition of signals into physical meaningful components (Golyandina et al., 2001;Groth & Ghil, 2015). Historically, this technique has seen success in a wide range of fields from climatology (Chen et al., 2013;Vautard & Ghil, 1989) to economics (Hassani & Thomakos, 2010;. Recently, the multivariate extension of SSA (MSSA) has been used to simultaneously decompose time-series measurements from a pair of satellite-mounted magnetometers into robust, physically meaningful components corresponding to the near-DC trend, interesting geomagnetic phenomena, and local magnetic interference (Finley et al., 2023).
Fundamentally, SSA compresses the maximum variance in a signal into a minimum number of time-series components through decomposition of a time-delayed embedding of the original input signal (Groth & Ghil, 2015). The output of the technique is a set of time series, each with length equal to the original input, that correspond to the input's trends, periodic oscillations, and extraneous phenomena (Golyandina et al., 2001(Golyandina et al., , 2018. Further, these output sub-signals, when summed together, completely recreate the original input with no loss of information. The parameter space for SSA is very low, with only two user-defined parameters required for operation: the fixed input length (N); and, the tunable window length (L) which defines both the number of sub-signals generated and the maximum-period oscillation that can be isolated. The multivariate extension (MSSA) expands upon SSA by simultaneously decomposing multiple input signals (e.g., measurements from multiple magnetometers), leveraging shared spatiotemporal information from all inputs.
To classify these sub-signals as local magnetic interference or background field the interference approximation provided by the magnetic field gradient between two boom-mounted magnetometers can be utilized. Mathematically, this approximation is defined for each sensor axis as (1)

of 10
The statistical correlation between each of the decomposed sub-signals and the interference approximation is then calculated; sub-signals with a low degree of correlation correspond to the background field, whereas sub-signals with a high degree of correlation correspond to local magnetic interference and are subsequently removed. A threshold parameter (ɑ) is defined by the user to determine the minimum correlation value that is tolerable in the denoised output. Further mathematical details and results for the application of this dual-sensor magnetometer denoising technique can be found in Finley et al. (2023).

Machine Learning for Single-Sensor Classification
Although the field gradient between two magnetometers is useful in classifying decomposed sub-signals as geomagnetic phenomena or local interference, data is not always available from both magnetometers onboard a spacecraft. Often, telemetry limitations force compromises to be made when transmitting magnetic field data to the ground, resulting in limited intervals where two sensors are providing full-cadence measurements. This can obviously limit the applicability of the statistical interference mitigation technique described in Section 2.1 due to the unavailability of the interference approximation.
However, it can be observed that for well-synchronized and calibrated pairs of magnetometers, SSA and MSSA produce extremely similar results. Figure 1 illustrates the first five sub-signals output for the outboard sensor from the dual-sensor MSSA decomposition (left), as well as the single-sensor SSA decomposition for the outboard sensor (right), over an interval of CASSIOPE/Swarm-Echo magnetic field data (Wallis et al., 2015;Yau & James, 2015) using a window length of 20 samples for a signal with a length of ∼24,000 samples. Note that the same features such as near-DC trend (Row 1), oscillations presumably caused by reaction wheels (Rows 2 and 3), and geomagnetic phenomena (Rows 4 and 5) previously identified as Alfvénic activity (Finley et al., 2023;Miles et al., 2018) can be seen in both methods of decomposition. This implies that the classification of the sub-signals decomposed by both techniques should also be extremely similar, although we cannot rely on the simple field gradient for classification when only one sensor is available.
Recent advances in machine learning (ML) tools have seen neural networks achieve a great deal of success in classifying time-series signals. This manuscript proposes the use of such networks to automatically classify signals decomposed by SSA as either local magnetic interference or residual geophysical signal, enabling interference mitigation even when only a single magnetometer is constantly telemetering data. A high-level block diagram of the proposed technique is shown in Figure 2a. During intervals where two magnetic field sensors are telemetering data, MSSA is used to decompose the measurements and the magnetic gradient between the sensors is used to classify them, as explained in Section 2.1 (Finley et al., 2023) and shown outlined in blue in Figure 2a (Normal Operation). These decomposed signals and associated labels are used to train a Convolutional Neural Network (CNN, Goodfellow et al., 2016), which is used to perform the same binary classification on SSA-decomposed signals when measurements from only a single magnetometer are available. This resiliency mode operation is outlined in gray in Figure 2a (Resiliency Operation).
The specific CNN implemented for this manuscript is shown in Figure 2b, and was adapted from a similar architecture described in (Z. Wang et al., 2017). This network was selected due to the simplicity of its implementation and its performance history on classification of time series data. The basic building block of this network is a convolutional layer followed by batch normalization (a regularization technique used to increase convergence speed and avoid overfitting) and the ReLU activation function (f(x) = max(0,x)) to provide nonlinearity (Goodfellow et al., 2016). The filter applied at each convolution decreases in length from eight to five to three for each of the respective blocks. The number of filters applied in each convolutional layer is four for the leftmost and rightmost block and is eight at the center block. After the convolutions are applied, a global pooling operation is performed, a dense layer is used to adjust the dimensionality, and the Softmax activation function provides the probability associated with the binary output labels through exponentiation and normalization (Goodfellow et al., 2016). This network was implemented in MATLAB 2022b using functionality from the Deep Learning Toolbox. Training parameters and results are discussed in detail in Section 4.

CASSIOPE e-POP/Swarm-Echo MGF
The first source of data analyzed in this manuscript is from the CASSIOPE/Swarm-Echo magnetic field instrument (MGF). These identical fluxgate magnetometers are deployed on a common boom at distances of approximately 0.9 and 0.6 m from the host spacecraft. Both sensors measure and telemeter data at a cadence of 160 samples/s. The specific intervals chosen for visualization or analysis were selected due to the presence of interesting geophysical events such as the Alfvén waves  shown in Figure 1 and ion upflow and downflow (Shen et al., 2016(Shen et al., , 2018 shown in Section 4, all of which have distinct magnetic signatures. Note that a 20 s moving average (Hansun, 2013) has been removed from the original measurements captured by the e-POP MGF for ease of visualization.

Parker Solar Probe FIELDS MAG
Another source of data analyzed in this manuscript is from the Parker Solar Probe/FIELDS experiment (Bale et al., 2016). FIELDS consists of two fluxgate magnetometers (MAGs) 1.9 and 2.7 m from the spacecraft, which operate at a maximum sample rate of 292.969 samples/s (Bowen, Bale, et al., 2020). The dual sensors provide for failure redundancy, gradiometric estimates of spacecraft noise, and monitoring of variations in DC offsets. The outboard MAG (MAGo) is less impacted by spacecraft noise and accordingly used as the primary science instrument. The inboard MAG (MAGi) data is generally downsampled, using an onboard triangle filter, by a factor of 2 N prior to transmitting the data due to telemetry constraints of the mission. Data chosen in this study were chosen due to the identical sample rates of the inboard and outboard measurements. Note that low-frequency interference from other subsystems dominates the field gradient spectrum, and a high-pass filter at 3 Hz is applied by the authors to enable isolation of only the reaction wheels, which are a significant source of noise in studying the polarization of plasma waves (Bowen, Mallet, et al., 2020).

Neural Network Training
The CNN used to classify decomposed sub-signals on e-POP MGF data was trained using gradiometer data from 1 to 5 March 2016, although the data coverage was sparse in this interval as is typical for this spacecraft. The available data was split into 40-s intervals (i.e., 6,400 samples/interval) and discarded if NaN values were present in either the inboard or outboard measurements (due to data dropouts or other factors). Each of the resulting 476 pairs of measurements were passed through MSSA with a window length (L) of 40 samples, resulting in ∼39,000 pairs of sub-signals that were subsequently labeled via correlation against the magnetic field gradient with a threshold of ɑ = 0.55. This threshold value was intentionally set high to increase the confidence in the labeling scheme, although the resulting labels may still be incorrect when the statistical significance-as defined in Finley et al. (2023)-of the sub-signals is ambiguous. Of the original ∼76,000 sub-signals, ∼2,500 were labeled as interference and ∼74,000 were labeled as residual geophysical signal. A random permutation of 2,000 of the sub-signals corresponding to each binary label (i.e., interference and geophysical signal) were selected as inputs to the CNN training.
A similar data processing scheme was utilized for the limited gradiometer data from the Parker Solar Probe MAG. Only 3 hr of data (06:00:00-09:00:00 UTC) from 30 March 2019 (Encounter 2) were processed with a window length (L) of 40 samples and a threshold value (ɑ) of 0.35, resulting in ∼43,000 labeled 40-s sub-signals (∼2,600 labeled as local interference, ∼40,500 labeled as residual geophysical signal). A random permutation of 2,500 of the sub-signals corresponding to each label were selected as inputs to the CNN training.
Prior to training the CNN, all input data were normalized between 0 and 1. The total input set was divided randomly into disjoint training, validation, and testing sub-sets using a typical 80%, 10%, 10% split (Vabalas et al., 2019). The network was then trained, using the default Adam optimizer (Kingma & Ba, 2017) to minimize the cross-entropy loss function, for 10 epochs. Cross-entropy, which calculates the difference between two probability distributions, is a standard choice for classification networks (de Boer et al., 2005). It is important to note that, given the potential for misclassification in the generation of the training set, the performance of the classification network is not necessarily indicative of the performance of the interference mitigation algorithm as a whole. That said, the CNN trained on e-POP MGF data achieved a validation accuracy and loss of 98.0% and 0.086. The CNN trained on PSP MAG data achieved a validation accuracy and loss of 98.86% and 0.046.

Numerical Analysis
To quantitatively assess the performance of the proposed method in mitigating stray magnetic field caused by reaction wheels, it is necessary to perform numerical analysis of the results. This manuscript calculates the linear spectrum associated with the apparent reaction wheel frequencies during the events under observation before and after the application of the proposed method of single-sensor decomposition and ML-enabled sub-signal classification. Results are also calculated for the dual-sensor, gradient-based algorithm to provide a comparison with the technique used to train the classification network.
The values of the linear spectrum associated with the reaction wheel frequencies is calculated using Welch's method of overlapping periodograms (Welch, 1967) and an HFT95 flat-top window with an effective noise bandwidth (ENBW) of 3.8112 Hz (Heinzel et al., 2002). Mathematically, the linear spectrum (LS) can be defined based on the power spectral density (PSD) resulting from Welch's method as The results analyzed in this section are from data with near-constant reaction wheel rates for computational simplicity in the absence of a ground truth. Note that, during the intervals selected for analysis, the CASSIOPE reaction wheels were spinning at a uniform rate. As such, only one frequency point must be analyzed to determine the mitigation performance provided by the proposed method. However, the Parker Solar Probe reaction wheels are not at a uniform rate during these intervals, so the linear spectrum value attributed to each reaction wheel frequency (determined using the spacecraft's housekeeping data) is calculated and averaged.
Additional analysis is performed to ensure that the proposed interference mitigation technique does not suppress a significant portion of the ambient magnetic field surrounding the local interference in the frequency domain. This is performed by calculating the RMS value associated with the linear spectrum at all frequencies outside of a small region (∼±0.4 Hz) surrounding the apparent reaction wheel frequencies. The resulting value is then compared before and after the application of the proposed method to ensure data not contaminated by interference is well-preserved by the proposed algorithm.

Experiments
The proposed method of automated single-sensor interference mitigation utilizing machine learning classification techniques was applied to four distinct intervals of magnetometer data from two different missions, as shown in Figure 3. Each row of Figure 3 corresponds to one interval: Row 1 and 2 illustrate the proposed method applied e-POP MGF data during ion downflow events (Shen et al., 2016(Shen et al., , 2018; Row 3 and 4 illustrate the technique applied to intervals of Parker Solar Probe (PSP) MAG data during Encounter 2. The first two columns of Figure 3 show the outboard measurements before and after the single-sensor correction, as well as after the dual-sensor correction for comparison. Column 1 shows the entire 40-s interval under observation, whereas Column 2 shows a 2-s zoomed view for ease of visualization. Columns 3-5 show the spectra associated with the uncorrected, single-sensor corrected, and dual-sensor corrected measurements, respectively. Table 1 provides numerical results for the proposed interference mitigation method using the analysis technique described in Section 4.2. The specific frequencies analyzed correspond to the reaction wheel frequencies observed or reported by the spacecraft housekeeping data. For the e-POP MGF events shown, the proposed single-sensor method reduces the linear amplitude at the frequencies associated with the spacecraft reaction wheels by greater than 87% without substantial suppression of the ∼2-3 nT ambient magnetic field. For the PSP MAG intervals during Encounter 2, an amplitude reduction of greater than 95% can be seen in the reaction wheel frequencies without significant suppression of the ∼0.3-0.4 nT ambient field.
These results are compared to the dual-sensor interference mitigation method, which utilized the same window length (L = 40) as in the single-sensor decomposition, paired with a threshold value (ɑ) of 0.25 for PSP and 0.15 for e-POP. Amplitude reductions of greater than 88% and 78% can be seen for e-POP and PSP, respectively. This slightly lower reduction (specifically for the PSP MAG) can be attributed to the substantial time-frequency overlap seen between the apparent reaction wheel interference and the observed magnetic phenomena during the intervals analyzed, although the dual-sensor interference method still does not substantially reduce the ambient field amplitude calculated using the technique described in Section 4.2.
As the SSA technique and its multivariate extension provide asymptotic separability (Harmouche et al., 2018), larger window lengths enable signal elements with lower frequencies or close spectral signatures to be separated from one another; however, greater window length also increases the number of sub-signals generated by the decomposition, potentially reducing their statistical significance. As such, an identical window length was used across all experiments for simplicity and consistency. More robust models utilizing all available gradiometer data, hyperparameter optimization, model generalizability across missions, and generalizability to interference sources other than reaction wheels are all exciting avenues for future work related to the proposed method of interference mitigation.

Conclusions
This manuscript has presented a novel method for the automatic mitigation of local magnetic interference from sources such as reaction wheels on spacecraft where gradiometer measurements are not always available. Specifically, statistical decomposition and analysis provide a large data set of labeled sub-signals when gradiometer measurements are available. This data set is subsequently used to train a neural network to label decomposed signals as local interference or residual physical fields when data from only a single magnetometer is available. This method has been tested, with positive results, against measurements from the CASSIOPE/Swarm-Echo and Parker Solar Probe missions. For example, on a 40-s interval of data during Parker Solar Probe's Encounter 2, a reduction in reaction wheel amplitude of 95.2% can be seen following the application of the proposed method. Figure 3. The proposed method of single-sensor interference mitigation compared to dual-sensor mitigation during intervals of e-POP MGF data captured during geomagnetic phenomena (Rows 1-2) and Parker Solar Probe MAG data captured during Encounter 2 (Rows 3-4). (Columns 1-2) 40-s total interval and two-second zoomed interval time-series data for uncorrected, single-sensor corrected, and dual-sensor corrected outboard measurements; (Column 3) Uncorrected outboard spectrum; (Column 4) Single-sensor corrected outboard spectrum; (Column 5) Dual-sensor corrected outboard spectrum.

Note.
(Rows 1-2) Results for interesting geomagnetic intervals captured by the e-POP MGF; (Rows 3-4) Results for PSP MAG data captured during Encounter 2.

Table 1
Numerical Analysis for the Events Shown in Figure 3