1 Introduction

In developing nations, there is a growing recognition that the integration of intermittent renewable energy sources into the energy mix necessitates a holistic approach. This approach includes the collaborative development of energy storage solutions, the implementation of smart grids with efficient energy management systems, and the use of sustainable energy forecasting tools for both energy consumption and production.

Progress in these three critical areas is poised to significantly enhance the predictability and manageability of solar energy sources. This, in turn, will lead to a reduction in the economic costs associated with unexpected variations in solar radiation. [1,2,3].

To effectively assess energy storage capabilities, optimize energy systems, and mitigate potential limitations of photovoltaic (PV) systems, it is essential to conduct solar radiation forecasting for its various components, including global, direct, and diffuse radiation. This forecasting process not only aids in tailoring energy systems to meet specific needs but also facilitates enhancements in electricity market transactions, promoting more efficient commercial exchanges [4]. Improving Smart Microgrids (SM-Grids) presents a substantial challenge. These grids employ advanced technologies to enhance the effectiveness and dependability of generating and distributing electricity. They play a pivotal role in facilitating the seamless integration of renewable energy sources into diverse power generation methods. Furthermore, SM-Grids are instrumental in efficiently managing fluctuations in both power generation and consumption [3].

Energy management algorithms often use estimated production and distribution data to optimize the scheduling of battery charge and discharge, as well as to efficiently distribute electrical power [5]. An enhanced energy management method, employing mixed-integer linear programming (MILP) and taking into account assumed actions based on forecasted data, was applied to an SM grid equipped with photovoltaic (PV), battery, and hydrogen storage [6].

Solar radiation is indeed a crucial factor in solar power generation, and forecasting it accurately is essential for optimizing the efficiency of solar energy systems. Solar radiation forecasting has been extensively studied in the literature to help with the planning and operation of solar power installations. Researchers have developed various methods and models for forecasting solar radiation, considering factors such as weather conditions, time of day, and geographic location.

Different approaches to forecasting solar radiation can be categorized into three main groups: physical, statistical, and machine learning methods. In the physical method, forecasting are generated using numerical weather prediction models, which are better suited for longer-term forecasts, typically spanning 1 to 2 days. On the other hand, the statistical method relies on historical time series data, which is simpler than the physical approach. However, the performance of the statistical method is often constrained because it's based on the persistence or stochastic nature of time series data, while solar irradiance data exhibits non-stationary characteristics. The machine learning method, which falls under the domain of artificial intelligence, has the capability to learn from datasets and establish a non-linear relationship between input and output data without requiring explicit programming. This paper primarily concentrates on the utilization of machine learning algorithms for predicting solar irradiance.

Sharma et al. [7] introduced a mixed approach called the wavelet neural network (WNN) for forecasting solar irradiance in the tropical region of Singapore, with forecasts made for both the next hour and the next 15 min. The performance of the WNN model was assessed and compared against several benchmark forecasting methods, including persistence, ETS (error, trend, and seasonality), ARIMA (autoregressive integrated moving average), and ANN. The results of the study indicated that the WNN model outperformed the benchmark methods across all performance metrics, suggesting that it provided more accurate and reliable forecasts of solar irradiance in the given tropical region. This suggests that the WNN approach may be particularly effective for predicting solar irradiance in this specific context, potentially offering improved precision and utility compared to other traditional and statistical methods. Cao et al. [8] have devised an approach for the day-to-day prediction of solar irradiance. They achieve this by amalgamating the use of an ANN and wavelet analysis. This method leverages historical day-to-day records of solar irradiance to make accurate forecasts, demonstrating the potential of combining these two techniques for improved solar irradiance predictions. Ahmad et al. [9] employed autoregressive recurrent neural networks (AR-RNN) that take into account both exogenous inputs and weather variables to generate a one-day ahead forecast of hourly global solar irradiation specifically for New Zealand. This approach highlights the use of advanced neural network models to predict solar irradiation, incorporating external factors such as weather variables to improve the accuracy of their forecasts. B. Belmahdi et al. [10] used ARIMA and ARMA models to forecast one month ahead of the mean monthly daily global solar radiation. They also explored Multi-Period Ahead forecasting, looking at one, two, and three months into the future to make data-driven predictions for a large-scale solar component. Their results identified ARIMA(0,2,1) and ARMA(2,1) as suitable models based on their statistical performance accuracy. The chosen model with the lowest error can effectively forecast future output in locations with similar weather conditions. Srivastava et al. [11] set out with the primary goal of predicting solar radiation for a range of forecasting horizons, spanning from 1 day ahead to 6 days ahead, with a focus on hourly data. They employed several different models, including MARS (multivariate adaptive regression splines), CART (classification and regression trees), M5, and random forest (RF), for this purpose in the context of Gorakhpur, India. They findings that the RF model outperformed the other models in terms of accuracy, making it the most effective model for solar radiation prediction in this specific region. In contrast, the CART model was identified as the least accurate among the four models considered. In [12], the authors employed both artificial neural networks (ANN) and time series models to forecast daily global solar radiation in various Moroccan locations. They conducted an examination and review of the hybrid ARIMA-ANN technique. Their findings demonstrated that the hybrid ARIMA-ANN approach outperforms single techniques in terms of several statistical criteria and provides more accurate daily global solar radiation forecasts. This highlights the benefits of combining time series and neural network approaches for improved forecasting accuracy. Furthermore, the authors [13] conducted a comparison of hourly global solar radiation forecasts using various machine learning and time series approaches. They evaluated these methods by comparing them with the persistence technique and the dataset, employing multiple statistical measurements to determine the approach with the highest accuracy. The results of this comparison revealed that in most cases, the RMSE (%) and MBE (%) values were significantly positive. The range of RMSE (%) and MBE (%) values for the selected models varied from 4.64% to 8.87% and 6% to 22.93%, respectively. Notably, the model with the lowest value in comparison to the other models was the neural feedforward backpropagation (FFBP) model, with an RMSE of 6.10% and employing the Levenberg–Marquardt algorithm. The method that performed well and showed significance for experimental measurements is a suitable choice [13]. It seems unnecessary to provide additional information on the structure and effectiveness of the other techniques, as they have already been extensively documented in previous publications. For further insights and specifics, it is advisable to refer to the cited references [10, 12, 14].

To summarize the novel aspects of our work, the primary contributions made in this paper can be outlined as follows:

  • Develop new ANN models by considering various input combinations to forecast day ahead hourly global, direct, and diffuse solar radiation in the Mediterranean climate. This will be done using data from the Meteorological station located on the rooftop of Abdelmalek Essaadi, Faculty of Science in Tetuan, Morocco, as well as Meteonorm software.

  • Utilize a meteorological dataset, which includes parameters such as clearness index (Kt), top of atmosphere (TOP), maximum temperature (Tmax), minimum temperature (Tmin), temperature difference (ΔT), temperature ratio (Tratio), and relative humidity (Rh) as input variables for the study.

  • Evaluate the performance accuracy of all possible combination models to select the most suitable configuration.

  • Forecast day ahead hourly solar radiation using the most accurate combination of input variables, the appropriate training algorithm, and the transfer function of the ANN model.

The remainder of the paper follows this structure: Sect. 2 outlines the data collection and concise overview of the ANN. Section 3 provides analysis methods employed in this study. Section 4 delves into the discussion of experimental results. Lastly, Sect. 5 summarizes the primary conclusions and future perspectives derived from this investigation.

2 Data collection and ANN model

2.1 Data selection

The data used in this study was sourced from the Meteorological station situated on the rooftop of Abdelmalek Essaadi, Faculty of Science in Tetouan, Morocco, as well as the website (http://www.wunderground.com). The forecasting of day ahead hourly solar radiation covered the period from 2010 to 2019, focusing on the geographical coordinates of 35.5889° N and 5.3626° W in Morocco.

Figure 1 displays the distribution of global, diffuse, and direct solar radiation for each day and month in 2015. The data reveals a distinct seasonal pattern characterized by noticeably higher variances in the irradiance distributions during August and September compared to the other months. This increase in variance can be attributed to the rainy season at the Tetuan site.

Fig. 1
figure 1

Daily and monthly global, diffuse and direct solar radiation throughout 2015

The collected data for this research includes several meteorological variables such as Tmax, ΔT, Tratio, and Rh. Additionally, computational and astronomical data, including CI and TOA, were incorporated into the analysis. The general formulas for computing these inputs data are provided in Fig. 2 and described below:

Fig. 2
figure 2

Daily measured and computed inputs variables throughout 2015

The \(\Delta T\) refers to the difference in temperature between the maximum and minimum temperatures in a given time period, typically a day. The formula for \( \Delta T\) is:

$$ \Delta T = T_{{{\text{max}}}} - T_{{{\text{min}}}} $$
(1)

where \(T_{{{\text{max}}}} \) is the maximum temperature (°C), and \(T_{{{\text{min}}}} { }\) is the minimum temperature (°C).

The \(T_{{{\text{ratio}}}}\) is the ratio of the actual temperature to an average temperature. It is calculated as:

$$ T_{{{\text{ratio}}}} = \frac{{T_{{{\text{actual}}}} }}{{T_{{\text{average }}} }} $$
(2)

where \( T_{{{\text{actual}}}}\), and \(T_{{{\text{average}}}}\) are the actual, and average temperature (°C) respectively.

The CI is defined as the ratio of the actual solar radiation received at the surface to the extraterrestrial solar radiation (solar radiation received at the top of the atmosphere). The mathematical expression of is given as follow:

$$ CI = \frac{GSR}{{TOA}} $$
(3)

where \(GSR\) is Global Solar Radiation received at the surface (W/m2), and \(TOA\) is the Top of Atmosphere radiation (w/m2).

The Top of Atmosphere (TOA) radiation is the solar radiation received at the top of the Earth's atmosphere. It can be calculated using the formula:

$$ TOA = I_{{{\text{sc}}}} \times \left( {\left( {1 + 0.034\cos \left( {\frac{2\pi n}{{365}}} \right)} \right) \times \cos \left( \theta \right)} \right) $$
(4)

where \(I_{sc}\) is the solar constant (approximately 1361 W/m2), n is the day of the year (dimensionless), and \(\theta\) is the solar zenith angle (degrees or radians).

The combination of these meteorological, astronomical, and computational data is used to determine the most suitable configuration for forecasting day ahead hourly solar radiation. This comprehensive dataset and approach aim to enhance the accuracy of solar radiation forecasting in the specified geographical location and time period.

The Eq. (5) provided can be used to compute the binomial coefficient or combination:

$$ Combin. = \mathop \sum \limits_{p = 1}^{m} C_{m}^{p} = \mathop \sum \limits_{p = 1}^{m} \frac{m!}{{\left( {m - p} \right)!p!}} $$
(5)

where Combin. is the number of all combinations, and m is the total number of inputs.

2.2 Building neural network algorithms

The selection of the training algorithm's characteristics is a crucial step in developing an ANN model depending on the combination of various input data, and Fig. 3 illustrates a schematic diagram of an ANN.

Fig. 3
figure 3

Schematic diagram featuring multiple training algorithms used in an ANN

In previous studies, straightforward classification input data have been commonly employed, and these inputs directly influence the forecasted output data. In this study, various combinations of input data were utilized with the aim of reducing forecasting errors and achieving high-performance accuracy.

The architecture of an ANN consists of fundamental nodes organized into layers, with connections established through weights and biases between these layers. Typically, ANNs are composed of three major layers: the input layer, the hidden layer, and the output layer. These layers work together to process the input data and produce the desired output, making ANNs a versatile tool for various tasks, including forecasting.

2.2.1 Scaled conjugate gradient algorithm

The Scaled Conjugate Gradient (ANN-SCG) is a supervised learning algorithm developed by Moller [3], and it falls under the category of conjugate gradient techniques. The primary function of the SCG algorithm is to combine the trust region approach employed in Levenberg–Marquardt with the conjugate gradient approach. In the context of artificial neural networks, the ANN-SCG algorithm serves as an optimization technique used to find the minimum values of various parameters during the training process, adjusting the step size at each iteration.

One of the key advantages of the ANN-SCG algorithm is its ability to significantly increase the learning speed in successive iterations. The algorithm's parameter improvement process can be described mathematically by the following expression:

$$ W^{{\left( {k + 1} \right)}} = W^{k} + \Upsilon ^{k} \mathbb{N}^{k} $$
(6)

where \( \Upsilon ^{k} \) and \({\mathbb{N}}^{k}\) are the training direction vector and the training rate.

2.2.2 Gradient descent algorithm

The Gradient Descent Algorithm (ANN-GDA) is an iterative procedure used in neural networks to determine an optimal set of internal variables for a model. In this context, "gradient" refers to the rate of change or slope, and "descent" implies moving toward an optimal solution. The gradient descent method typically consists of three main phases:

  1. 1.

    Initialization of internal variables.

  2. 2.

    Evaluation of the model's performance based on the current internal variables.

  3. 3.

    Optimization by updating the internal variables to minimize the model's error or loss.

The gradient descent method progresses through iterations using the following equation:

$$ W^{{\left( {k + 1} \right)}} = W^{k} - \nabla {\mathcal{F}}\left( {W^{k} } \right){\mathbb{N}}^{k} $$
(7)

where \(W^{k} \) and \(\nabla {\mathcal{F}}\left( {W^{k} } \right) \) are the set of variables, and the gradient of function according to \( W^{k} \). \({\mathbb{N}}^{k}\) is the training step, and k = 0, 1,…k.

2.2.3 Resilient backpropagation algorithm

The Resilient Backpropagation (ANN-RBP) algorithm is a supervised learning technique closely related to the standard backpropagation algorithm, with the key difference being the way weights are updated. During the training process, ANN-RBP is known for being faster and more complex than the traditional backpropagation method. The ANN-RBP method involves iterating through steps determined by the following equation:

$$ W^{{\left( {k + 1} \right)}} = W^{k} - \nabla {\mathcal{F}}\left( {W^{k} } \right) $$
(8)

where \(W^{k} \) and \(\nabla {\mathcal{F}}\left( {W^{k} } \right) \) are the set of variables, and the resilience of function according to \( W^{k} \). \({\mathbb{N}}^{k}\) is the training step, and k = 0, 1,…

2.2.4 Levenberg–Marquardt back-propagation algorithm

The Levenberg–Marquardt algorithm (ANN-LM) is a hybrid approach that combines aspects of both gradient descent (GD) and Gauss–Newton (GN) methods. It is primarily used for curve fitting and adjusting non-linear least squares problems. One of the key advantages of the LM algorithm is its ability to intelligently choose the most appropriate method to reduce the function value during optimization. During the training process, ANN-LM selects either the gradient descent (GD) or Gauss–Newton (GN) approach at each iteration, depending on the current conditions, and provides updated results accordingly. The parameter development process can be mathematically defined as follows:

$$ W^{{\left( {k + 1} \right)}} = W^{\left( k \right)T} - \left( {{\text{\AA}}^{k} \cdot {\text{\AA}}^{k} + {\mathcal{B}}^{k} \cdot I} \right)^{ - 1} \left( {2{\text{\AA}}^{\left( k \right)T} \mu^{k} } \right) $$
(9)

where \({\text{\AA}}^{k}\) is the Jacobian Matrix; \({\mathcal{B}}^{k}\) is the damping factor that guarantees the confident of the Hessian matrix; and \(\mu^{k}\) is the vector of all error terms for k = 0, 1…

3 Methodology

3.1 Day ahead hourly forecasting model

Day-ahead hourly solar radiation forecasting, which involves forecasting solar radiation for multiple step ahead, commonly employs three primary strategies: the direct strategy, the recursive strategy, and the direct-recursive strategy [15]. In the recursive strategy, a single model is used to make forecasts for a sequence of future time steps, one after the other. This model takes historical data as input, generates a forecast for the next time step, and then integrates this newly forecasted value into the input data for making further forecasts. This approach accumulates predictions step by step. In contrast, the direct strategy uses multiple distinct models to make forecasts for several steps into the future. Each of these models is responsible for forecasting a specific number of steps ahead. The direct strategy assumes that the prediction horizons are not interrelated, allowing for the training of different models using the same input data. The direct-recursive strategy combines elements from both the direct and recursive forecasting strategies. This method decomposes the task of making H-step forecasts into n models, with each model generating h outputs. Instead of generating all forecasts at once, each individual model produces one output at a time. This approach provides a hybrid solution that balances the advantages of both direct and recursive strategies.

These strategies offer different approaches to tackling the challenging task of forecasting day-ahead hourly solar radiation, allowing for flexibility in modeling and forecasting based on specific needs and data characteristics. This work we use the direct multi-step forecast strategy (Fig. 4), which involves forecasting multiple future time steps simultaneously in a single step. While it can be computationally efficient, it may face challenges in capturing complex dependencies and may have limitations in capturing the relevance between adjacent values in the time series.

$$ \hat{y}_{t + 1} = F_{1} \left( {y_{t} ,y_{t - 1} , \ldots \ldots .,y_{t - d + 1} } \right) $$
$$ \hat{y}_{t + 2} = F_{2} \left( {y_{t} ,y_{t - 1} , \ldots \ldots .,y_{t - d + 1} } \right) $$
$$ \hat{y}_{t + 3} = F_{3} \left( {y_{t} ,y_{t - 1} , \ldots \ldots .,y_{t - d + 1} } \right) $$
$$ \hat{y}_{t + H} = F_{H} \left( {y_{t} ,y_{t - 1} , \ldots \ldots .,y_{t - d + 1} } \right) $$
(10)
Fig. 4
figure 4

Direct strategy for multi-step ahead forecasting

The method introduced in this paper is used to enhance an attention-based ANN model by combining input data using multiple training algorithms. The strategy of this method can be summarized in five key steps illustrated in Fig. 5, which are as follows:

  1. 1.

    Pre-processing: This step involves preparing the input data collected to ensure that it aligns with the objectives of the study. It includes tasks like correcting missing data and removing outliers to improve data quality.

  2. 2.

    Input Data Combination: After pre-processing, a series of input data combinations is initiated, addressing any remaining missing data.

  3. 3.

    Model Building: Using the obtained combination of input data, an ANN model is constructed, with multiple training algorithms being employed.

  4. 4.

    Statistical Performance Evaluation: Statistical performance indicators are computed to assess the relationship between the forecasted and experimental output data. This step provides insights into the accuracy and reliability of the model.

  5. 5.

    Testing and Simulation Forecast: The established model is tested, and simulation forecasting is conducted to forecast day ahead hourly global, direct, and diffuse solar radiation using the optimum configuration and the appropriate model. This final step aims to validate the model's performance in forecasting solar radiation under various conditions.

Fig. 5
figure 5

Block diagram of the proposed methodology

3.2 Performance metric

To evaluate the effectiveness of the two-part model, one set of input variables is used for the learning process, and the second set is designated as the validation set, which also serves as a test set. The testing procedures entail comparing various model outcomes. The proposed methodology's performance is assessed by employing various statistical metrics, including:

$$ MBE = \frac{1}{N}\sum\limits_{i = 1}^{N} {\left( {G_{{{\text{forcast}},i}} - G_{\exp ,i} } \right)} $$
(11)
$$ RMSE = \sqrt {\frac{1}{N}\sum\limits_{i = 1}^{N} {\left( {G_{{{\text{forcast}},i}} - G_{\exp ,i} } \right)} } $$
(12)
$$ R^{2} = 1 - \frac{{\sum\limits_{i = 1}^{N} {\left( {G_{{{\text{forcast}},\;i}} - G_{\exp ,\;i} } \right)^{2} } }}{{\sum\limits_{i = 1}^{N} {\left( {G_{{{\text{forcast}},\;i}} - \overline{G}_{\exp ,\;i} } \right)^{2} } }} $$
(13)
$$ {\text{Sd}} = \sqrt {\frac{{N\left( {RMSE^{2} - MBE^{2} } \right)}}{N - 1}} $$
(14)

where, \(G_{{{\text{forecast}}}}\) and \(G_{\exp }\) are the forecasted and measured values of day ahead hourly solar radiation, respectively. \(\overline{G}_{{{\text{forecast}}}}\) and \(\overline{G}_{\exp }\) present the average of forecasted and measured values of day ahead hourly solar radiation and N is the number of observation data.

4 Results and discussions

The main objective of this study is to evaluate the performance of different ANN models. These models use a combination of meteorological data to forecast day ahead hourly solar radiation. The study employs a variety of training algorithms, including LM, SCG, RBP, and GDA.

The training process continues until the network's output error reaches a desirable level. The study explores a range of epoch numbers for training, varying from 100 to 1000 with increments of 100.

Table 1 provides a detailed description of the characteristics of the ANN models used in this research. These models are crucial for improving the accuracy of solar radiation forecasts by utilizing different combinations of meteorological data and training algorithms.

Table 1 The parameters selected and applied in the training algorithm

The selection of an appropriate architecture for an ANN model poses a significant challenge, primarily concerning the configuration of the activation function and the number of neurons in the hidden layer. The process of selecting the right activation function involved a trial-and-error analysis.

One of the most fundamental and critical phases in designing an ANN is determining the number of hidden nodes. In Fig. 6, the optimal number of hidden nodes was determined by evaluating the RMSE from the tenfold cross-validation error. This step is essential in achieving an effective ANN architecture for the specific modeling task.

Fig. 6
figure 6

The results of a tenfold cross-validation process for simple training algorithms

The primary objective of using tenfold cross-validation methods is to optimize the number of hidden neurons in the hidden layer during the training process. This optimization aims to prevent overfitting of the ANN model. After completing all the training and validation iterations, the average RMSE is calculated to provide a consolidated measure from these samples.

The ANN-based combination of meteorological data structures that exhibited the lowest cross-validation error was chosen for the day ahead hourly forecasting of global, direct, and diffuse solar radiation. After several attempts, it was determined that using 10 nodes in the hidden layer with the LM trained algorithm produced the lowest RMSE (%) values, ranging between 2.214% and 2.501%, respectively. These selected nodes in the hidden layer served as a reference for each training algorithm. This configuration was found to offer the most accurate results in the forecasting task.

Figure 7 and Table 2 represent the performance of different neural network activation functions (LOGSIG, TANSIG, and PURELIN) in terms of RMSE across various combinations of input features. Each point on the x-axis corresponds to a unique combination of input features. In addition, the y-axis measures the differences between forecasted and observed values. As we can see, all possible training combinations are presented in different colors to distinguish between scenarios. In terms of RMSE percentages, the average values for the PURELIN transfer function algorithms fall between 0.6159% and 0.6221%. On the other hand, the average values for the LOGSIG and TANSIG transfer functions range between 0.6111% and 6.149% across the LM, SCG, RBP, and GDA algorithms.

Fig. 7
figure 7

The RMSE for 125 combinations of input data using multiple training algorithms

Table 2 The training algorithm with the highest and lowest values of RMSE (%)

It's important to note that the lower the RMSE value, the more suitable the configurations of ANN models are for the task. The figures and table clearly demonstrate that the LOGSIG transfer function in conjunction with the ANN-LM algorithm offers the most favorable results (Table 2) In this study, the most effective configuration was chosen to enhance the accuracy of forecasting day ahead hourly global, direct, and diffuse solar radiation components Table 3.

Table 3 The most suitable combination of input data

Once the number of nodes in the hidden layer is determined and the coordination procedure is established, the process of combining different meteorological data begins automatically using the binomial coefficient formula described in Eq. (1). After several trials, 125 combinations were identified as suitable configurations (Appendix: Tables 4, 5 and 6). These results need to be compared in order to select the appropriate input parameters that can forecast day ahead hourly solar radiation using multiple training algorithms.

In Table 3, we found six combinations that are considered the most suitable configurations for predicting day ahead hourly global, direct, and diffuse solar radiation. Subsequently, the ANN process commences with the selected combination of inputs, and the network is further trained before forecasting the desired output. This systematic approach aims to optimize the accuracy of solar radiation forecasts.

In Fig. 8, you can observe all possible combinations of input variables, CI, Tmax, ∆T, Tratio, TOA, and Rh. Based on the results, the most suitable configuration with the highest R2 value and the lowest RMSE (%) value was selected as the fundamental input for training and retraining the ANN models with multiple training algorithms, namely ANN-LM, ANN-SCG, ANN-RBP, and ANN-GDA.

Fig. 8
figure 8

All possible combinations of various meteorological, astronomical, and computational input parameters

The adjustment of weights (\(W^{{\left( {k + 1} \right)}}\)) described in Eqs. (25) is carried out through the training set and the validation set, ensuring that the error remains within a certain range. This approach helps determine the optimal number of hidden layers or identifies a breakpoint for the backscatter algorithm, rather than adjusting weights directly.

Finally, the model's accuracy on the test data contributes to the forecasting performance of the ANN model. The training process conducted to forecast day ahead hourly global, direct, and diffuse solar radiation is presented in the Appendix (Tables 4, 5 and 6). This comprehensive methodology aims to enhance the accuracy of solar radiation forecasts through systematic training and model evaluation.

Based on the statistical metrics presented in Tables 4, 5 and 6 (refer to the Appendix), it is evident that the values highlighted in bold are considered appropriate combinations. These combinations were established for a range of global solar radiation scenarios, including combin.149, combin.64, combin.70, combin.72, combin.83, combin.94, combin.99, combin.102, combin.104, combin.107, and combin.109. For direct solar radiation, the suitable combinations include combin.07, combin.08, combin.10, combin.20 to combin.24, combin.49, combin.79, combin.90, and combin.25, among others. Likewise, for diffuse solar radiation, the combin.07, combin.67, combin.100, combin.101, combin.115, combin.117, combin.119, combin.122 to combin.125 were identified as suitable configurations, with corresponding input parameters provided in Table 2. These configurations achieved R2 values ranging from 0.9665 to 0.9898, indicating a strong correlation between the experimental and forecasted values.

The range values for RMSE, MBE, and SD vary based on the solar component. For global solar radiation, the RMSE ranges from 0.303 to 0.499, MBE (%) ranges from -0.471 to -0.244, and SD ranges from 0.376 to 0.495. For direct solar radiation, the corresponding ranges are 0.3991 to 0.6983 for RMSE (%), -4.8385 to -2.9817 for MBE (%), and 4.0006 to 5.0950 for SD (%). Diffuse solar radiation exhibits a range value of RMSE between 0.3980 and 0.8008, MBE (%) between -0.8647 and -0.7417, and SD (%) between 0.4993 and 0.6631.

These statistical metrics were applied across all mentioned training algorithms. The lowest values of these statistical indicators reflect the highest accuracy in the performance comparison between experimental and forecasted values for the three solar components. Additionally, the R2 for these combinations approaches 1, indicating a strong level of accuracy in forecasting global, direct, and diffuse solar radiation.

Figure 9A, B and C depicts the experimental and the forecasted day ahead hourly global, direct and diffuse solar radiation output of appropriate inputs-output of one typical clear sky day (over 100 W/m2 to 1000 W/m2) from 2010 to the 2019 year. In this case, forecasting solar radiation with the PURELIN transfer function generate relatively less accuracy as shown in the previous figures and Tables. Whereas, the first transfer function (LOGSIG) with the LM algorithm is considered a suitable training model due to the agreement relationship between experimental and forecasted data. The obtained result is conducted to select an appropriate training algorithm (ANN-LM) in three forecasts of solar radiation as a reference model for implementing a new empirical model based on temperature, humidity, etc.… Here, we simulate the three components of solar radiation on one typical day due the importance of maximum capturing especially on clear sky condition.

Fig. 9
figure 9figure 9

The day ahead hourly forecast of a global, b direct, and c diffuse solar radiation of different training algorithm model under sky conditions

Figures 10, 11, and 12 depict the forecasting performance of the ANN model using the best combinations generated from the appropriate training algorithms for the three solar components on a typical clear sky day. The R2 values for the day ahead hourly forecast of global, direct, and diffuse solar radiation by the ANN-LM model on the training dataset range from 0.984 to 0.989, respectively, when compared to the experimental dataset. As a result, the forecasting performance of the ANN-LM model using all selected combinations closely aligns with the measured data. These results substantiate the strong relationship between the forecasts and the actual observed data.

Fig. 10
figure 10

Comparison between the Experimental data and the day ahead hourly forecast of GSR using the appropriate ANN model (ANN-LM)

Fig. 11
figure 11

Comparison between the Experimental data and the day ahead hourly forecast of direct solar radiation generated by the suitable ANN model ANN-LM)

Fig. 12
figure 12

Comparison between the Experimental data and the day ahead hourly forecast of diffuse solar radiation using the appropriate ANN model (ANN-LM)

Figures 13A, B and C provide the average values of RMSE (%), MBE (%), SD (%), and R2 (%) for global, direct, and diffuse solar radiation, respectively. These results were obtained under clear sky conditions, indicating an absence of clouds throughout the sky dome. Additionally, all the results are based on the best combinations of ANN-based input parameters and the optimal training algorithm.

Fig. 13
figure 13

Average a RMSE (%), b MBE (%), c SD (%), and d R2 (%) for the three solar radiation with appropriate training algorithm models

The figures clearly illustrate that global solar radiation exhibits the lowest average values when compared to direct and diffuse radiation, especially in the trained ANN-LM algorithm. The average RMSE (%) ranges between 0.400 and 5.065, while MBE (%) falls between -0.165 and -4.876, and SD (%) ranges from 0.376 to 5.725 for global solar radiation.

Regarding the R2, ANN-LM consistently outperforms the other trained models, with R2 values ranging from 0.9801 to 0.9899. This indicates a strong correlation between the forecasted and measured global solar radiation data, further emphasizing the accuracy of the ANN-LM algorithm for this particular component.

Interestingly, the hybrid ARIMA-FFBP method described in [12] for Tetuan, Morocco, seems to perform better using the R2 metric compared to the ANN-LM method presented in our paper for the same city. This superior performance can be attributed to the hybrid model's ability to combine the strengths of both linear and non-linear modelling techniques. ARIMA effectively captures the linear trends and seasonality in the data, while the FFBP neural network handles the non-linear residual patterns. This synergy allows the hybrid model to better adapt to the intricate variations in solar radiation, resulting in a more accurate and robust forecasting as indicated by the higher R2 values. In summary, the ANN-LM method demonstrates certain strengths, particularly in terms of simplicity and computational efficiency, the hybrid ARIMA-FFBP model's ability to combine linear and non-linear modeling techniques appears to offer superior performance for the Tetuan dataset. Future research could explore the integration of hybrid models and compare their performance across different metrics and datasets to further validate these findings.

The different results among the methods presented in this paper can be attributed to several physical factors inherent in the data and the modelling approaches. Variability in local climatic conditions, such as sudden changes in weather patterns, cloud cover, and temperature fluctuations, can significantly impact solar radiation and temperature readings, introducing non-linearities and complexities that certain models handle better than others. The ability of a model to capture these intricate patterns and adapt to the dynamic nature of environmental data is crucial. The neural network models, particularly those using activation functions like LOGSIG and TANSIG, are designed to model complex, non-linear relationships, which might explain their varied performance across different input combinations. Additionally, the choice of training algorithms and their sensitivity to initial conditions and parameter settings can lead to differences in model accuracy and robustness, further influencing the comparative performance of the methods.

5 Conclusions

This paper presents a comprehensive approach for forecasting day ahead hourly global, direct, and diffuse solar radiation in a Mediterranean climate, specifically at the Tetuan site in Morocco. The methodology involves using ANNs based on various combinations of meteorological, astronomical, and computational input data. Multiple training algorithms and transfer functions are employed to identify the most effective models, providing a practical empirical framework.

The ANN models are developed and implemented using well-known trained algorithms such as LM, SCG, GDA, and RBP within the MATLAB software environment. The process starts by addressing missing input data and handling outlier removal. Various input combinations are tested to determine the most suitable parameters. These selected inputs are then used to construct ANN models with the primary objective of forecasting day ahead hourly global, direct, and diffuse solar radiation.

Subsequently, the fixed ANN configurations are trained and retrained using different training algorithms and appropriate transfer functions to forecast day ahead hourly output parameters. The results are analyzed using statistical indicators to assess and summarize the models, highlighting the lowest and highest values of RMSE (%), MBE (%), SD (%), and R2, which establish the relationship between forecasted and experimental data.

The selected combination of input parameters, as presented in the Appendix, underscores the performance of the developed ANN models. The appropriate input data are CI, TOA, Tmax, Tratio, ∆T, and Rh, with an R2 range value of 0.9930%. On a typical clear sky day, the simulation results confirm that the ANN-LM model with the LOGSIG transfer function closely aligns with experimental output data. These results showcase the robustness of the developed ANN models and the effectiveness of the simulation approach. The ANN models could serve as reference models for the development of new empirical models based on climatological conditions, incorporating factors such as temperature, humidity, etc.