# MEC: A Mesoscale Events Classifier for Oceanographic Imagery
## 4 MEC Explained  
### Spaghetti Plot Generation  
The data files described in Section 2 are georeferenced, meaning that a satellite image with timestamp \(t\) contains several SST readings, each associated with a point on the surface of Earth. In the following we denote by \(T(t,\phi,\lambda)\) the recorded SST at time \(t\) at the point with latitude \(\phi\) and longitude \(\lambda\). Note that, if we choose random values for \(t\), \(\phi\), and \(\lambda\), it is possible that the corresponding SST value \(T(t,\phi,\lambda)\) is not defined: this depends on the available data in the satellite files. Given a target area \(A=[\phi_{\min},\phi_{\max}]\times[\lambda_{\min},\lambda_{\max}]\) and a time interval \(\tau=[t_{\text{start}},t_{\text{end}}]\), we illustrate here the steps used to produce a spaghetti plot. 1. Choose a resolution \(r>0\), such that the numbers \(\ell=(\phi_{\max}-\phi_{\min})/r\) and \(m=(\lambda_{\max}-\lambda_{\min})/r\) are integers (typical values for \(r\) lie between 0.01 and 0.25 degrees in latitude and longitude) and divide the area \(A\) in \(\ell\times m\) squares \[a_{i,j}=[\phi_{\min}+ir,\phi_{\min}+(i+1)r]\times[\lambda_{\min}+jr,\lambda_ {\min}+(j+1)r]\] with \(i=0,\ldots,\ell-1\) and \(j=0,\ldots,m-1\). 2. For each satellite image with timestamp \(t\) and for all squares \(a_{i,j}\), compute the spatial average of the SST at time \(t\) in the square. This step is performed to mitigate the effects of possible outliers and noise within the square. Formally, let \(X_{i,j}(t)\) be the set of points with coordinates \((\phi,\lambda)\in a_{i,j}\) that have a recorded SST in the image, i.e., \[X_{i,j}(t)=\{(\phi,\lambda)\in a_{i,j}\mid T(t,\phi,\lambda)\text{ is recorded}\};\] then for each \(t\), \(i\), and \(j\) compute \[\overline{T}_{i,j}(t)=\frac{1}{|X_{i,j}(t)|}\sum_{(\phi,\lambda)\in X_{i,j}(t) }T(t,\phi,\lambda)\] where \(|\cdot|\) denotes the cardinality of a set. Notice that \(X_{i,j}(t)\) may be empty--in that case, we leave \(\overline{T}_{ij}(t)\) undefined. We choose to not define \(\overline{T}_{i,j}(t)\) also when \(|X_{i,j}(t)|\) is  
Figure 2: **Left**: depth map of the Atlantic Ocean around the southwestern coast of the Iberian peninsula. The arrows show the direction of the water currents during a mesoscale event. **Right**: examples of SST maps with recognisable events patterns (highlighted in the rectangles). too small, because in that case the lack of a sufficient amount of data within \(a_{i,j}\) makes the mean estimation unreliable. 3. Let \(t_{1},\ldots,t_{N}\) be the timestamps of the images belonging to the time interval \(\tau\). For each square \(a_{i,j}\) compute the time series \[p_{i,j}=\{(t_{k},\overline{T}_{i,j}(t_{k}))\mid k=1,\ldots,N\text{ such that }\overline{T}_{i,j}(t_{k})\text{ is defined}\}.\] (1)
4. The spaghetti plot is obtained by plotting all the time series \(p_{i,j}\) simultaneously within the same time-temperature coordinate system. Each square \(a_{i,j}\) and the plot of the corresponding series \(p_{i,j}\) is colour-coded, so that it is easier to recognise different SST trends in different parts of the area \(A\). The above steps integrate and further detail the generation of spaghetti plots described in [41,44]. After having tested different values of the parameters involved in the spaghetti plot generation process, the following choice represented a satisfactory trade off between the computational effort (more details about this in Section 5) and the classifier resolution requirements, that need to be properly tuned to ensure a correct features extraction process (described in Section 4.2):  
* Resolution \(r=0.25^{\circ}\);
* Time interval \(\tau=15\) days, which is the typical temporal scale at which the sought mesoscale events appear and fade;
* Data abundance threshold (used in step 2 above): we require \(|X_{i,j}(t)|\geq 100\) for \(\overline{T}_{i,j}(t)\) to be defined (i.e., about 16% of the expected amount of data in a square). Figure 3 introduces an example that will be discussed step by step in the following.