# Estimation of Gross Primary Productivity (GPP)
## 2 Materials and Methods
### Extracting Phenology Indicators from GPP and VIs
#### 2.4.1 Filtering Methods  
The study area was characterized by long rainy and cloudy periods, mainly in the year 2016. For that reason, we selected three smoothing functions, whose in regions with a long period of cloudiness and a high atmospheric variability are well documented [28; 83; 84]: Savitzky-Golay (SavGol), Harmonic Analysis of Time Series (HANTS) and polynomial (Polyfit). The SavGol filter is a robust method to reduce efficiently the cloud and snow contamination in the time-series [84; 85]. It is a low-pass filter that smooths the time-series applying a polynomial regression function to \(x\) data points in a moving window [86]:  
\[f(t)=c_{0}+c_{1}t+\ldots+c_{n}t^{n} \tag{1}\]  
For all points within the time window, a polynomial function of \(n\) degree was solved. In this study, the window size and the degree of the polynomial fitting function have been defined for each time-series data (i.e., VIs and GPP). In every window, a new polynomial was fitted. Subsequently, the window moved to the next part of the input dataset, a new local polynomial function was fitted to the original data in this window, and a new data point was calculated. This process was repeated for all remaining time windows. The parameters used to smooth both VIs and GPP time-series are reported in Table 2. We obtained these parameters using Python 3.6 package scipy.signal and the function SavGol filter ([[https://scipy.org/](https://scipy.org/)]([https://scipy.org/](https://scipy.org/))). \begin{table}
\begin{tabular}{l c c c c c c} \hline \hline \multirow{2}{*}{**Method**} & \multicolumn{2}{c}{**2016**} & \multicolumn{2}{c}{**2017**} & \multicolumn{2}{c}{**2018**} \\ \cline{2-7}  & \(n\) & \(x\) & \(n\) & \(x\) & \(n\) & \(x\) \\ \hline \multicolumn{7}{l}{_SurGol_} \\ GPP & 4 & 111 & 1 & 111 & 6 & 111 \\ NDVI & 2 & 9 & 3 & 17 & 3 & 9 \\ EVI & 2 & 7 & 2 & 7 & 3 & 9 \\ MTCI & 2 & 7 & 2 & 11 & 3 & 9 \\ ChIRedEdge & 2 & 11 & 2 & 11 & 3 & 9 \\ MCARI & 4 & 9 & 2 & 11 & 3 & 9 \\ SIP & 3 & 7 & 3 & 9 & 3 & 9 \\ PSSR & 4 & 11 & 2 & 11 & 3 & 9 \\ gNDVI & 3 & 7 & 2 & 15 & 3 & 9 \\ _Polytt_ & & & & & & \\ GPP & 6 & & 5 & 6 & 6 \\ NDVI & 6 & & 6 & 6 & 6 \\ EVI & 6 & 5 & 6 & 6 & 5 \\ MTCI & 6 & & 6 & 5 & 6 \\ ChIRedEdge & 6 & & 5 & 6 & 6 \\ MCARI & 6 & & 5 & 6 & 6 \\ SIP & 6 & & 6 & 6 & 6 \\ PSSR & 5 & 6 & 6 & 6 \\ gNDVI & 5 & 3 & 5 & 5 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Parameters used for Savitzky–Golay (SavGol) and polynomial (Polyfit) methods for filtering time-series of Gross Primary Productivity (GPP) and VIs (see VIs definitions in Table 1) per each year. \(n\)—degree of polynomial function; \(x\)—data points in the moving window used for the SavGol method. HANTS filter employs the Harmonic Analysis of Time Series, adapted from the fast Fourier transform [87]. A least-square fit was applied iteratively on all data points of each time-series, the observations were compared to the fitting curve and outliers removed from the time-series [88]. This analysis was done using the HANTS script in MATLAB 6.3 (MathWorks Inc., Sherborn, MA, USA) developed by [PERSON] ([[https://mabouali.wordpress.com/projects/harmonic-analysis-of-time-series-hants/](https://mabouali.wordpress.com/projects/harmonic-analysis-of-time-series-hants/)]([https://mabouali.wordpress.com/projects/harmonic-analysis-of-time-series-hants/](https://mabouali.wordpress.com/projects/harmonic-analysis-of-time-series-hants/))). For both GPP and VI time-series we used the following default parameters: valid range minimum = 0.0; fit error tolerance = 5.0; degree of over determinedness = 1; delta to suppress high amplitudes = 0.1. The length of the base period was settled to 2. For GPP, the total number of the time-series and the number of frequencies to be considered above the zero frequency were fixed to the total number of days in a year (365 or 366). For VIs, these two last parameters corresponded to the number of Sentinel-2 images available for each year.