# Trends from 30-Year Observations of Downward Solar Irradiance in Thessaloniki, Greece
## 2 Data and Methodology
### The Clear Sky Identification Algorithm  
To calculate the reference clear-sky \(\mathrm{SDR}_{\mathrm{CSef}}\), we used the \(\mathrm{SDR}_{\mathrm{Haurwitz}}\) derived by the radiation model of [PERSON] [22] (Equation (1)), adjusted for our site:  
\[\mathrm{SDR}_{\mathrm{Haurwitz}}=1098\times\cos(\theta)\times\exp\biggl{(}\frac {-0.059}{\cos(\theta)}\biggr{)} \tag{1}\]  
where \(\theta\) is the SZA. The adjustment was made with a factor \(a\) (Equation (3)), which was estimated through an iterative optimization process, as described by [PERSON] and [PERSON] [23] and [PERSON] and [PERSON] [17]. The target of the optimization was the minimization of a function \(f(a)\) (Equation (2)) and was accomplished with the algorithmic function 'optimise', which is an implementation based on the work of [PERSON] [24], from the library'stats' of the R programming language [25]. \[f(a)=\frac{1}{n}\sum_{i=1}^{n}(\mathrm{SDR}_{\mathrm{CSid},i}-a\times\mathrm{ SDR}_{\mathrm{testCSef},i})^{2} \tag{2}\]  
where \(n\) is the total number of daylight data, \(\mathrm{SDR}_{\mathrm{CSid},i}\) are the data identified as clear-sky by CSid, \(a\) is a site-specific adjustment factor, and \(\mathrm{SDR}_{\mathrm{testCSef},i}\) is the SDR derived by any of the tested clear-sky radiation models. The optimization and the selection of the clear-sky reference model was performed on SDR observations for the period 2016-2021. During the optimization, eight simple clear-sky radiation models were tested (namely, Daneshyar-Paltridge-Proctor, Kasten-Czeplak, Haurwitz, Berger-Duffie, Adnot-Bourges-Campana-Gicquel, Robledo-Soler, Kasten, and Ineichen-Perez) with a wide range of factors. These models are described in more detail by [PERSON] et al. [18] and are evaluated by [PERSON] and [PERSON] [17]. We found that [PERSON]'s model, adjusted with the factor \(a=0.965\), yields one of the lowest root mean squared errors (RMSE), and the procedure manages to successfully characterize the majority of the data. Thus, our clear sky reference is derived by Equation (3):  
\[\mathrm{SDR}_{\mathrm{CSef}}=a\times\mathrm{SDR}_{\mathrm{Haurwitz}}=0.965 \times 1098\times\cos(\theta)\times\exp\biggl{(}\frac{-0.057}{\cos(\theta)} \biggr{)} \tag{3}\]The criteria that were used to identify whether a measurement was taken under clear-sky conditions are presented below. A data point is flagged as 'clear-sky' if all criteria are satisfied; otherwise, it is considered as 'cloud-sky'. Each criterion was applied for a running window of 11 consecutive one-minute measurements, and the characterization was assigned to the central datum of the window. Each parameter was calculated from the observations in comparison to the reference clear-sky model. The allowable range of variation is defined by the model-derived value of the parameter multiplied by a factor plus an offset. The factors and the offsets were determined empirically by manually inspecting each filter's performance on selected days and adjusting them accordingly during an iterative process. The criteria are listed below, together with the range of values within which the respective parameter should fall in order to raise the clear-sky flag:  
1. Mean of the measured \(\overline{\text{SDR}}_{i}\) (Equation (4)): \[0.91\times\overline{\text{SDR}}_{\text{CSref},i}-20\,\text{Wm}^{-2}<\overline{ \text{SDR}}_{i}<1.095\times\overline{\text{SDR}}_{\text{CSref},i}+30\,\text{Wm} ^{-2}\] (4) 2. Maximum measured value \(M_{i}\) (Equation (5)): \[1\times M_{\text{CSref},i}-75\,\text{Wm}^{-2}<M_{i}<1\times M_{\text{CSref},i}+75 \,\text{Wm}^{-2}\] (5) 3. Length \(L_{i}\) of the sequential line segments, connecting the points of the 11 SDR values (Equation (6)): \[L_{i}=\sum_{i=1}^{n-1}\sqrt{\left(\text{SDR}_{i+1}-\text{SDR}_{i}\right)^{2}+ \left(t_{i+1}-t_{i}\right)^{2}}\] (6) \[1\times L_{\text{CSref},i}-5<L_{i}<1.3\times L_{\text{CSref},i}+13\] (7) where \(t_{i}\) is the time stamp of each SDR measurement. 4.