ORIGINAL RESEARCH article

Front. Astron. Space Sci., 20 October 2022

Sec. Space Physics

Volume 9 - 2022 | https://doi.org/10.3389/fspas.2022.1016453

Automated bow shock and magnetopause boundary detection with Cassini using threshold and deep learning methods

  • 1. Department of Physics and Astronomy, UCL, London, United Kingdom

  • 2. Mullard Space Science Laboratory, UCL, Dorking, United Kingdom

Abstract

Two algorithms set for automatic detection of bow shock (BS) and magnetopause (MP) boundaries at Saturn using in situ magnetic field and plasma data acquired by the Cassini spacecraft are presented. Traditional threshold-based and modern deep learning algorithms were investigated for the task of boundary detection. Sections of Cassini’s orbits were pre-selected based on empirical BS and MP boundary models, and from outlier detection in magnetic field data using an autoencoder neural network. The threshold method was applied to pre-selected magnetic field and plasma data independently to compute parameters to which a threshold was applied to determine the presence of a boundary. The deep learning method used a type of convolutional neural network (CNN) called ResNet on images of magnetic field time series data and electron energy-time spectrograms to classify the presence of boundaries. 2012 data were held out of the training data to test and compare the algorithms on unseen data. The comparison showed that the CNN method applied to plasma data outperformed the threshold method. A final multiclass CNN classifier trained on plasma data obtained F1 scores of 92.1% ± 1.4% for BS crossings and 84.7% ± 1.9% for MP crossings on a corrected test dataset (from use of a bootstrap method). Reliable automated detection of boundary crossings could enable future spacecraft experiments like the PEP instrument on the upcoming JUICE spacecraft mission to dynamically adapt the best observing mode based on rapid classification of the boundary crossings as soon as it appears, thus yielding higher quality data and improved potential for scientific discovery.

1 Introduction

Cassini was the first spacecraft to orbit around Saturn’s near-space environment. The mission lasted 13 years (2004–2017) producing the first large-scale in situ dataset at Saturn, returning a total of 635 GB of scientific data (). The high spatio-temporal resolution data of the planet and its space environment could be leveraged by data science techniques, including machine learning, to aid the study of outer planets physics.

An ongoing challenge in the study of planetary boundaries like the bow shock (BS) and magnetopause (MP) is their manual identification in big multi-instrument datasets from space missions. From a data analysis perspective, automation of this activity would improve reproducibility, discovery potential in existing unlabelled data, and reusability in existing and future planetary missions. “Human-in-the-loop” scientists combined with partial automation would speed up data selection by orders of magnitude as most data would be pre-classified to a good level of accuracy, whilst only correcting a manageable number of misclassifications would be needed. Automation would facilitate larger crossing lists to be compiled and could also have implications for the future development of onboard data-processing protocols in the pre-downlink stage. From a fundamental perspective, a more complete boundary survey provides an invaluable dataset with which to understand the boundary structures, like the distribution of radial distances, local times, and latitudes at which the boundaries are detected, under different phases of the solar cycle throughout the mission lifetime. This offers a wealth of information about the interface between the planet and the solar wind.

In recent years, there have been multiple studies on the application of machine learning techniques, including deep learning, to automate the process of selecting or detecting plasma regions or boundaries from spacecraft data, many of which focus on space missions of the Earth, with a few for other planets such as Saturn. Recent studies which used Earth space mission data include: Automating the detection of the Earth’s bow shock (BS) and magnetopause (MP) using gradient boosted decision trees (), automating the burst data selection process onboard the MMS spacecraft using a Long-Short Term Memory (LSTM) Recurrent Neural Network (RNN) model (), automating the classification of plasma regions in near-Earth space using a time series convolutional model on engineered features from MMS data (), automating region identification in MMS data using support-vector-machines in the density and temperature (n-T) space (), automatically classifying plasma regions using convolutional neural networks on three-dimensional ion energy spectra produced by DIS sensor onboard MMS (), and predicting plasma regimes and thermal electron density from WHISPER spectra onboard Cluster II using neural networks . Recent studies which used Saturn space mission data include a threshold-based detection of boundary crossings at Saturn from Cassini’s plasma spectrometer data using a transition detection score (), and automatic plasma region classification using an RNN model on Cassini time-series data ().

Despite the recent interest in using machine learning models to tackle the problem of automating such pattern recognition tasks in spacecraft data, more traditional methods such as using thresholds of different engineered parameters have been used to identify potential plasma boundaries such as in in which they compared MP modelled positions and in situ Cluster data. However, each space mission provides its unique challenges.

This study aims to develop and compare traditional threshold and deep learning techniques to automate the detection of the bow shock and magnetopause boundary crossings at Saturn using data from the Cassini spacecraft. The potential to apply such techniques to other planetary boundary studies is also discussed.

1.1 Deep learning models

The following section gives a brief introduction to the deep learning models used in this study for context. Neural networks are powerful function approximators. A feed-forward deep neural network contains two or more layers of neurons. Mathematically, each layer applies a linear operation to its input according to z = WX + b, where W and b are the weights and biases (i.e., learned parameters) of that layer, and X is the input. The output z is then “activated” by an activation function. The activation is a non-linear function, such as the Rectified Linear Unit (ReLU) f(z) = max (0, z), applied to the output of a layer to introduce non-linearity. In short, a fully connected neural network performs the following operations: “weight times input, add a bias, activate”. A trained neural network with learned parameters represents the best function approximation which defines the mapping y = f (x; W, b) ().

1.1.1 Autoencoder

The autoencoder (AE) is an unsupervised learning neural network architecture trained to reconstruct the input as close as possible from a compressed latent space (i.e., the network learns to map an input X to an output X). This dimensionality reduction capability of an AE has been demonstrated by . The AE architecture contains two parts, an encoder (gϕ) and a decoder (fθ). The encoder block takes an input (e.g., an image or sequential data) and compresses it to a latent vector z, then the decoder block learns to reconstruct the input from the compressed representation. The training of the AE neural network involves using backpropagation (i.e., chain rule) to minimise the following loss functionwith respect to the network parameters (θ, ϕ) to output a reconstructed data sample as close as possible to the original input x ≈ fθ(gϕ(x)). The loss function in Eq. 1 is the sum of the squared error between the input and output. For sequential data, the encoder and decoder blocks utilise a long short-term memory (LSTM) recurrent neural network, which is adept at learning longer-term dependencies in time-series data due to their “memory cell” function. For more details, refer to .

The motivation for the use of an AE was that boundary crossings usually contain turbulent magnetic fields on the magnetosheath side, whilst the majority of the intervals in the magnetosphere and solar wind contain smoother magnetic field profiles. It is expected that the AE would reconstruct the magnetosheath fields worst, compared to magnetospheric or solar wind fields. Thus, this feature could be leveraged to identify potential regions of crossings between distinct plasma regions.

1.1.2 Residual convolutional neural network (ResNet)

A plain Convolutional Neural Network (CNN) is typically used in a supervised learning setting like image classification. Convolution involves sliding a ‘kernel’ over an image to extract certain ‘features’ from the image to identify the class to which it belongs. Each layer in a CNN extracts a different level of features of the input image based on the kernel parameters. Eventually, the input image becomes a latent vector of a single dimension (similar to the output of the encoder part of the autoencoder 1.1.1). This latent vector is finally passed through a fully connected neural network in order to output a classification. In traditional image classification, these ‘kernels’ are hand-engineered. However, CNN automatically learns features in the image through gradient-based learning () using backpropagation (i.e., chain rule) to minimise the following loss functionwith respect to the parameters of the kernels, where y is the output vector from the final layer of the network with dependence on network parameters, whose length is the same as the number of classes in the classification problem, trueclass specifies the index of the element in y corresponding to the true class, and Wtrue class is the weight of the true class. These class weights are particularly useful when the dataset contains a strong class imbalance such that bigger weights could be applied to minority classes to improve their classification performance. This loss function is called the cross entropy loss which combines the negative log function with the softmax function (the arguments inside the log). To minimise this loss, the network parameters are adjusted based on the gradients such that the element of y which corresponds to the true class becomes larger. In other words, the smallest loss is achieved when the numerator in Eq. 2 is largest (i.e., the network predicts the true class with a high probability), whilst the biggest loss is seen when the numerator is smallest (i.e., the network predicts the true class with a low probability).

Deeper neural networks (i.e., more layers of neurons) can generally perform more complex mappings due to more tunable parameters. However, very deep neural networks are difficult to train due to the vanishing gradient problem in which gradients of the loss function with respect to the network parameters are close to zero and the network cannot minimise the loss function further (). The ResNet architecture developed by overcomes this by introducing ‘skipped connections’ which allowed successful training of deep neural networks. ‘Skipped’ connections are where the activation from one layer is directly added to another layer deeper in the network, as shown in Figure 1. This allows a deep neural network to continue tuning the parameters of the network to minimise the loss function and improve its classification performance. Mathematically, the skip-connections of a residual block are combined with L2-regularisation (i.e., a penalty term to minimise the values of the learnable parameters) and ReLU activation function, to allow for zero weights and biases for the extra (potentially redundant) layer of neurons in the network leading to zero contribution from this added layer, thus giving the residual block the ability to learn the identity function easily. That is to say, the activated output of the added layer is the same as the activated output of some previous layer connected by the skipped connection. Therefore, deeper networks with residual blocks do not hinder the learning ability of the overall network compared to shallower networks because it is easy for the residual block to produce the same output as prior to adding the extra layers.

FIGURE 1

. In this schematic, there are two convolutional layers acting on the input (x) followed by an element-wise summation operation with xvia the ‘skipped’ connection.

The motivation for using the CNN for boundary detection came from how the existing catalogue of crossings was created. The data were manually surveyed by human eyes looking for characteristic features of BS and MP as described in Section 2.2.1. This bodes well for automation with computer vision models due to the visual distinctive features seen in the plots of the data.

2 Materials and methods

The life-cycle for this project consisted of four main stages: 1) Scoping, where the project goal is defined. 2) Data, where the data source is defined, the pre-processing steps are established, the features and labels for the events of interest are defined, and a baseline performance is established (e.g., human-level performance for boundary classification). 3) Modelling, where the data is modelled with different algorithms and performing error analysis to understand areas of improvement both with the models’ parameters and also the data itself, 4) Deployment, where the system is used on new data and is monitored and maintained to ensure proper functioning. The algorithm implementations were done in Python and the deep learning models were built using the PyTorch framework ().

2.1 Scoping

The task of boundary detection can be broadly framed as a classification problem. Therefore, the scope of this project is to build an automated system that, given an interval of magnetic field and plasma data, outputs a list of candidate times corresponding to bow shock (BS) and magnetopause (MP) crossings.

2.2 Data

For this study, magnetic field and particle data from Cassini were used to detect BS and MP crossings. These measurements were obtained by the following two instruments on board Cassini: The dual-technique magnetometer (MAG) (), and the electron spectrometer (ELS) part of the CAPS (Cassini Plasma Spectrometer) instrument (). MAG provided the magnetic field measurements from which 1-min averaged data were used. The coordinate system was Kronocentric solar magnetospheric (KSM), where X points from the centre of Saturn to the Sun, Y points in the direction Ω × X (where Ω is Saturn’s rotational/magnetic dipole axis), and Z completes the right-handed coordinate system. Moments derived from 8-s averaged distributions in the ELS data provide electron density and temperature. The ELS instrument has eight anodes which sweep through 63 bins covering an energy range of 0.6 eV–28.25 keV in 2 s. The ELS is able to detect electron density as low as (). The field of view of each anode is 20° × 5° (thus 160° × 5° for all eight anodes). An actuator rotates the anodes back and forth covering sr of solid angle. The coverage may be increased if the spacecraft is rolling. For this study, we used anode 5 for all electron measurements as it has relatively large pitch angle coverage (angle of electron velocity relative to the local magnetic field) throughout an actuation cycle, compared to other anodes.

Cassini provided 13 years of data from 2004 to 2017. The latest catalogue of crossings at Saturn produced by consisted of 2,118 MP crossings and 1,243 BS crossings, both of which were recorded as single timestamps, and were identified mainly using 1-min MAG data, but validated with CAPS electron data when available.

2.2.1 BS and MP crossing features

For the creation of the boundary crossing list, a range of visual characteristics can be seen in the MAG and CAPS datasets.

Bow shock (BS) crossings have the most distinct features in both MAG and CAPS data. It involves transitioning between solar wind (SW) on one side and magnetosheath (SH) on the other. The SW exhibits a quiet, low-magnitude interplanetary magnetic field (IMF) and relatively cold electrons ( eV). In contrast, the magnetosheath exhibits turbulent, enhanced IMF with typical field fluctuations such as mirror mode compressions () (which are often excited under sheath-like conditions) and heated ion and electron energy spectra ( eV). A spacecraft moving from SW into SH will often measure a clear increase in magnetic field strength, typically accompanied by a magnetic ‘overshoot’ (). In occasional cases where the magnetic features were unclear for a BS crossing (e.g., a rapid pair of BS crossings occurred around 2012-04-01 03:00:001), CAPS data would typically display a sharp change in both density and temperature of the plasma at BS crossings, see Figure 2 for examples. have shown that the magnetic overshoot is strongly correlated with the Alfvén Mach Number (MA) which depends on upstream field strength and solar wind dynamic pressure. The authors also point out that Saturn has the largest range of MA due to the highly variable upstream conditions, which could explain the large variety of BS crossing appearances in the data.

FIGURE 2

Magnetopause (MP) crossings can be identified by both a change in the nature of fluctuations and the direction of the magnetic field, such as those found on the Earth [e.g., ; ], and similar features are observed at Saturn. For inbound MP crossings, the field typically changes from the more turbulent fluctuations in the magnetosheath to the steadier field in the magnetosphere, accompanied by a rotation of the field to a southward (magnetospheric) orientation, and increased field strength. However, there may be cases where magnetosheath fields may not be turbulent (with a small standard deviation) such as during the MP encounters between 2005-08-15 12:00:00 to 2005-08-15 20:00:00 (Supplementary Figure S1). Furthermore, MP crossings with low magnetic shears (small change in field orientation across the MP) as found by may also be ambiguous using MAG data alone. In such cases, CAPS data would generally show a change from the steady electron energy spectra of the magnetosheath (higher density, lower temperature electrons) to the more variable magnetospheric populations (lower density, higher-temperature electrons), see Figure 3 for examples.

FIGURE 3

Typical speeds of Saturn’s magnetopause are of order 100 km/s (), which is of the same order as the estimated speed of Saturn’s bow shock (). For typical MP crossings of duration between 5-min to 10-min, this gives a thickness of roughly 0.5 to 1 RS (Saturn radii), or equivalent to to magnetosheath proton gyroradii (based on typical E = 100 eV, B = 1 nT), which is of the same order as the estimated MP thickness of thermal proton gyroradii at Earth (e.g., ). Typical magnetosheath electrons (E = 100 eV, B = 1 nT) have a gyroradius of rge ≈ 30 km which is more than three orders of magnitude smaller than the typical width of the MP current layer. Given a boundary that is much thicker than typical electron gyroradii, and that the MP is closed (i.e., no magnetic connectivity between magnetosheath and magnetosphere), electrons are usually unable to cross the MP boundary but instead flow tailward (downstream towards Saturn nightside) along the magnetosheath field lines. Thus, the MP current sheet separates well the magnetosheath electrons and magnetospheric thermal electrons at energies close to the modal energy. Despite this natural separation of electron populations by the MP boundary, test particle simulations by have shown that higher energy electrons from the Earth’s outer radiation belt can escape through a closed MP into the magnetosheath via gradient drift. They showed that the weaker the B-gradient, the higher the energy of electrons is required to escape into the magnetosheath: E.g., for a magnetic field gradient scale length of ∼ 17 RE along the magnetopause, the minimum kinetic energy for loss is ∼ 3 MeV. The large variety of MP crossings is likely due to the different plasma processes and evolving structures which may occur at the MP boundary such as electron heating associated with magnetic reconnection (; ), Kelvin-Helmholtz vortices, (), plasma depletion layers () and low-latitude boundary layers ().

2.2.2 Data preprocessing

The preprocessing pipeline provides a systematic way to process large spacecraft datasets for data-driven modelling.

The first part of data-preprocessing involved reducing the search scope for BS and MP boundary crossings. Sections of Cassini’s orbits were pre-selected based on the conservative estimates of the minimum and maximum standoff distances for the BS and MP boundaries (i.e., distance from the centre of Saturn to the subsolar point of the MP or BS). These standoff distances were found by fitting empirical models for BS () and MP () surfaces to pass through Cassini’s positions. Note that the polar flattening and dawn-dusk asymmetry coefficients from the Pilkington model were not used here (i.e., the assumed MP surface was axis-symmetric). The same fitting was done to the catalogue of crossings. From this result, the minimum and maximum nose standoff distances used for MP were 13 and 43 RS respectively, and the shock standoff distances were 16 and 51 RS respectively. These values were used to select orbital segments which captured all of the crossings in the catalogue. This produced a list of intervals with a cumulative total time of 4,178,770 min (∼ 8 years) out of the 13-year mission.

To further reduce the search space, the second preprocessing part used an autoencoder (AE) for unsupervised outlier detection. The input magnetic field vector values were scaled to between 0 and 1 for the purpose of training the neural network. The scaling is given by:

where X is the quantity of interest such as the magnetic field, min and max are the minimum and maximum of the quantity respectively, over the pre-selected intervals of data. The autoencoder algorithm has been used in other space physics applications such as finding anomalies in electron distribution functions (). Since the data were sequential, the layers of the AE consisted of long short-term memory (LSTM) units (). The dataset included windows of magnetic field data constructed from the pre-selected orbital segments from the first part of data-preprocessing. The sequence length for each window was 60 min at 1-min resolution, and the stride was set to 30 min. After removing the windows which contained missing data or ‘NaN’, the resulting shape of the dataset was (125553, 60, 4) where 125,553 was the total number of windows of magnetic field data, 60 was the sequence length, and 4 represented Bx, By, Bz and |B| (i.e., the three field components in KSM coordinates and the field magnitude).

After training the network with the adam optimiser () (which is suited for optimising systems with lots of parameters like neural networks), it was found that the AE was able to reconstruct the smooth persistent changes of each magnetic field component, however not the local smaller scale fluctuations. Field profiles containing rapid, large-amplitude fluctuations, or field rotations in one or more components, tended to have higher reconstruction loss. By calculating the median loss value for the entire dataset of 60-min intervals, it was used as a threshold to accept or reject each interval for potential boundary crossings. Figure 4 shows the reconstruction loss for the pre-selected intervals in 2016. Generally, it was found that intervals with high loss values were mostly associated with magnetosheath regions as expected, but also associated with most BS and MP crossings. In contrast, pure magnetospheric and solar wind intervals have relatively smoother field profiles and thus lower loss values.

FIGURE 4

The result of this step reduced the search space by 49% whilst retaining 97% of crossings in the latest catalogue (). For comparison, standard scaling (zero mean and unit variance) was applied to the same dataset to select windows of magnetic field profiles which had at least a single field component with a Z-score greater than three (i.e., three standard deviations from the mean of the 60-min interval). This method of filtering reduced the amount of data to search by 38% whilst only retaining 80% of crossings in the catalogue. This indicated that the LSTM AE method could offer more flexibility regarding outlier detection of sequential data.

2.2.3 Train, validation and test dataset

Figure 5 compares the BS and MP crossings between 2004 to 2012 and 2013 to 2016. It is apparent that many of the 2013–2016 crossings had much higher planetary latitudes than those between 2004–2012. This was due to increasingly higher inclination orbits towards the end of the mission, allowing Cassini to sample the magnetosphere at much higher latitudes. Around 80% of the crossings in the catalogue were found before the CAPS instrument was turned off, and 20% after it was switched off (between 2012-06-02 to the end of the mission in September 2017). It is crucial for learning algorithms to have consistent labels to train from because a noisy mapping between input data and output labels may lead to poor convergence towards the true underlying function. For traditional programmatic algorithms where rules are hard-coded, it is equally important to have a reliable ground truth dataset for evaluating the performance of the algorithmic detections.

FIGURE 5

The decision was thus made to train on data between 2004–2011 whilst the first half of the 2012 data were used for testing the algorithms, as validation with CAPS data was expected to produce more consistent crossing labels. For the remainder of the data, between 2012–06 to 2016-08, where crossings did not have CAPS data for validation, a MAG-only detection model was used.

For the CNN model, initially, the scope was simplified to a binary classification problem: Does the input interval contain a crossing or not? It was later modified to perform multiclass classification with classes ‘notCrossing’, ‘BS’, and ‘MP’. The CAPS and MAG data were prepared according to the following procedure. A list of 2-h time intervals with 30-min strides was produced. The magnetic field plot images had a fixed y-scale ranging from −10 nT to 10 nT. The CAPS-ELS spectrogram images had a fixed y-scale ranging from 0.6 eV to 28.25 keV in logarithmic scale consisting of the 63 energy bins of the CAPS ELS instrument. An illustration of both types of images is shown in Figure 8. This provided a dataset of 73,623 images of MAG and CAPS-ELS plots in total between the years 2004–2012. The class distribution for these images were: 66,513 (90%) notCrossing, 4,994 (7%) MP and 2,116 (3%) BS. This strong class imbalance was addressed by using class weights during model training as described in the cross entropy loss function (Eq. 2). The years used for training and validating the CNN were 2004–2011 with an 80:20 split respectively. A stratified splitting was used in which the data were shuffled to ensure that the class ratios were preserved in both the train and validation dataset. A histogram of the time intervals between consecutive crossings and a distribution of crossing epochs (on the Cassini mission timeline) for both the train and validation dataset are included in the Supplementary Material (Supplementary Figures S3, S4). For the test dataset, the remaining 2012 data with CAPS available were used. The nature of time-series data means that the train and test data should not be shuffled together. From a physical point of view, the equinox (2012) structure of Saturn’s current sheet and magnetosphere is quite distinct from that of distantly pre-equinox times (e.g., summer solstice). Hence an algorithm which performs effectively under this constraint would certainly be expected to perform just as well, if not better when applied to test cases drawn from the pre-equinox mission epoch. Using the results from the autoencoder data-preprocessing stage, the 2-h intervals from the training dataset were discarded if the corresponding interval of magnetic fields could be recreated with better than median reconstruction loss (i.e., a lower loss value) as they would likely not contain a crossing. This reduced the number of training images to 37,057.

To derive the final list of crossings, the start time of the first positive detection and the end time of the last positive detection was extracted from continuous positive detections of the 2-h windows. This ensured that the interval contained the crossing of interest. A single timestamp of the crossing could be estimated by taking the centre of the interval, but precise timings would still need to be extracted manually. In terms of spacecraft position, this interval is usually short enough that it appears as a single point in a typical spatial plot. However, this method of producing a final list of crossing times depended on the assumption that individual crossings were separated by a sufficient time such that consecutive 30-min strides would not continuously yield positive detections allowing the chain of positive detections to be broken, but this was not always the case.

2.3 Modelling

The next step in the pipeline was the modelling part in which algorithms were designed to perform the BS and MP classification in order to re-discover the catalogue of crossings.

Two different types of models were implemented to detect and classify boundary crossings. The performance of traditional threshold and modern deep learning techniques was compared to show the strengths and weaknesses of each (Section 3.1).

2.3.1 Threshold method

The threshold method was motivated by a similar use case to automate magnetopause detections at Earth (). Figure 6 (left) shows the magnetic field data with four field parameters for thresholding (bottom two panels). On the right, CAPS electron data is shown with four parameters based on density and temperature moments for thresholding (bottom two panels). MAG and CAPS parameter values were computed using two sliding windows of length 30-min with a fixed gap of 8 min in between (shown by the red squares in Figure 6).

FIGURE 6

A positive detection occurs when a fixed threshold is exceeded in all the parameters. To find the most suitable parameter thresholds which maximise the number of true crossings being discovered (recall) whilst also maximising the number of true positives (precision), Bayesian optimisation was used to ‘train’ the threshold model to maximise the F1 score over all the training data (2004–2011). The F1 score is defined as

It is a harmonic mean of precision and recall, meaning the F1 score is more sensitive to smaller values of precision (

P

) or recall (

R

). Precision, which measures how accurate are the predictions, is given by

i.e., the fraction of positive predictions (TP + FP) that is actually true (TP). Recall, which measures how good the model finds all the positives, is given by

i.e., the fraction of positive instances (TP + FN) that is correctly predicted (TP). Here,

TP

,

FP

, and

TN

represent true positive, false positive and true negative. The Bayesian optimisation routine was implemented using the Botorch package in

Python

. The outline of the procedure is as follows:

  • 1. The initial sampling set is the initial guess of parameter values to be optimised. For this study, the thresholds of the magnetic field and electron parameters were the parameters to guess.

  • 2. Black-box problem evaluation is performed by looping through the dataset using this set of parameter thresholds and the desired target metric is evaluated.

  • 3. A Gaussian process (GP) would predict what the target metric would be for other input parameter thresholds.

  • 4. Evaluate the acquisition function to decide what input parameters to test next. This process uses a Monte-Carlo sampler. For example, to minimise some metric, the lower confidence bound acquisition function a(x) = f(x) − κσ(x) can be used where κ is a hyperparameter of the optimisation problem, f(x) is the mean of the GP, σ is the standard deviation at input x.

  • 5. The next point to evaluate the target will be at arg minx (a(x)). i.e., the parameter thresholds which would decrease (or increase) the target function (depending on the goal of the optimisation).

  • 6. Iterate until convergence, that is when the target function no longer improves for a consecutive number of iterations. Typically, 100 loops of optimisation were found to work well.

The classification between BS and MP is further determined from the windowed statistics of each interval. A big drawback of using the threshold method with magnetic field data was the existence of a significant number of MP crossings with low magnetic shear () meaning that there may not be a sufficient ratio in Bzr,SP/Bzr,SH. Despite the use of four criteria in the ‘thresh-mag’ method, the precision remains low (i.e., large number of false positives).

2.3.2 ResNet18: Convolutional neural network

The convolutional neural network (CNN) method for boundary classification was motivated by how the existing catalogue of crossings was created. The data were manually surveyed by human eyes looking for characteristic features of BS and MP as described in Section 2.2.1. This bodes well for attempting automation with computer vision models. The model architecture consisted of two parts: a feature learning network and a classification network. The ResNet18 was used for the first part with 18 convolutional layers, followed by a fully connected neural network with two layers for the second part. More details of the model architecture can be found in Section 1.3 of the Supplementary Material. The number of training epochs was set to 30 but generally it was found that training curves plateaued around 10 epochs.

Figure 7 shows an input image of the CAPS electron energy spectrogram passed through the CNN giving output ‘crossing’ or ‘notCrossing’. Similar to how the four parameters (or features) for the threshold method were created based on input MAG or CAPS time-series, a CNN automatically finds discriminative features from the input image by training with the ground truth labels for each plot.

FIGURE 7

Both the threshold and CNN models would accomplish the task of automation in principle because they were designed to look for patterns commonly found in BS and MP crossings. A natural question to ask is: why did the algorithm produce a particular output? Can the model outputs be explained?

2.3.3 Model explainability

For the threshold method, it was obvious why a prediction was made based on the values of the four parameter thresholds which discriminate a crossing from a non-crossing.

For CNN, the Grad-CAM technique () was used to visually explain the neural network’s output. This technique overlays a heatmap on top of an image of interest to indicate pixel regions which are most discriminative for the output class. The values which make up the heatmap are a linear combination of the activation function value in each channel in the last layer, weighted by the gradient of the loss with respect to the parameters in the last convolutional layer.

Figure 8 shows an example of Grad-CAM applied to MAG and CAPS plots using the implementation by . The red regions (or equivalently regions of concentrated contour lines) highlight the most important parts of the image considered by the final layer of the CNN. Experiments were performed using Grad-CAM on a series of BS CAPS plots striding forward in time in steps of 6 min. It was observed that for the different input images, the red region tracked well where the discontinuity was, which mimicked what human eyes would focus on for making predictions. This was a good indication that the neural network was focusing on the right features in the image to generate the correct classification.

FIGURE 8

2.3.4 Error analysis

After training and evaluating the models, error analysis was performed to understand where the algorithms were making mistakes. One of the major problems found was the lack of label consistency in the existing crossing list. An example was found in a high latitude MP crossing in the interval 2009-02-10 17:13:00 to 2009-02-10 19:13:00 (Supplementary Figure S2); the timestamp for this event from independently derived, expert identified catalogues by and were 1 hour apart. The Bayesian optimised MAG and CAPS threshold methods predicted a crossing at around 18:00 which was between the two human labels, whilst the CNN model also predicted a crossing for this 2-h interval. Label inconsistency is particularly detrimental to supervised learning algorithms because its goal is to learn a mapping between the input MAG or CAPS data (X) and output label (y). A noisy set of labels would lead to a noisy mapping, thus low accuracy. Attempts were made to clean up the labels by using a set of clearer labelling instructions and also exclude samples which were ambiguous from the training data as these could deteriorate the performance of the final model.

2.3.5 Other potential automation techniques

Other techniques were explored using mathematical models of the MP boundary to design a series of physical checks to determine if the selected candidates were genuine BS, MP or neither.

Assuming that MP crossings were oriented similar to those predicted by an MP model [e.g., ], another method that was thought to be a good physical check was the use of minimum variance analysis (MVA) to determine the orientation of Saturn’s MP surface at the time of each crossing and compare it with the model normal. The angular difference between them could be used to double check the validity of the proposed crossing based on our physical knowledge of the MP boundary. In this physical check, for every candidate center crossing time, a series of window sizes (6, 10, 14, 20, 30, 40, 60) in minutes were used to calculate the MVA normal. An estimate of the smallest angle between the MVA normal and the model normal was found, and similarly between the MVA normal and the tangential discontinuity (TD) normal could also be made (). Crossings could be discarded if they exceeded a certain threshold of this angular difference. However, the orientation of the normal was highly dependent on the identification of intervals corresponding to the magnetopause current layer (MPCL) where the field direction persistently changes. The MPCL interval has to be done by eye currently and thus is not yet possible to automate. Furthermore, there was a significant number of cases where, even by eye, the identification of the MPCL interval was ambiguous, especially in cases where there was a low magnetic shear between the magnetospheric and magnetosheath magnetic fields. This physical check was discarded in the end as it did not offer any boost in the performance compared with more simple checks (such as using the magnetic field magnitude alone), whilst also requiring more computational cost.

Another technique to check whether the selected candidates were true MP crossings or not was to fit a magnetic pressure model using the existing list of magnetopause crossings assuming a dipole approximation. Using the functional form of the magnetopause given by () and applying pressure balance at the MP boundary, a value of β could be estimated for the candidate which can be compared with the distribution of β values found for genuine MP crossings. It was suspected that, due to the pressure balance nature of the MP boundary, events which were not genuine should have a predicted β which would be in the tail of the distribution for genuine MP crossings. However, the opposite was found to be true; many events which were not genuine crossings also had typical β values, within 1 standard deviation of the mean log(β) distribution from the MP crossing list. Thus, this physical check was not used.

2.4 Deployment

The rapid inference time of the CNN model makes it a suitable candidate for usage onboard the spacecraft. The ResNet18 model has a size of 42.8 MB which is small compared to the onboard storage of 2 Gb (gigabits) in the form of dynamic random access memory (DRAM) on Cassini. However, the actual inference times may differ depending on the availability of hardware acceleration onboard the spacecraft. Compression techniques such as pruning and quantization of trained models could also be leveraged to significantly decrease the overall resource requirements for deploying such networks on mobile devices with limited resources (). Furthermore, as the model inputs are JPEG or PNG images of the data plots, it requires minimal processing, unlike other detection methods. After deployment, the performance of the system would be continuously monitored by the human-in-the-loop to ensure data drift or concept drift are not affecting the system. Data drift occurs when the input distribution is changed relative to the training data. This could be drastic changes to the spacecraft orbit to monitor a different region of space which changes the input data distribution. In this case, the model should be retrained with the inclusion of the new data and corresponding labels. Concept drift occurs when the mapping between input and output changes. This could be due to changes in the sensitivity of the instruments during the space mission, such that the same phenomena now correspond to different instrumental measurements. Therefore, human-in-the-loop is still crucial to ensure the proper long-term functioning of the automated system.

3 Results and discussion

The results of this study are reported using precision, recall and F1 scores for corresponding models investigated. These metrics are summarised in Table 1 for the threshold and CNN models. The performance scores are relative to the ground truth provided by boundary crossing list. However, these performance metrics may differ upon further refinement of the crossing list. At the time of the current study, it was found that the cnn-caps outperformed all other methods based on the recall (88.7%) and F1-score (72.5%) metrics.

TABLE 1

ClassifierPrecisionRecallF1-score
thresh-mag48.960.153.9
thresh-caps73.868.370.9
thresh-mag-caps80.612.621.8
cnn-mag59.375.666.5
cnn-caps61.488.772.5

Performance comparison for different models. Precision (P) is the % of predictions which are correct. Recall (R) is the % of ground truth which are predicted correctly. F1-score is the harmonic mean of precision and recall (Eq. 4). Note that the tolerance for correct classification for ‘thresh-’ classifiers was set at ± 60 min from the ground truth crossing times. The bold values represent the model which achieved the best score for that specific metric.

3.1 Model comparison: Performance

The performance of the two methods was expected to be different due to the difference in the locality with which features were generated. The threshold method extracted features using two 30-min windows with a fixed gap of 8 min whilst the CNN method extracted features from a 2-h window.

Considering the threshold method, when optimising for the F1-score (Eq. 4) on a global scale (i.e., evaluating the performance using all crossings from all years), the thresh-caps method generally produced consistently better performance metrics across the years 2004–2012 than thresh-mag as seen in Figure 9. Further experimentation was done such as ensembling the MAG and CAPS threshold features together. This had the expected result of massively improved precision for some years compared to the magnetic-field-only method, exceeding the recall in all years (Figure 9C). The amount of improvement varied across the different years of orbits, in some cases doubling from 30% to 60% such as in the year 2009, whilst other years the improvement was more modest from 60% to 62% such as in the year 2005. However, the recall naturally dropped significantly due to more criteria to satisfy to make a positive detection, reducing the number of positive detections. Another problem associated with this method was the fact that the thresholds were picking up both BS and MP. This was not unexpected as BS crossings typically have even larger values in the parameters considered thus more easily satisfying the thresholds set for MP crossings. There was no single way to separate the two types of crossings using thresholds alone due to the large variations of both types of crossings. There were attempts to further refine the classifications using the magnetic field magnitude as it was one of the biggest differentiating factors between BS and MP crossings. However, the issue was still the sheer number of false positive detections that were retrieved using the threshold method. This lead to poor precision when considering the retrieval of a single class of crossing.

FIGURE 9

An experiment was conducted to optimise the F1-score for different location sectors to investigate the dependence of the threshold method on the crossing location. The sectors were defined based on local time (DAWN 3 h–9 h, DAY 9 h–15 h, DUSK 15 h–21 h) and absolute latitude (LOW 0°–30°, MID 30°–60°, and HIGH 60°–90°). The majority (92%) of the true BS and MP crossings between 2004–2012 were in the LOW latitude bins (across all local times), with a small percentage (8%) in bins of DAYMID, DUSKMID and DUSKHI. For the years 2013–2016, 69% of true crossings were in the LOW latitude bins, and the remaining 31% were distributed amongst the DAWNMID, DAYMID, and DUSKMID bins.

By performing Bayesian optimisation for each bin, a set of thresholds was obtained for each bin (Figure 10). It was found that there was large variability in performance across different years for each bin, which indicated that a threshold which does well for 1 year may not be applicable for another. This is likely due to changing conditions from the Sun, changing spacecraft radial distance and other plasma processes which could change the nature of the boundary crossings. For dusk crossings, the magnetodisc plasma sheet could expand more due to solar wind direction being the same as corotation flow, leading to less turbulent conditions. Therefore, the ‘typical’ features of an MP transition may not be as common. There could also be lots of genuine partial crossings which are being picked up but that may not be in the ground truth (i.e., large number of false positives), lowering the precision (Eq. 5). Bins with fewer crossings were found to perform better likely because the thresholds were over-fitted to just capture those few crossings. Bins with more crossings (e.g., in the LOW latitude bin) have lower performance as the single set of optimised thresholds fails to capture the variety of crossings observed at low latitudes.

FIGURE 10

When considering magnetic-field-only detections, the worst performing local time sector was dusk, likely due to missed partial crossings and or more false positives. It may also be that the magnetic fields are more dynamic over timescales similar to an MP crossing, leading to less well-defined transitions. The lack of difference between either side of the transition is particularly detrimental to the threshold method given that it uses the ratios of quantities from two windows of data. The year 2007 was particularly problematic when trying to define consistent crossing times. However, due to a large number of detections, it was unfeasible to perform an error analysis of each positive detection as was done for the CNN method.

Considering the CNN method, given that the cnn-caps model outperformed other models in the binary classification task, a multiclass cnn-caps model was then chosen to be trained in order to classify 2-h intervals of electron spectrogram data as ‘BS’, ‘MP’ or ‘notCrossing’. The model performance on the training and validation dataset was tested with 10-fold cross-validation and was found to be consistent across all 10-folds for a given model architecture. This implies that the model was not too sensitive to the choice of samples in the training and validation sets. The results are summarised in Supplementary Table S1 in the Supplementary Material. The model variance, defined as the difference between training and validation error, could be used to indicate signs of over-fitting. The error is obtained from the mean cross entropy loss (Eq. 2) calculated during model training, ranging from 0 to 1, with 0 being perfect classification. From the cross-validation experiment, the average model variance was low at around 0.10 ± 0.04. This result implies that the model was not suffering from over-fitting to the training data. The model with the lowest validation error from cross-validation was used to evaluate the performance on the test dataset. To estimate uncertainty in the test performance metrics, 1,000 bootstrap samples of the test dataset with replacements were used (). The histograms of precision, recall, and F1 for each class are shown in Supplementary Figure S5 in the Supplementary Material from which uncertainties were estimated using the standard deviation (given the similarity to Gaussian distributions). Through error analysis of 196 misclassified samples, it was revealed that 48.5% were MP crossings, 26.5% were BS, 12.2% occurred in the magnetosheath, 11.7% occurred in the magnetosphere, 1.0% occurred in the solar wind. There were 15 samples which had missing CAPS data within the defined intervals whilst ground truth labels were provided using MAG data. These were removed from the test dataset which reduced the number of test samples from 3,032 to 3,017. Table 2 shows the performance of the multiclass cnn-caps model when the test dataset was corrected to include previously missed BS and MP crossings. The results indicate that the cnn-caps model was able to detect ‘notCrossing’ class with high precision and recall, BS crossings with very high precision but slightly lower recall, and MP crossings with reasonable precision and recall. The resulting F1 scores (Eq. 4) for the classes of interest were 92.1% ± 1.4% and 84.7% ± 1.9% for BS and MP crossings respectively.

TABLE 2

PrecisionRecallF1-scoreSupport
notCrossing0.979 ± 0.0020.991 ± 0.0020.985 ± 0.0022,624
BS0.995 ± 0.0040.857 ± 0.0250.921 ± 0.014195
MP0.860 ± 0.0230.834 ± 0.0260.847 ± 0.019198

Performance metrics of the cnn-caps classifier after correction of the labels in the previously misclassified samples. The support columns indicate the number of samples for each class. The uncertainty in each metric was estimated using the standard deviation of 1,000 bootstrap samples of the corrected test dataset evaluated using the same model.

The threshold method is intuitive for event detection but it lacks the flexibility due to fixed thresholds to capture events especially when the variety of crossings is large, even within the same type of boundary, such as MP crossings. On the other hand, neural network models have enough parameters to offer more flexibility to find a wider range of events without over-fitting.

One of the major advantages of neural network models is that once the algorithm is trained, the inference speed is extremely fast. For the sake of comparison, for the same 2-h interval, the trained cnn-caps model performs inference on the order of 10 ms on a laptop equipped with NVIDIA GeForce GTX 1650, whilst the thresh-mag model takes the order of 1s to predict whether there is a crossing, which is 100 times slower than the cnn-caps method. Therefore, in an onboard data selection scenario, it is advantageous to leverage the speed of neural networks in order to perform the first level of data selection before fine-tuning with other techniques such as manual inspection.

3.2 A new BS and MP crossings list for saturn

The benefit of having an automated system is that it can be used to scan through all the data without extra human effort. This allows the discovery of new events which could have been missed despite being obvious. For example, the interval between 2005-07-28 14:00:00 and 2005-07-28 16:00:00 had a data gap in the MAG data but was easily detected from CAPS data using cnn-caps.

To this end, a new comprehensive list of BS and MP crossings from Cassini have been identified with the help of the models developed in this study, building on the lists found by and . All new crossings added were ensured to be consistent with previously identified crossing directions. For example, an inbound MP crossing must be followed by an outbound MP crossing.

The new list contains 1349 BS crossings and 2539 MP crossings, representing an 8% and 20% increase compared to the original list with 1249 BS and 2124 MP, respectively.

The breakdown of the number of crossings across different years of the mission from Saturn-Orbit-Insertion in July 2004 to when the CAPS instrument was switched off in June 2012 is shown in Table 3.

TABLE 3

YearBSMP
20045129
2005287252
200612108
2007191560
200854303
20098200
201058411
2011244269
2012180194

Breakdown of the number of bow shock (BS) and magnetopause (MP) crossings in the new list of boundary crossings between years 2004–2012.

Interesting case studies could be discovered by inspecting through the positive detections. For example, Figure 11 shows a ‘crossing’ event recorded between 2012-05-14 05:00:00 and 2012-05-14 07:00:00 picked up by the CNN method that was not previously identified in any crossing list appeared to be a candidate K-H vortex encounter. This event was situated on the dusk flank near the equator. There was periodic sign change in By and striking electron and ion energization signature similar to that discussed in .

FIGURE 11

In a future study, there is potential to turn the CNN classifier into both a region and a boundary classifier, by altering the training labels with six classes: SW, BS, SH, MP, SP and Other. The ‘Other’ class can be thought of as an ‘uncertainty’ class which should be looked at by the ‘human-in-the-loop’, as well as the precise crossing times for each BS and MP crossing classified. One could also explore the possibilities of fine-tuning the classifier for boundary detection at other planets. Since BS and MP crossings at different planets share common magnetic field and plasma signatures (e.g., as described in Section 2.2.1), at least visually, the weights of the ResNet18 portion of the CNN classifier could be kept fixed, whilst the weights in the classifier ‘head’ could be fine-tuned by training on a consistently labelled crossings dataset for the planet of interest. This greatly reduces the number of learned parameters in the neural network, thus, significantly reduces the training time and the size of the dataset required.

ML algorithms can help automate a manual process. However, when the algorithm’s ability is not yet fully reliable, the degree of automation falls short of fully automatic detection. Nevertheless, having partial automation and keeping the human-in-the-loop can still hugely accelerate the process of crossing identification.

4 Conclusion

The key points of this study can be summarised as follows:

  • 1. Two methods for automating the detection of the bow shock and magnetopause crossings in Cassini data were implemented and compared: Threshold-based detection and convolutional neural network (CNN) classifier. Based on 2012 test data and the latest BS and MP catalogue at Saturn, the CNN approach outperformed the threshold approach when considering CAPS data. Cassini MAG and CAPS/ELS datasets were used as the data source. However, the methods demonstrated would also be applicable to other spacecraft missions with magnetic field and plasma data.

  • 2. It is possible to automate the detection of BS and MP crossings using magnetic field data and/or electron energy spectrograms as demonstrated with Cassini data at Saturn. However, it was found that for both methods the electron-only data model outperformed the magnetic-field-only model, for the period where both instruments did not have missing data. Combining both datasets lead to higher precision but lower recall as expected. For discovering more crossings, ‘thresh-mag’ could be used with higher thresholds to ensure a higher probability of correct identification of typical BS or MP crossing events. The ability to select specific types of events which exceed definitive thresholds is an advantage of the threshold method, which is not possible with the CNN model.

  • 3. The ResNet18 CNN model is small (42.8 MB) and once trained has fast inference times (of order 10 ms) which makes it suitable for on-board spacecraft data selection or performing large-scale boundary surveys in post-mission data analysis.

Statements

Data availability statement

The original contributions presented in the study are included in the article/Supplementary Material, further inquiries can be directed to the corresponding author.

Author contributions

IC wrote the code, analysed the results and wrote the main manuscript. NA and AS directed the various experiments. All authors reviewed the manuscript.

Funding

IC was supported by a UK STFC studentship hosted by the UCL Centre for Doctoral Training in Data Intensive Science (Grant Number ST/P006736/1). NA was supported by UK STFC Consolidated Grant Number ST/S000240/1 (UCL/MSSL-Physics and Astronomy Solar System). AS was supported by NERC grants NE/P017150/1 and NE/V002724/1. For the purpose of open access, the author has applied a Creative Commons Attribution (CC BY) licence to any Author Accepted Manuscript version arising.

Acknowledgments

The authors wish to thank Caitriona Jackman for thoughtful discussions and useful comments about this work. The Cassini MAG and ELS data are available from the Planetary Data System (http://pds.nasa.gov/).

Conflict of interest

The authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

Publisher’s note

All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.

Supplementary material

The Supplementary Material for this article can be found online at: https://www.frontiersin.org/articles/10.3389/fspas.2022.1016453/full#supplementary-material

Footnotes

1.^Timestamp notation: YYYY-MM-DD HH:MM:SS.

References

Summary

Keywords

Saturn’s magnetosphere, bow shock, magnetopause, automation, threshold anomaly detection, convolutional neural networks, explainable AI

Citation

Cheng IK, Achilleos N and Smith A (2022) Automated bow shock and magnetopause boundary detection with Cassini using threshold and deep learning methods. Front. Astron. Space Sci. 9:1016453. doi: 10.3389/fspas.2022.1016453

Received

11 August 2022

Accepted

20 September 2022

Published

20 October 2022

Volume

9 - 2022

Edited by

Fadil Inceoglu, National Atmospheric and Oceonographic Administration (NOAA), United States

Reviewed by

Artem Smirnov, GFZ German Research Centre for Geosciences, Germany

Suranga Ruhunusiri, The University of Iowa, United States

Updates

Copyright

*Correspondence: I Kit Cheng,

This article was submitted to Space Physics, a section of the journal Frontiers in Astronomy and Space Sciences

Disclaimer

All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article or claim that may be made by its manufacturer is not guaranteed or endorsed by the publisher.

Outline

Figures

Cite article

Copy to clipboard


Export citation file


Share article

Article metrics