A method for short-term irradiance prediction based on Transformer
Through the transformer-based method, the area around the sun is segmented and cloud features are extracted. Combined with light impact assessment, the problems of low prediction accuracy and high cost are solved in the short-term irradiance prediction, achieving higher precision prediction effects.
Patent Information
- Application Number
- CN202111027387.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-02
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2041-09-02
AI Technical Summary
The prior art has problems of low prediction accuracy and high cost in short-term irradiance prediction, especially traditional ARMA models and sky cloud map prediction methods.
Using transformer-based method, the area around the sun is divided, the cloud features are extracted using the VGG16 model, and the cloud speed is calculated by combining the Lucas-Kanade algorithm, multi-head attention mechanism and full-connection layer are used for prediction, and sunny day models are added for lighting impact assessment.
The accuracy of short-term irradiance prediction is improved, the average absolute error is reduced by 6.83%, and the cost is reduced.
Smart Images

Figure CN113723691B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method for short-term irradiance prediction, and more particularly to a method for short-term irradiance prediction based on transformer. Background Art
[0002] Solar energy is a new type of energy that is green, pollution-free, has huge potential, and is sustainable. At present, the utilization of solar energy is mainly for photovoltaic grid-connected power generation, and irradiance in the photovoltaic power generation system is a decisive factor affecting the power generation. The algorithms for predicting irradiance in the past can generally be divided into two categories. One is to directly use the historical irradiance data for univariate prediction, and the other is to use meteorological data such as temperature, air pressure, humidity, and cloud information for univariate or multivariate prediction. Among them, the collection of complex meteorological information is difficult, the calculation process is complex, and the prediction accuracy is relatively low.
[0003] For short-term prediction of ground irradiance, the commonly used methods are as follows: (1) Autoregressive Moving Average (ARMA) model; this method uses the historical time series data of irradiance, and determines a mathematical model that can describe the irradiance time series through model identification, parameter estimation, and model testing, so as to achieve the prediction purpose. However, since ARMA is a linear model, the prediction accuracy is limited; (2) Prediction method using sky cloud image; this method usually requires installing a sky imager at the photovoltaic power station site, which is costly and the prediction algorithm is complex, so it is difficult to implement. Summary of the Invention
[0004] In order to overcome the deficiencies of the prior art, the present invention provides a method for short-term irradiance prediction based on transformer.
[0005] A method for short-term irradiance prediction based on transformer includes the following steps:
[0006] (1) Divide the area around the sun according to the position of the sun and the wind speed of the cloud. The position of the sun center on the image is calculated according to the following formula:
[0007]
[0008]
[0009] ω=(k - 12)×15°
[0010]
[0011] θ s represents the solar zenith angle, Let φ represent the latitude of the observation site, δ represent the declination angle, ω represent the hour angle, DOY represent the day of the year, k represent the sample collection time in hours, and α represent the solar azimuth angle;
[0012] The position of the sun (x s , y s ) is calculated according to the following formula:
[0013] r s = R Z sinθ
[0014] x s = x 0 + r s sinα
[0015] y s = y 0 + r s cosα
[0016] Where r s represents the distance from the center of the picture to the center of the sun; x 0 , y 0 is the position of the center of the image, and R Z is the distance between the sun and the center of the sky image when the solar zenith angle is 90 degrees;
[0017] The ground-based panoramic camera is used to perform time-periodic sampling on the sky cloud image, and the Lucas-Kanade algorithm is used to calculate the average velocities of the clouds around the sun in the t-th, (t + 1)-th, (t + 2)-th, and (t + 3)-th images, namely (u t , v t ), (u t+1 , v t+1 ), (u t+2 , v t+2 ), (u t+3 , v t+3 ), where u represents the horizontal velocity and v represents the vertical velocity;
[0018] The positions of the sun in the t-th, (t + 1)-th, (t + 2)-th, and (t + 3)-th images are (x t , y t ), (x t+1 , y t+1 ), (x t+2 , y t+2 ), (x t+3 , y t+3 )
[0019] The t-th segmented image is obtained by taking (u t + x t , v t + y tCenter-divide an image of 64×64 pixels, and the same applies to the (t+1)-th, (t+2)-th, and (t+3)-th images; (2) Respectively pass the divided t-th, (t+1)-th, (t+2)-th, and (t+3)-th images through the VGG16 model for training and extract the fully connected features f t , f t+1 , f t+2 , f t+3 ∈R 1024×1 , f t represents the features extracted after passing the t-th image collected through the VGG16 network, and R (Real domain) represents the real number domain; where the label of the VGG16 model is g t -m t , g t represents the current GHI of the t-th image, and m t represents the GHI of the clear sky model of the t-th image;
[0020] The GHI of the clear sky model is calculated as follows:
[0021] At solar noon on the spring or autumn equinox, i.e., when the sun crosses the meridian, the zenith angle θ s is equal to the latitude of the observation site
[0022]
[0023] On any other day of the year, the zenith angle θ at solar noon s is:
[0024]
[0025] Calculate the zenith angle θ other than solar noon according to step (1) s ;
[0026] The GHI of the clear sky model is:
[0027] GHI = 1159.24×(cosθ s ) 1.179 ×exp(-0.0019×(90° - θ s ))
[0028] Correct the clear sky model,
[0029]
[0030] GHI = GHI + error
[0031] i represents the i-th image before the t-th image;
[0032] (3) Connect the features extracted by the VGG16 model
[0033] f = (f t , f t+1 , f t+2 , f t+3 ) ∈ R 4096×1
[0034] Encode each feature to obtain e represents the dimension of each feature embedding;
[0035] (4) Position encoding PE ∈ R 4096×e The calculation formula is as follows:
[0036] PE (pos,2j) = sin(pos / 10000 2j / e )
[0037] PE (pos,2j+1) = cos(pos / 10000 2j / e )
[0038] where pos represents the position of the feature and j represents the position of the encoding vector;
[0039] Add the position encoding PE and the input encoding to get H ∈ R 4096×e as the input of the multi - head attention mechanism,
[0040]
[0041] (5) After passing through the multi - head attention mechanism, we get Normalize , where the label of the transformer is g t+6 -m t+6 ;
[0042] (6) Output the predicted GHI value p after 30 minutes by passing H' through global average pooling and a fully - connected layer;
[0043] (7) Evaluate the impact of lighting on the experiment based on the GHI value g t+3 of the (t + 3) - th image and the GHI value m t+3 of the clear - sky model of the (t + 3) - th image. If the difference between g t+3 -m t+3 is small and g t+3 is large, it means that lighting has an impact, and then the prediction result after 30 minutes is the GHI value m t+3 of the clear - sky model of the (t + 3) - th image. Otherwise, it is the value output by the fully - connected layer,
[0044]
[0045] Preferably, gt+3 -m t+3 Take 160 g t+3 Take 150.
[0046] First, the present invention divides the area around the sun according to the position of the sun and the wind speed. Different from the traditional method of artificially extracting cloud features, the present invention uses the VGG16 network structure to extract the features of different clouds. Secondly, a group of cloud features are connected and the transformer structure is used to train the irradiance value after cloud change. Finally, the fully connected layer is used to output the result of irradiance prediction. The final irradiance result will determine whether to use the clear sky model output or the fully connected output according to the magnitude of the influence of light. The clear sky model is also added in the middle to train the entire structure; The results show that after adding the clear sky model, the mean absolute error of the global horizontal irradiation (GHI) can be reduced by 6.83% compared with the traditional neural network model. Brief Description of the Drawings
[0047] Figure 1 is the flowchart of the present invention. Detailed Embodiments
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the present invention will be further described below with reference to the drawings and embodiments, but the scope to be protected by the present invention is not limited thereto.
[0049] Refer to Figure 1 , a method for short-term irradiance prediction based on transformer, comprising the following steps:
[0050] (1) Divide the area around the sun according to the position of the sun and the wind speed of the cloud. The position of the sun center on the image is calculated according to the following formula:
[0051]
[0052]
[0053] ω = (k - 12) × 15°
[0054]
[0055] θ s represents the solar zenith angle, represents the latitude of the observation site, δ represents the declination angle, ω represents the hour angle, DOY represents the day of the year, k represents the sample collection time, in hours, that is, the time when a picture sample is taken on a certain day. For example, if a picture is taken at 11:30, then k is 11.5, and α represents the solar azimuth angle;
[0056] The position of the sun (xs , y s It is calculated according to the following formula:
[0057] r s = R Z sinθ
[0058] x s = x 0 + r s sinα
[0059] y s = y 0 + r s cosα
[0060] Among them, r s represents the distance from the center of the image to the center of the sun;
[0061] x 0 , y 0 is the position of the center of the image, and R Z is the distance between the sun and the center of the sky image when the solar zenith angle is 90 degrees;
[0062] Using a ground-based panoramic camera to perform time-periodic sampling on the sky cloud image, and using the Lucas-Kanade algorithm to calculate the average velocities of the clouds around the sun in the t-th, (t + 1)-th, (t + 2)-th, and (t + 3)-th images respectively as (u t , v t ), (u t+1 , v t+1 ), (u t+2 , v t+2 ), (u t+3 , v t+3 ), where u represents the horizontal velocity and v represents the vertical velocity;
[0063] The positions of the sun in the t-th, (t + 1)-th, (t + 2)-th, and (t + 3)-th images are (x t , y t ), (x t+1 , y t+1 ), (x t+2 , y t+2 ), (x t+3 , y t+3 )
[0064] The t-th segmented image is obtained by segmenting a 64×64 pixel image centered at (u t + x t , v t + y t ) on the original image. The same applies to the (t + 1)-th, (t + 2)-th, and (t + 3)-th images;
[0065] (2) The t-th, (t + 1)-th, (t + 2)-th, and (t + 3)-th images after segmentation are respectively trained through the VGG16 model and the fully-connected features f t , f t+1 , f t+2 , f t+3 ∈R 1024×1 are extracted, where the label of the VGG16 model is g t -m t , g t represents the current GHI of the t-th image, and m t represents the GHI of the clear-sky model of the t-th image;
[0066] The GHI of the clear-sky model is calculated as follows:
[0067] At solar noon on the spring or autumn equinox, that is, when the sun crosses the meridian, the zenith angle θ s is equal to the latitude of the observation site
[0068]
[0069] On any other day of the year, the zenith angle θ s at solar noon is:
[0070]
[0071] According to step (1), calculate the zenith angle θ s outside solar noon;
[0072] The GHI of the clear-sky model is:
[0073] GHI = 1159.24 × (cosθ s ) 1.179 × exp(-0.0019 × (90° - θ s ))
[0074] Correct the clear-sky model,
[0075]
[0076] GHI = GHI + error
[0077] i represents the i-th image before the t-th image;
[0078] (3) Connect the features extracted by the VGG16 model
[0079] f = (f t , f t+1 , f t+2 , f t+3 ) ∈ R 4096×1
[0080] Encode each feature to obtain e represents the dimension of each feature embedding;
[0081] (4) The positional encoding PE ∈ R 4096×e The calculation formula is as follows:
[0082] PE (pos,2j) = sin(pos / 10000 2j / e )
[0083] PE (pos,2j+1) = cos(pos / 10000 2j / e )
[0084] where pos represents the position of the feature and j represents the position of the encoding vector;
[0085] Add the positional encoding PE and the input encoding F to obtain H ∈ R 4096×e as the input of the multi-head attention mechanism,
[0086]
[0087] (5) After passing through the multi-head attention mechanism, obtain Normalize , where the label of the transformer is g t+6 -m t+6 ;
[0088] (6) Output the predicted GHI value p after 30 minutes by passing H′ through global average pooling and a fully connected layer;
[0089] (7) Evaluate the impact of light on the experiment based on the GHI value g t+3 of the (t + 3)-th image and the GHI value m t+3 of the clear-sky model of the (t + 3)-th image. If the difference between g t+3 -m t+3 is small and g t+3 is large, it indicates that light has an impact (experimental results show that when g t+3 -m t+3 takes 160 and g t+3 takes 150, the effect is the best), then the predicted result after 30 minutes is the GHI value m t+3 of the clear-sky model of the (t + 3)-th image, otherwise it is the value output by the fully connected layer.
[0090]
[0091] To verify the effectiveness of this method, the present invention uses the data from 2020 and 2021 on the SRRL dataset, where the data from July and November 2020 and January and April 2021 are used as the test set, and the data from June, August, September, October, and December 2020 and February, March, and May 2021 are used as the training set. The experimental results are shown in Table 1 as follows:
[0092] Table 1
[0093] nRMSE nMAPE Basic Convolution-Regression Model 15.27 29.34 Model without - Transformer Model 14.57 27.03 Model without Correction - Transformer Model 15.70 26.84 Model with Correction - Transformer Model 14.26 24.27
[0094] After passing through the light influence evaluation module, by selecting different α and γ, the nRMSE and nMAPE results are shown in Table 2 and Table 3. Here, α represents the difference between the current irradiance and the sunny day model, and γ represents the current irradiance.
[0095] Table 2
[0096] α=100 α=160 α=220 α=280 γ = 50 13.92 13.90 13.96 14.17 γ = 150 13.91 13.90 13.92 14.07 γ = 250 13.95 13.94 13.93 14.01 γ = 350 14.00 14.00 14.00 14.06
[0097] Table 3
[0098] α=100 α=160 α=220 α=280 γ = 50 23.57 22.58 22.88 23.56 γ = 150 23.53 22.51 22.68 23.15 γ = 250 23.78 22.71 22.78 22.97 γ = 350 24.19 23.21 23.20 23.37
[0099]
[0100]
[0101] Among them, n is the number of test samples, and y i and are the true value and the predicted value of GHI respectively.
[0102] The experimental results show that the error of the corrected model - the Transformer model is lower than that of the traditional neural network model, and the effect is more significant after passing through the light influence evaluation module, which proves the effectiveness of the method.
[0103] The present invention has been described in detail above in combination with the embodiments. However, the content described above is only the specific implementation manner of the present invention, and it cannot be understood as a limitation on the scope of the patent of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, any several deformations and improvements made according to the scope of the application of the present invention should still fall within the scope covered by the patent of the present invention.
Claims
1. A method for short-term irradiance prediction based on Transformer, characterized in that it includes the following steps: (1) Divide the area around the sun according to the position of the sun and the wind speed of the cloud. The position of the sun center on the image is calculated according to the following formula: ; θ s represents the solar zenith angle, φ represents the latitude of the observation site, δ represents the declination angle, ω represents the hour angle, DOY represents the number of days, and k represents the sample collection time, in hours, α represents the solar azimuth angle; The position of the sun ( x s , y s ) is calculated according to the following formula: ; Among them, r s represents the distance between the center of the image and the center of the sun; x 0 , y 0 is the position of the center of the image, R Z is the distance between the sun and the center of the sky image when the solar zenith angle is 90 degrees; Periodically sample sky cloud images using a ground-based panoramic camera, and use the Lucas-Kanade algorithm to calculate the average velocities of the clouds around the sun in the t-th, (t + 1)-th, (t + 2)-th, and (t + 3)-th images respectively ( u t , v t ), ( u t+1 , v t+1 ), ( u t+2 , v t+2 ), ( u t+3 , v t+3 ), where u represents the horizontal velocity, and v represents the vertical velocity; The solar positions of the t-th, (t + 1)-th, (t + 2)-th, and (t + 3)-th images are ( x t , y t ), ( x t+1 , y t+1 ), ( x t+2 , y t+2 ), ( x t+3 , y t+3 ), The t-th segmented image is obtained by segmenting an image of 64×64 pixels centered at ( u t + x t , v t + y t ) on the original image. The (t + 1)-th, (t + 2)-th, and (t + 3)-th segmented images are obtained in the same way; (2) The t-th, (t + 1)-th, (t + 2)-th, and (t + 3)-th images after segmentation are respectively trained through the VGG16 model and the fully connected features are extracted f t , f t+1 , f t+2 , f t+3 ∈ R 1024×1 , where the label of the VGG16 model is g t - m t , g t represents the current GHI of the t-th image, m t represents the GHI of the clear sky model of the t-th image; The GHI of the clear sky model is calculated as follows: At solar noon on the spring or autumn equinox, when the sun crosses the meridian, the zenith angle θ s is equal to the latitude of the observing site φ : θ s = φ On any other day of the year, the zenith angle of the sun at noon θ s is as follows: θ s = φ - δ Calculate the zenith angle other than at solar noon according to step (1). θ s ; The GHI of the clear sky model is: ; Correct the clear sky model, ; i denote the i images in front of the t-th image; (3) Connect the features extracted by the VGG16 model f = ( f t , f t+1 , f t+2 , f t+3 )∈ R 4096×1 ; Encode each feature to obtain , where e represents the dimension of each feature embedding; (4) Position Encoding PE ∈ R 4096×e The calculation formula is as follows: ; Among them pos indicates the position of the feature j indicates the position of the encoded vector Add the positional encoding PE and the input encoding to obtain H ∈ R 4096×e as the input to the multi-head attention mechanism ; (5) After passing through the multi-head attention mechanism, we get , and normalize . The label of the Transformer is g t +6 - m t+6 ; (6) After global average pooling and fully connected layers, the output predicts the GHI value after 30 minutes. p ; (7) According to the value of the GHI of the (t + 3)-th image g t +3 and the value of the GHI of the clear-sky model of the (t + 3)-th image m t+3 to evaluate the impact of light on the experiment, the prediction result after 30 minutes is the value of the GHI of the clear-sky model of the (t + 3)-th image m t+3 , otherwise it is the value of the fully-connected output 。 2. The method for short-term irradiance prediction based on Transformer according to claim 1, characterized in that: g t +3 - m t+3 Take 160, g t +3 Take 150.
Citation Information
Patent Citations
Sun tracking correction method and sun tracking correction device based on motion law of sun and image acquisition
CN106774439A
Sun irradiance predication method based on full-sky imaging equipment and device thereof
CN108121990A