## 2 Materials and Methods
### Chemometric Analysis  
PLS calibration models were developed based on Raman spectra of mixed liquor samples (Raman spectroscopic method) and on respective standard measurements of the selected parameters (reference analytical method). Commercial OPUS Quant2 software, version 8.2.28 (Bruker Optik GmbH, Leipzig, Germany), was used for spectral data pre-processing and a chemometric PLS calibration model development for each selected parameter.  
Raman spectral pre-processing is crucial to remove undesired systematic variations in the spectral data that are unrelated to the analytical information, consequently degrading the predictive ability of a calibration model. To extract the spectral information related to each one of the parameters considered, the corresponding PLS calibration models were optimized in terms of spectral range, pre-processing method and the number of factors or latent variables (LVs) employed, a maximum of 10 LVs being considered.  
The optimization of calibration models was performed using the OPUS Quant2 optimization tool, which evaluates the combination of different data pre-processing strategies with various spectral ranges, resulting in more than 1000 tested combinations [37]. Specifically, a Raman shift region defined by the user is divided into 10 equal subregions and the best combination of subregions is iteratively searched by the optimization tool. Mean-centering was applied as the default in every pre-processing strategy, in addition to the eleven default pre-processing strategies, which include no further spectral data pre-processing, constant offset elimination, straight line subtraction (SLS), vector normalization (standard normal variate; SNV), minimum-maximum (Min-Max) normalization, multiplicative scatter correction (MSC), first derivative (1 st Der) and second derivatives (17 smoothing points used as default), as well as the combined methods 1 st Der + SLS, 1 st Der + SNV and 1 st Der + MSC.  
A full cross-validation (leave-one-out) procedure was adopted to determine the optimal number of LVs, based on the minimum value obtained for the root mean square error of cross-validation (RMSECV). The prediction performance and accuracy of the PLS models were evaluated based on the coefficient of determination of cross-validation (R\({}^{2}_{\text{CV}}\)), the RMSECV and the residual prediction deviation of cross-validation (RPDCV). The RPD value indicates specifically whether a PLS model has insufficient prediction quality (RPD < 2.5) or whether it can be used as a rough screening method (2.5 < RDP < 3), as a good screening method (3 < RPD < 5), as a quality control method (5 < RPD < 8) or as an excellent method for analytical tasks (RPD > 8) [38]. Bias was also considered, corresponding to the systematic averaged deviation between the predicted and the reference values. Overall, robust, reliable, and unbiased calibration models are characterized by combining low values of RMSECV, high R\({}^{2}_{\text{CV}}\) and RPD\({}_{\text{CV}}\), a bias value close to zero, as well as a low number of LVs in order to avoid overfitting the model. Depending on the studied parameter, some samples were excluded from the calibration set during PLS model development, either in the case of no detectable amounts of the analyte in a sample (null concentration determined by the reference method) or when the associated measurement was considered an outlier based on the Mahalanobis distance. The spectra of samples containing null concentration of a parameter were not included in the PLS model in order to avoid an imbalanced calibration model focused on the concentration region around zero, instead of the concentration range of interest for each parameter. Since NO\({}_{2}\) was not detectable in any of the analyzed samples, PLS models were not developed for this parameter.