# Enhancing Photovoltaic Power Predictions with Deep Physical Chain Model
## 2 Methodology and Resources
### Features Engineering
#### 2.4.5 Deep Chain Model
We define abnormal data as zero power values when GHI is greater than \(15\,\mathrm{W}/\mathrm{m}^{2}\). Figure 7: Brief overview of our proposed chain model for power photovoltaic forecasting. To structure the time series, key parameters are established: window size \(w=4\) timestamp is initially set somewhat arbitrarily, serving as a starting point to facilitate data handling. Forecast horizon \(h=4\) timestamp is chosen to align and compare with the methodologies used in the referenced papers [21; 22]: number of input variables \(v_{i}\), amount of input metadata \(m_{i}\), and number of previous chain blocks \(v_{o}\). It should be remembered that each timestamp is equivalent to 15 min, so considering 4 timestamps would correspond to one hour. These parameters are consolidated into the input vector with length \(N\) given by Equation (4) and illustrated in Figures 8 and 9:  
\[N=wv_{i}+2 hv_{o}+(h+m_{i}) \tag{4}\]  
The green boxes represent the various inputs and exogenous variables used in the forecasting model, including Local Measurement Data (LMD), Metadata, Numerical Weather Prediction (NWP), and exogenous factors such as solar position. The blue boxes indicate the outputs of the model's prediction results. The timeline marked from \(t=-60\) min to \(t=60\) min shows the temporal framework, where data is used for both historical input and future prediction targets. The selection of variables depends on their significance for forecasting the horizontal irradiance, the plane of the array, and the generation of photovoltaic power. We have chosen to incorporate the exogenous variables \(\cos(\theta_{\text{zenith}})\) and \(\sin(\theta_{\text{azimuth}})\) across all proposed models, as they provide a comprehensive description of solar movement throughout the day. It is crucial to understand that the \(\theta_{\text{zenith}}\) angle denotes the inclination between a point in the sky and the vertical over a specific location, while the \(\theta_{\text{azimuth}}\) angle is the measure between a point on the horizontal plane and a fixed reference, usually geographic North. These variables are obtained using the SPA algorithm. Additionally, metadata such as the inclination angle of the solar panel are included to improve the accuracy of the model. Table 6 summarizes all these variables, which are tailored according to the specific segment of the prediction chain. Figure 8: Framework of the data preparation process. Figure 9: General order of the inputs for the Transformer Bi-LSTM model. The symbol \({}^{*}\) represents data that are not added to every block in the chain. Stations 0, 1, 2, 3, 4, 5, and 8 are chosen for the formation and evaluation of the blocks of the model chain, as well as the calibration of the variable \(\mathrm{NWP_{GHI}}\). This selection is based on previous studies to facilitate comparisons with [21; 22]. The measurements of each station are sorted chronologically. Three days are assigned for training, one for validation and one for testing, for each block of five days. This distribution guarantees a climatic balance in the evaluations and is consistent with previous studies [22]. The final sizes of the datasets are 55,280, 18,216, and 18,206 for training, testing, and validation, respectively. To evaluate the effectiveness of this methodological proposal, a set of metrics commonly adopted in research on photovoltaic power generation forecasts is used: these are specifically MAE, RMSE, and \(R^{2}\). Finally, the implementation is performed on a system with an Intel i7, 16 GB of RAM and an NVIDIA GTX1660-TI GPU. Python (v3.10) and PyTorch (v2.0) [39] are used as the framework with a batch size of 1000. The Adam optimizer is adopted with an initial learning rate of 0.01 and a learning rate scheduler that reduces it by a factor of 0.10 every 80 epochs. After 120 training epochs, satisfactory convergence is achieved without overfitting. The loss function L1 Loss (MAE) is chosen, given its suitability for predictive tasks. The training takes approximately 10 min.