Air temperature forecast error correction method and system based on space attention
By using a deep learning model in temperature forecasting combined with a spatial attention module and a fully connected correction module, the problems of system deviation and low computational efficiency of temperature forecasting in the prior art are solved, and higher forecast accuracy and computational efficiency are achieved.
Patent Information
- Application Number
- CN202411871848.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-11
AI Technical Summary
The existing temperature forecasting methods have problems of system deviation and low computational efficiency, especially when processing high-dimensional feature data, traditional methods are difficult to effectively utilize spatial information, resulting in insufficient forecast accuracy and computational efficiency.
The grid prediction correction model based on deep learning is adopted, combined with the spatial attention module and the fully connected correction module, the feature dimensions are reduced through LASSO feature selection, the calculation efficiency is improved, and the spatial distribution characteristics of temperature error are extracted using the spatial attention mechanism, and the weight of the grid is readjusted.
It improves the accuracy of temperature forecasting, reduces forecast errors, and improves calculation efficiency, so as to more effectively use the spatial information in the data to correct errors.
Smart Images

Figure CN119805626A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of meteorological information technology, and in particular to a temperature forecast error correction method and system based on spatial attention. Background Art
[0002] Temperature forecast is an important part of meteorological services. It plays an indispensable role in the normal operation of society and daily life, especially in providing a scientific basis for preventing disasters caused by extreme temperatures. Extreme temperature is a type of extreme weather, which refers to temperature conditions that are rarely seen in historical records in a certain area within a certain period of time. In the context of climate change, the frequency of extreme weather events (extreme high temperature, low temperature and cold damage, heavy rain, etc.) has been on the rise since the last century. The economic losses caused by extreme weather and the impact on society are very huge, and even cause exponential growth in the loss of people's lives and property safety. Among them, extreme high temperatures in summer have extensive harm to human health, agriculture and animal husbandry, food security, infrastructure and ecosystems. The increasingly severe and frequent high temperature conditions in summer in recent years have attracted great attention. Therefore, studying the influencing factors of summer high temperature and accurately predicting the area and time of high temperature events are of great practical significance for reducing the losses caused by disasters.
[0003] At present, the main method for predicting temperature is numerical weather prediction (NWP). It projects the atmospheric system onto a discrete numerical grid, sets initial values and configures boundary conditions based on meteorological principles, solves the nonlinear equations of fluid mechanics and thermodynamics that describe the weather evolution process on a supercomputer, and estimates the atmospheric motion state and weather phenomena for a certain period of time in the future, thereby predicting meteorological elements such as temperature and precipitation. Due to the influence of the accuracy of the initial field and boundary values, as well as the cumulative effect of the errors in the numerical calculation itself, there are inherent systematic deviations in the results of numerical weather forecasts. At the same time, the numerical weather forecast system and meteorological observation system operate around the clock at a fixed frequency, generating a massive amount of historical data. Weather forecast data contains three-dimensional spatial information: in the vertical direction, the atmosphere is divided into several layers according to the height above the ground, among which the weather conditions in the surface layer directly affect human activities, and extreme high temperature events occur in this layer; in the horizontal direction, it is projected into a discrete two-dimensional grid, that is, a matrix composed of grid points represented by longitude and latitude coordinates. The traditional error correction method is model output statistics (MOS), which usually adopts statistical methods such as multivariate linear regression and logistic regression.
[0004] Recently, many researchers have explored modern machine learning methods, such as random forests and neural networks, to replace statistical methods and reduce the deviation of physical model output results. However, the disadvantage of these methods is that they must be modeled separately for specific locations, ignoring the spatial information in the data, which affects the accuracy of the forecast. In order to improve accuracy, a large amount of calculations will be performed, which will affect the calculation efficiency. Summary of the invention
[0005] One of the purposes of the present invention is to provide a temperature forecast error correction method based on spatial attention, which can correct the errors of grid temperature in temperature forecast, improve the accuracy of forecast, and also improve the calculation efficiency.
[0006] The basic solution 1 provided by the present invention: a temperature forecast error correction method based on spatial attention, including the following contents:
[0007] S1. Obtain H types of forecast data in the forecast area and perform preprocessing;
[0008] S2. For the preprocessed forecast data, LASSO is used to select features and obtain h kinds of forecast data as features; where H>h;
[0009] S3. Construct a grid forecast correction model based on deep learning; the structure of the grid forecast correction model includes: a spatial attention module and a fully connected correction module, taking the feature as input data, inputting it into the spatial attention module, calculating the weight of each position of the input data, and obtaining a new feature map; inputting the new feature map into the fully connected correction module, and using the fully connected network to obtain the correction data;
[0010] S4, dividing the data set of forecast data used as features into a training set and a test set, using the training set to train the grid forecast correction model, and using the test set to test the trained grid forecast correction model;
[0011] S5. Use the grid forecast correction model that has passed the test to correct the errors of the grid temperature in the temperature forecast.
[0012] Furthermore, the preprocessing includes: format conversion, data cleaning and standardization;
[0013] Format conversion: convert NetCDF format to tensor format;
[0014] Data cleaning: delete missing and invalid values in forecast data;
[0015] Standardization: Standardize the data based on the mean and standard deviation of the original data:
[0016]
[0017] In the formula, x is a data in the original data, μ represents the mean of the original data, and σ represents the standard deviation of the original data; the original data is the forecast data after format conversion and data cleaning.
[0018] Furthermore, the penalty function of the LASSO is L1 regularization:
[0019] loss=||y-Xw|| 2 +α||w||.
[0020] Furthermore, the S1 also includes: acquiring reanalysis data of the forecast area, and preprocessing the reanalysis data.
[0021] Further, the S2 includes:
[0022] S201, all grid points in the forecast data are scattered to form a two-dimensional matrix of H columns, denoted as X; the difference between the forecast temperature in each row and the reanalysis temperature in the corresponding reanalysis data is denoted as y;
[0023] S202, standardize X, unify the dimensions, and transform all columns into vectors with a mean of 0 and a variance of 1;
[0024] S203, inputting X and y into the LASSO model for fitting training;
[0025] S204. Check the correlation coefficients of the features in the trained LASSO model, and retain the features that are not zero as correction factors.
[0026] Furthermore, the grid point forecast correction model adopts mean square error MSE as the loss function:
[0027]
[0028] Among them, y i and They represent the true value and the revised value respectively, that is, the true data of temperature in the reanalysis data and the corresponding forecast data.
[0029] Furthermore, the grid point forecast correction model that passes the test is a grid point forecast correction model whose mean square error MSE after training is less than a threshold value.
[0030] The second purpose of the present invention is to provide a temperature forecast error correction system based on spatial attention, which can correct the errors of grid temperature in temperature forecast, improve the accuracy of forecast, and also improve the calculation efficiency.
[0031] The present invention provides a second basic solution: a temperature forecast error correction system based on spatial attention, comprising: a data acquisition module, a data processing module, a model building module, and a data analysis module;
[0032] A data acquisition module is used to obtain H types of forecast data in the forecast area;
[0033] The data processing module is used to preprocess the forecast data, and use LASSO to select features of the preprocessed forecast data to obtain h types of forecast data as features; where H>h;
[0034] A model building module is used to build a grid forecast correction model based on deep learning; the structure of the grid forecast correction model includes: a spatial attention module and a fully connected correction module, which takes the feature as input data and inputs it into the spatial attention module, calculates the weight of each position of the input data, and obtains a new feature map; the new feature map is input into the fully connected correction module, and the correction data is obtained using the fully connected network;
[0035] It is also used to divide the data set of forecast data used as features into a training set and a test set, use the training set to train the grid forecast correction model, and use the test set to test the trained grid forecast correction model;
[0036] The data analysis module is used to correct the errors of the grid point temperatures in the temperature forecast by constructing a grid point forecast correction model that has passed the training and testing.
[0037] Furthermore, the data acquisition module is also used to acquire reanalysis data of the forecast area;
[0038] The data processing module is also used to pre-process the reanalysis data.
[0039] Furthermore, the grid point forecast correction model adopts mean square error MSE as the loss function:
[0040]
[0041] Among them, y i and Respectively represent the true value and the revised value, that is, the true data of temperature in the reanalysis data and the corresponding forecast data;
[0042] The grid point forecast correction model that passes the test is a grid point forecast correction model whose mean square error MSE after training is less than a threshold.
[0043] Beneficial effects: This scheme is an error correction method for grid-type numerical temperature forecast results; first, for the problem of large feature dimensions in the numerical temperature forecast results, the LASSO regression method is used for feature selection, and finally h variables with high correlation with the temperature error are selected as correction factors, which effectively improves the calculation efficiency and solves the problem of slow training speed due to large amount of calculation, and the high feature dimension will cause the number of model parameters to increase dramatically, resulting in non-convergence;
[0044] Then, we designed and trained a grid forecast correction model based on deep learning, using the attention mechanism to identify the spatial distribution characteristics of temperature errors, thereby readjusting the weights of the grid points. This solves the problem that although the fully connected network can reduce the forecast error to a certain extent, this method processes each grid point in isolation and ignores the spatial correlation contained in the data.
[0045] Through experimental comparison, it is found that both the fully connected network and can reduce the forecast error. The fully connected network can use the correction factor to a certain extent to capture the error change law of the forecast system in terms of temperature. However, the data corrected by the fully connected network model still has certain errors, and the degree of error is strongly correlated with the original forecast data. The spatial attention module in this scheme improves the model correction effect, further verifies the impact of geographical location differences on the distribution of temperature errors, and can use the spatial information in historical data to promote the development of error correction technology.
[0046] In summary, this scheme can correct the error of the grid temperature in the temperature forecast, improve the accuracy of the forecast, and also improve the calculation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 It is a structural schematic diagram of a grid point forecast correction model in an embodiment of the temperature forecast error correction method based on spatial attention of the present invention;
[0048] Figure 2 It is a structural schematic diagram of a fully connected network correction model in an embodiment of a temperature forecast error correction method based on spatial attention of the present invention;
[0049] Figure 3 It is a structural schematic diagram of spatial attention in an embodiment of a temperature forecast error correction method based on spatial attention of the present invention;
[0050] Figure 4 It is a schematic diagram of the comparison of mean absolute error (MAE) in the embodiment of the temperature forecast error correction method based on spatial attention of the present invention;
[0051] Figure 5 It is a schematic diagram of the comparison of mean square error MSE in the temperature forecast error correction method based on spatial attention of the present invention;
[0052] Figure 6 It is a schematic diagram of the comparison of errors before and after correction in the embodiment of the temperature forecast error correction method based on spatial attention of the present invention;
[0053] Figure 7 It is a schematic diagram of the temperature comparison before and after correction in the embodiment of the temperature forecast error correction method based on spatial attention of the present invention. DETAILED DESCRIPTION
[0054] The following is further described in detail through specific implementation methods:
[0055] Embodiment 1
[0056] This embodiment provides a temperature forecast error correction method based on spatial attention, including the following contents:
[0057] S1. Obtain H types of forecast data and reanalysis data in the forecast area, and preprocess the forecast data and reanalysis data;
[0058] The forecast data include: air temperature, air pressure, wind speed, dew point temperature, specific humidity, etc. at each altitude layer, totaling H variables;
[0059] The forecast area in this embodiment is area A, with a longitude coverage range of 94.65°E to 128.55°E, and a latitude range of 34.90°N to 55.80°N; the horizontal resolution of the forecast data is 0.05°, and the total number of grid points is 679×419; the forecast data adopts the hourly forecast data from 2019 to 2023 provided by the numerical model of area A, including 49 variables such as air temperature, air pressure, wind speed, dew point temperature, specific humidity, etc. at each altitude layer, that is, H=49.
[0060] In this embodiment, the reanalysis data is the real data of temperature, that is, the real surface temperature data, which comes from the ERA5 (The Fifth Generation ECMWF Reanalysis) data set. The surface temperature data with the same longitude and latitude, time range and resolution as the forecast data are selected from the ERA5 data set as the real value output by the subsequent grid forecast correction model.
[0061] The forecast data and reanalysis data are preprocessed, including format conversion, data cleaning and standardization;
[0062] Format conversion: Both forecast data and reanalysis data are in NetCDF format, containing indexes such as longitude, latitude, altitude and time. They cannot be directly used for subsequent model training and need to be converted into tensor format. For forecast data, longitude and latitude are retained as the width and height dimensions of the tensor, while all meteorological elements contained in different altitude layers are connected to form the channel dimension. The processed data is used as the input X of the model, and its shape is 679×419×49. Similarly, the real value data of temperature is used as the output y of the model after processing, and its shape is 679×419×1.
[0063] Data cleaning: The numerical forecast data contains some missing values (such as "NA") and invalid values (such as "99999"), which need to be cleaned. The method used in this embodiment is to delete the records containing such data;
[0064] Standardization: In order to speed up the convergence of the neural network model and improve the accuracy of the model, the training data needs to be standardized. This embodiment always adopts the Z-Score standardization method, that is, the data is standardized based on the mean and standard deviation of the original data:
[0065]
[0066] In the formula, x is a data in the original data, μ represents the mean of the original data, and σ represents the standard deviation of the original data; the original data are the forecast data and reanalysis data after format conversion and data cleaning.
[0067] S2. For the preprocessed forecast data, LASSO is used to select features and obtain h kinds of forecast data as features; where H>h;
[0068] If the preprocessed forecast data is used as features directly for subsequent neural network (grid forecast correction model) training, the amount of calculation is too large, the training speed is slow, and the high feature dimension will cause a sharp increase in the number of model parameters, resulting in failure to converge. Therefore, it is necessary to screen the forecast data and remove unnecessary features;
[0069] Among them, LASSO (Least Absolute Shrinkage and Selection Operator) regression aims to reduce the feature set (order reduction). It is a shrinkage estimation method. The LASSO method can compress the coefficients of the features and make some regression coefficients become 0, thereby achieving the purpose of feature selection. It can be used for model improvement and feature selection, and can also be used for dimensionality reduction of meteorological data. Feature selection is essentially a process of seeking sparse expression, and this process can be completed by optimizing a function problem of "loss" and "penalty". The penalty function is L1 regularization, that is:
[0070] loss=||y-Xw|| 2 +α||w||;
[0071] In this embodiment, the regression model LASSO in the sklearn machine learning algorithm library is used for feature prediction, the forecast data is used as input, the forecast error is used as the training target, the regression model is trained and the correlation coefficient between the feature and the target is calculated. The specific steps are as follows:
[0072] S201, all grid points in the forecast data are scattered to form a two-dimensional matrix of H columns, denoted as X; the difference between the forecast temperature in each row and the corresponding reanalysis temperature is taken as y, that is, the difference between the predicted temperature in the forecast data and the reanalysis temperature in the reanalysis data is taken as y;
[0073] S202, standardize X, unify the dimensions, and transform all columns into vectors with a mean of 0 and a variance of 1;
[0074] S203, inputting X and y into the LASSO model for fitting training; using the LASSO model for fitting, the number of fittings is not fixed. When the characteristic coefficient hardly changes after multiple consecutive fittings, or the amplitude of the change is very small, it means that the model has found a relatively stable solution, and the fitting can be ended. That is, after each fitting, the difference with the previous fitting result is judged. If the difference is less than the preset difference, the fitting is ended and the training is completed;
[0075] S204, check the correlation coefficient of the features in the trained LASSO model, and retain the features that are not zero as correction factors; in this embodiment, there are 6 features retained, as shown in the following Table 1:
[0076] Table 1: Feature selection results
[0077] Feature Name meaning Correlation coefficient 2t_0 2 meter temperature -0.18987900239957478 orog_0 terrain -0.119616693469475 2d_0 2m dew point temperature -2.8804451757755754 r_0 Relative humidity 2.0966347724913152 pt_200 200hPa layer high temperature -0.6915292341698964 v_200 200hPa layer height meridional wind -0.6921449882842785
[0078] The LASSO regression method is used to screen the temperature correction factors, which reduces the number of features from 49 in the original data to 6, which is beneficial to improving the calculation efficiency.
[0079] S3. Construct a grid forecast correction model based on deep learning;
[0080] The structure of the grid prediction correction model includes: spatial attention module and fully connected correction module, such as Figure 1 As shown; the features are used as input data (the original data in the attached figure) and input into the spatial attention module to calculate the weights of each position of the input data to obtain a new feature map; the new feature map is input into the fully connected correction module, and the fully connected network is used to obtain the corrected data, that is, the final corrected temperature;
[0081] The grid forecast correction based on deep learning is to use the deep neural network model to learn the mapping relationship between the forecast data of historical grid points and the historical real data (reanalysis data), so as to correct the numerical forecast results and produce more accurate forecasts; the historical forecast data and the real data have the same spatial and temporal resolution, and the forecast area is discretized as an M×N grid, where M is the number of rows and N is the number of columns. The data on each grid point contains C physical quantities of different heights; therefore, each forecast data and the corresponding real data can be represented as two three-dimensional tensors: X, Y∈R C×M×N , where R represents the value space of the forecast elements, so the grid correction problem can be regarded as constructing a correction function f θ ∈R C×M×N →R C×M×N , which can transform the forecast data to obtain a forecast that is closer to the actual data distribution And satisfy:
[0082]
[0083] Among them, θ is the parameter vector of the correction function, and ε is an arbitrarily small positive real number. The correction function is fitted by training the deep neural network model to minimize the gap between the correction result and the real data.
[0084] The temperature data changes are relatively continuous and evenly distributed. The numerical simulation error is mainly affected by the terrain, surface, atmosphere, etc. The three-layer fully connected neural network model is used to fit the correction function on a single grid point, which can effectively reduce the forecast error. In order to realize the correction of the temperature of all grid points in the entire forecast area, a single-point correction model is constructed for each grid point, and then merged into a regional correction model according to the shape of the grid, such as Figure 2 As shown;
[0085] Although the fully connected network can reduce the forecast error to a certain extent, this method processes each grid point in isolation and ignores the spatial correlation contained in the data. The temperature change is greatly affected by the region, and the forecast error varies greatly between the grid points in the entire forecast area, and shows a certain regularity. In order to further improve the correction effect, the spatial attention mechanism is used to extract this change pattern. The spatial attention mechanism is a technology that enhances the ability of information extraction and representation in deep learning models. The spatial attention structure is shown in the figure. Figure 3 As shown in Figure 2, we can dynamically assign weights to different positions based on the correlation between input and output, thereby highlighting important information and constructing a Figure 1 The grid forecast correction model based on deep learning is shown.
[0086] S4, dividing the data set of forecast data used as features into a training set and a test set, using the training set to train the grid forecast correction model, and using the test set to test the trained grid forecast correction model;
[0087] In this embodiment, the forecast data from 2019 to 2022 are used for model training, 80% of which are selected as the training set and 20% as the validation set; the data from 2023 are used to test the grid forecast correction model to evaluate the correction effect;
[0088] The initial learning rate of the grid prediction correction model is 1, and the batch size is 16. To avoid the training process falling into the local optimum, the learning rate is attenuated by a decay coefficient of 0.1. The weights of the grid prediction correction model are trained by the stochastic gradient descent method, and the maximum training generation is 50. Since temperature is a continuous variable, the mean square error MSE is used as the loss function in this embodiment:
[0089]
[0090] Among them, y i and They represent the true value and the corrected value respectively, that is, the true data of temperature in the reanalysis data and the corresponding forecast data; in this embodiment, the deep learning model is implemented using pytorch, and the training device is a server equipped with Nvidia A100.
[0091] S5. Use the grid forecast correction model that has passed the test to correct the error of the grid temperature in the temperature forecast;
[0092] Among them, the grid forecast correction model that passes the test is the grid forecast correction model whose mean square error (MSE) after training is less than the threshold.
[0093] The data collected in S1 are used for comparative experiments. The forecast effect of temperature is mainly evaluated by mean square error (MSE) and mean absolute error (MAE). Figure 4 and Figure 5 As shown, the error MSE and MAE of the numerical forecast with a forecast time of 13h-48h, the correction using the fully connected network in the existing technology and the model correction of this scheme are compared respectively;
[0094] Figure 4 and Figure 5 In the middle figure, from top to bottom, they are the original forecast data before correction, the data corrected by the fully connected network, and the data corrected by the grid forecast correction model based on deep learning in this scheme. From left to right, they are the forecast time periods of 13 to 48 hours, and the network parameters of the correction model for each forecast time period are trained separately; Figure 4 and Figure 5It can be seen that the MSE and MAE of each forecast time are smaller after correction, and as the numerical forecast error increases, the error after correction also shows an increasing trend.
[0095] A forecast for a high temperature period in summer is selected from the test set, and the error value of the numerical forecast and the temperature error after correction are visualized. Figure 6 As shown, (a) is the real temperature, i.e. the true value, (b) is the forecast temperature error, (c) is the temperature error after correction by the fully connected network, and (d) is the temperature error after correction by the grid forecast correction model based on deep learning; from Figure 6 It can be seen that the original forecast data is generally lower than the actual value. After correction, the situation has improved and the overall error is closer to 0. In the error map after correction by the fully connected model, the area where the forecast is lower than the actual value and the absolute value is above 2° (blue) is significantly less than the original data. The error map after correction by the grid forecast correction model based on deep learning is generally similar to the former, and the error situation has improved in some areas (such as central and eastern Inner Mongolia, between 115°E and 120°E, and near the 45°N mark line).
[0096] like Figure 7 As shown, (a) is the real temperature, that is, the true value, (b) is the forecast temperature, (c) is the temperature after correction by the fully connected network, and (d) is the temperature after correction by the grid forecast correction model based on deep learning. The temperature data values are visualized, and it can be seen that the corrected temperature is closer to the true value, and the correction effect of this scheme is better than that of the fully connected network in the prior art.
[0097] In summary, this scheme is an error correction method for grid-type numerical temperature forecast results; first, for the problem of large feature dimensions in the numerical temperature forecast results, the LASSO regression method is used for feature selection, and finally h variables with high correlation with the temperature error are selected as correction factors. In this embodiment, there are 6 forecast data, including 2-meter temperature, terrain, 2-meter dew point temperature, relative humidity, 200hPa layer height temperature and 200hPa layer height meridional wind;
[0098] Then, a grid forecast correction model based on deep learning was designed and trained, using the attention mechanism to identify the spatial distribution characteristics of temperature errors and thus readjust the weights of the grid points.
[0099] Through experimental comparison, it is found that both the fully connected network and the grid forecast correction model based on deep learning can reduce the forecast error. The fully connected network can use the correction factor to a certain extent to capture the error change law of the forecast system in terms of temperature. However, the data corrected by the fully connected network model still has certain errors, and the degree of error is strongly correlated with the original forecast data. The improvement of the model correction effect by the spatial attention module further verifies the impact of geographical location differences on the distribution of temperature errors. The spatial information in historical data can be used to promote the development of error correction technology.
[0100] Embodiment 2
[0101] This embodiment is basically as shown in the accompanying drawings: a temperature forecast error correction system based on spatial attention includes: a data acquisition module, a data processing module, a model building module, and a data analysis module;
[0102] Data acquisition module, used to obtain H types of forecast data and reanalysis data in the forecast area;
[0103] The forecast data include: air temperature, air pressure, wind speed, dew point temperature, specific humidity, etc. at each altitude layer, totaling H variables;
[0104] The forecast area in this embodiment is area A, with a longitude coverage range of 94.65°E to 128.55°E, and a latitude range of 34.90°N to 55.80°N; the horizontal resolution of the forecast data is 0.05°, and the total number of grid points is 679×419; the forecast data adopts the hourly forecast data from 2019 to 2023 provided by the numerical model of area A, including 49 variables such as air temperature, air pressure, wind speed, dew point temperature, specific humidity, etc. at each altitude layer, that is, H=49.
[0105] In this embodiment, the reanalysis data is the real data of temperature, that is, the real surface temperature data, which comes from the ERA5 (The Fifth Generation ECMWF Reanalysis) data set. The surface temperature data with the same longitude and latitude, time range and resolution as the forecast data are selected from the ERA5 data set as the real value output by the subsequent grid forecast correction model.
[0106] The data processing module is used to preprocess the forecast data and reanalysis data, and use LASSO to select features of the preprocessed forecast data to obtain h types of forecast data as features; where H>h;
[0107] The forecast data and reanalysis data are preprocessed, including format conversion, data cleaning and standardization;
[0108] Format conversion: Both forecast data and reanalysis data are in NetCDF format, containing indexes such as longitude, latitude, altitude and time. They cannot be directly used for subsequent model training and need to be converted into tensor format. For forecast data, longitude and latitude are retained as the width and height dimensions of the tensor, while all meteorological elements contained in different altitude layers are connected to form the channel dimension. The processed data is used as the input X of the model, and its shape is 679×419×49. Similarly, the real value data of temperature is used as the output y of the model after processing, and its shape is 679×419×1.
[0109] Data cleaning: The numerical forecast data contains some missing values (such as "NA") and invalid values (such as "99999"), which need to be cleaned. The method used in this embodiment is to delete the records containing such data;
[0110] Standardization: In order to speed up the convergence of the neural network model and improve the accuracy of the model, the training data needs to be standardized. This embodiment always adopts the Z-Score standardization method, that is, the data is standardized based on the mean and standard deviation of the original data:
[0111]
[0112] In the formula, x is a data in the original data, μ represents the mean of the original data, and σ represents the standard deviation of the original data; the original data are the forecast data and reanalysis data after format conversion and data cleaning.
[0113] If the preprocessed forecast data is used as features directly for subsequent neural network (grid forecast correction model) training, the amount of calculation is too large, the training speed is slow, and the high feature dimension will cause a sharp increase in the number of model parameters, resulting in failure to converge. Therefore, it is necessary to screen the forecast data and remove unnecessary features;
[0114] Among them, LASSO (Least Absolute Shrinkage and Selection Operator) regression aims to reduce the feature set (order reduction). It is a shrinkage estimation method. The LASSO method can compress the coefficients of the features and make some regression coefficients become 0, thereby achieving the purpose of feature selection. It can be used for model improvement and feature selection, and can also be used for dimensionality reduction of meteorological data. Feature selection is essentially a process of seeking sparse expression, and this process can be completed by optimizing a function problem of "loss" and "penalty". The penalty function is L1 regularization, that is:
[0115] loss=||y-Xw|| 2 +α||w||;
[0116] In this embodiment, the regression model LASSO in the sklearn machine learning algorithm library is used for feature prediction, the forecast data is used as input, the forecast error is used as the training target, the regression model is trained and the correlation coefficient between the feature and the target is calculated. The specific steps are as follows:
[0117] All grid points in the forecast data are scattered to form a two-dimensional matrix of H columns, denoted as X; the difference between the forecast temperature in each row and the corresponding reanalysis temperature is taken as y, that is, the difference between the predicted temperature in the forecast data and the reanalysis temperature in the reanalysis data is taken as y;
[0118] Standardize X, unify the dimensions, and transform all columns into vectors with a mean of 0 and a variance of 1;
[0119] Input X and y into the LASSO model for fitting training; use the LASSO model for fitting, the number of fittings is not fixed, when the characteristic coefficient hardly changes after multiple consecutive fittings, or the change amplitude is very small, it means that the model has found a relatively stable solution, and the fitting can be ended, that is, after each fitting, the difference with the previous fitting result is judged, if the difference is less than the preset difference, the fitting is ended and the training is completed;
[0120] After training, the correlation coefficient of the features is checked in the LASSO model, and the features that are not zero are retained as correction factors; in this embodiment, a total of 6 features are retained, as shown in Table 1;
[0121] The LASSO regression method is used to screen the temperature correction factors, which reduces the number of features from 49 in the original data to 6, which is beneficial to improving the calculation efficiency.
[0122] The model building module is used to build a grid prediction correction model based on deep learning; the structure of the grid prediction correction model includes: a spatial attention module and a fully connected correction module, such as Figure 1 As shown, the features are used as input data and input into the spatial attention module to calculate the weights of each position of the input data to obtain a new feature map; the new feature map is input into the fully connected correction module, and the fully connected network is used to obtain the corrected data, that is, the final corrected temperature;
[0123] The grid forecast correction based on deep learning is to use the deep neural network model to learn the mapping relationship between the forecast data of historical grid points and the historical real data (reanalysis data), so as to correct the numerical forecast results and produce more accurate forecasts; the historical forecast data and the real data have the same spatial and temporal resolution, and the forecast area is discretized as an M×N grid, where M is the number of rows and N is the number of columns. The data on each grid point contains C physical quantities of different heights; therefore, each forecast data and the corresponding real data can be represented as two three-dimensional tensors: X, Y∈RC×M×N , where R represents the value space of the forecast elements, so the grid correction problem can be regarded as constructing a correction function f θ ∈R C×M×N →R C×M×N , which can transform the forecast data to obtain a forecast that is closer to the actual data distribution And satisfy:
[0124]
[0125] Among them, θ is the parameter vector of the correction function, and ε is an arbitrarily small positive real number. The correction function is fitted by training the deep neural network model to minimize the gap between the correction result and the real data.
[0126] The temperature data changes are relatively continuous and evenly distributed. The numerical simulation error is mainly affected by the terrain, surface, atmosphere, etc. The three-layer fully connected neural network model is used to fit the correction function on a single grid point, which can effectively reduce the forecast error. In order to realize the correction of the temperature of all grid points in the entire forecast area, a single-point correction model is constructed for each grid point, and then merged into a regional correction model according to the shape of the grid, such as Figure 2 As shown;
[0127] Although the fully connected network can reduce the forecast error to a certain extent, this method processes each grid point in isolation and ignores the spatial correlation contained in the data. The temperature change is greatly affected by the region, and the forecast error varies greatly between the grid points in the entire forecast area, and shows a certain regularity. In order to further improve the correction effect, the spatial attention mechanism is used to extract this change pattern. The spatial attention mechanism is a technology that enhances the ability of information extraction and representation in deep learning models. The spatial attention structure is shown in the figure. Figure 3 As shown in Figure 2, we can dynamically assign weights to different positions based on the correlation between input and output, thereby highlighting important information and constructing a Figure 1 The grid forecast correction model based on deep learning is shown.
[0128] It is also used to divide the data set of forecast data used as features into a training set and a test set, use the training set to train the grid forecast correction model, and use the test set to test the trained grid forecast correction model;
[0129] In this embodiment, the forecast data from 2019 to 2022 are used for model training, 80% of which are selected as the training set and 20% as the validation set; the data from 2023 are used to test the grid forecast correction model to evaluate the correction effect;
[0130] The initial learning rate of the grid prediction correction model is 1, and the batch size is 16. To avoid the training process falling into the local optimum, the learning rate is attenuated by a decay coefficient of 0.1. The weights of the grid prediction correction model are trained by the stochastic gradient descent method, and the maximum training generation is 50. Since temperature is a continuous variable, the mean square error MSE is used as the loss function in this embodiment:
[0131]
[0132] Among them, y i and Represent the true value and the corrected value respectively, that is, the true data of temperature in the reanalysis data and the corresponding forecast data; the deep learning model in this embodiment is implemented using pytorch, and the training device is a server equipped with NvidiaA100.
[0133] The data analysis module is used to correct the errors of the grid temperature in the temperature forecast by constructing a grid forecast correction model that has passed the training test; the grid forecast correction model that has passed the test is a grid forecast correction model whose mean square error MSE after training is less than a threshold.
[0134] This scheme can correct the errors of the grid temperature in the temperature forecast, improve the accuracy of the forecast, and also improve the calculation efficiency.
[0135] The above is only an embodiment of the present invention. The common sense such as the known specific structure and characteristics in the scheme is not described in detail here. The ordinary technicians in the relevant field know all the common technical knowledge in the technical field of the invention before the application date or priority date, can obtain all the existing technologies in the field, and have the ability to apply the conventional experimental means before that date. The ordinary technicians in the relevant field can improve and implement this scheme in combination with their own abilities under the enlightenment given by this application. Some typical known structures or known methods should not become obstacles for ordinary technicians in the relevant field to implement this application. It should be pointed out that for those skilled in the art, without departing from the structure of the present invention, several deformations and improvements can be made, which should also be regarded as the protection scope of the present invention, which will not affect the effect of the implementation of the present invention and the practicality of the patent. The protection scope required by this application shall be based on the content of its claims, and the specific implementation methods and other records in the specification can be used to interpret the content of the claims.
Claims
1. A temperature forecast error correction method based on spatial attention, characterized in that: It includes the following: S1. Obtain H types of forecast data in the forecast area and perform preprocessing; S2. For the preprocessed forecast data, LASSO is used to perform feature selection to obtain h types of forecast data as features; Where H>h; S3. Construct a grid prediction correction model based on deep learning; the structure of the grid prediction correction model includes: a spatial attention module and a fully connected correction module, taking the features as input data, inputting them into the spatial attention module, calculating the weights of each position of the input data, and obtaining a new feature map; Input the new feature map into the fully connected correction module and use the fully connected network to obtain the corrected data; S4, dividing the data set of forecast data used as features into a training set and a test set, using the training set to train the grid forecast correction model, and using the test set to test the trained grid forecast correction model; S5. Use the grid forecast correction model that has passed the test to correct the errors of the grid temperature in the temperature forecast.
2. The temperature forecast error correction method based on spatial attention according to claim 1 is characterized in that: The preprocessing includes: format conversion, data cleaning and standardization; Format conversion: convert NetCDF format to tensor format; Data cleaning: delete missing and invalid values in forecast data; Standardization: Standardize the data based on the mean and standard deviation of the original data: In the formula, x is a data in the original data, μ represents the mean of the original data, and σ represents the standard deviation of the original data; the original data is the forecast data after format conversion and data cleaning.
3. The temperature forecast error correction method based on spatial attention according to claim 1 is characterized in that: The penalty function of the LASSO is L1 regularization: loss=||y-Xw|| 2 +α||w||。 4. The temperature forecast error correction method based on spatial attention according to claim 1 is characterized in that: The S1 also includes: acquiring reanalysis data of the forecast area and preprocessing the reanalysis data.
5. The temperature forecast error correction method based on spatial attention according to claim 4 is characterized in that: The S2 comprises: S201, all grid points in the forecast data are scattered to form a two-dimensional matrix of H columns, denoted as X; the difference between the forecast temperature in each row and the reanalysis temperature in the corresponding reanalysis data is denoted as y; S202, standardize X, unify the dimensions, and transform all columns into vectors with a mean of 0 and a variance of 1; S203, inputting X and y into the LASSO model for fitting training; S204. Check the correlation coefficients of the features in the trained LASSO model, and retain the features that are not zero as correction factors.
6. The temperature forecast error correction method based on spatial attention according to claim 4 is characterized in that: The grid point forecast correction model adopts mean square error MSE as the loss function: Among them, y i and They represent the true value and the revised value respectively, that is, the true data of temperature in the reanalysis data and the corresponding forecast data.
7. The temperature forecast error correction method based on spatial attention according to claim 6 is characterized in that: The grid point forecast correction model that passes the test is a grid point forecast correction model whose mean square error MSE after training is less than a threshold.
8. The temperature forecast error correction system based on spatial attention is characterized by: include: Data acquisition module, data processing module, model building module, data analysis module; A data acquisition module is used to obtain H types of forecast data in the forecast area; The data processing module is used to preprocess the forecast data, and use LASSO to select features of the preprocessed forecast data to obtain h types of forecast data as features; Where H>h; A model building module is used to build a grid forecast correction model based on deep learning; the structure of the grid forecast correction model includes: a spatial attention module and a fully connected correction module, which takes the feature as input data and inputs it into the spatial attention module, calculates the weight of each position of the input data, and obtains a new feature map; the new feature map is input into the fully connected correction module, and the correction data is obtained using the fully connected network; It is also used to divide the data set of forecast data used as features into a training set and a test set, use the training set to train the grid forecast correction model, and use the test set to test the trained grid forecast correction model; The data analysis module is used to correct the errors of the grid point temperatures in the temperature forecast by constructing a grid point forecast correction model that has passed the training and testing.
9. The temperature forecast error correction system based on spatial attention according to claim 8, characterized in that: The data acquisition module is also used to acquire reanalysis data of the forecast area; The data processing module is also used to pre-process the reanalysis data.
10. The temperature forecast error correction system based on spatial attention according to claim 8, characterized in that: The grid point forecast correction model adopts mean square error MSE as the loss function: Among them, y i and Respectively represent the true value and the revised value, that is, the true data of temperature in the reanalysis data and the corresponding forecast data; The grid point forecast correction model that passes the test is a grid point forecast correction model whose mean square error MSE after training is less than a threshold.
Citation Information
Cited By
Multi-meteorological factor mode forecast temperature correction method based on deep learning
CN120951104A