CNN-GRU rainfall space-time interpolation method based on attention mechanism

By using the attention-based CNN-GRU method, which combines satellite-retrieved rainfall data and rain gauge data, the problems of missing feature information and high computational complexity of sparse meteorological station data are solved, achieving higher accuracy and lower complexity in spatiotemporal rainfall interpolation.

CN120952050APending Publication Date: 2025-11-14HOHAI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410591289.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-13
Publication Date
2025-11-14

AI Technical Summary

Technical Problem

Existing spatiotemporal interpolation methods for rainfall suffer from problems such as missing feature information and high computational complexity when processing sparse meteorological station data. In particular, the interpolation effect is poor when the data is incomplete or has a lot of noise, and the methods do not pay enough attention to the heterogeneity of spatial data and the spatiotemporal nonlinear correlation.

Method used

We employ a CNN-GRU spatiotemporal interpolation method for rainfall based on an attention mechanism. This method combines the spatial heterogeneity of satellite-retrieved rainfall data with high-precision point estimation from rain gauge data. CNN and GRU are used to extract the spatial heterogeneity and temporal correlation of rainfall, respectively. An attention mechanism is introduced to focus on important features from both global and local perspectives, thereby improving interpolation accuracy and model robustness.

Benefits of technology

It improves the accuracy of rainfall interpolation and the robustness of the model, reduces computational complexity, better adapts to complex spatiotemporal relationships and nonlinear changes, and enhances prediction accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120952050A_ABST
    Figure CN120952050A_ABST
Patent Text Reader

Abstract

The invention discloses a CNN-GRU rainfall space-time interpolation method based on an attention mechanism, and the method comprises the steps: obtaining drainage basin rainfall data, and carrying out the preprocessing of the drainage basin rainfall data; gridding processing is carried out on the rainfall data of the drainage basin; establishing a geographic coordinate conversion hash table, extracting drainage basin rainfall data, and dividing the data into a training set and a test set; confirming structures of a convolutional neural network CNN and a bidirectional gating circulation unit GRU; an Attention mechanism is introduced, and for feature vectors output by the GRU, probabilities corresponding to different feature vectors are calculated according to a weight distribution principle; training a CNN-GRU rainfall space-time interpolation model based on the attention mechanism by using the training set, adjusting hyper-parameters, and iterating an optimal model; performing interpolation prediction and generating raster data, and finally evaluating an interpolation result. According to the method, multi-source data are fused, an Attention mechanism is introduced to guide the neural network to pay attention to important features from global and local angles, and the rainfall interpolation precision and the model robustness are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of rainfall interpolation technology in the water conservancy industry, specifically involving a CNN-GRU spatiotemporal interpolation method for rainfall based on an attention mechanism. Background Technology

[0002] Rainfall data is a crucial component in rainfall-runoff forecasting, and its observation accuracy directly impacts the accuracy and effectiveness of rainfall-runoff forecast modeling. Traditional rainfall observation data primarily comes from ground-based meteorological stations, but configuring these stations requires significant manpower and resources, resulting in sparse station density and an inability to accurately reflect the spatiotemporal distribution patterns of rainfall. Rainfall spatiotemporal interpolation algorithms effectively address this issue.

[0003] Existing spatiotemporal data interpolation methods can be broadly categorized into three types: temporal interpolation (such as linear interpolation and polynomial interpolation), spatial interpolation (such as inverse distance weighting, spline function interpolation, and Kriging), and spatiotemporal interpolation. Temporal and spatial interpolation only consider the temporal and spatial correlations of the data itself, often leading to missing feature information and inaccurate interpolation results. Spatiotemporal interpolation methods, on the other hand, consider both the temporal and spatial correlations of the data. However, traditional spatiotemporal interpolation methods are typically based on mathematical and statistical principles, using manually selected features and models for interpolation, requiring significant human intervention and domain knowledge, and exhibiting poor interpolation performance when data is incomplete or noisy. In contrast, deep learning-based spatiotemporal interpolation methods are better suited to complex spatiotemporal relationships and nonlinear variations, typically exhibiting higher prediction accuracy and stronger generalization ability.

[0004] The journal article "A spatiotemporal deepfusion model for merging satellite and gauge precipitation in China," published in Volume 584 of the Journal of Hydrology, utilizes a convolutional neural network (CNN) and a long short-term memory network (LSTM) to learn the spatial distribution and temporal characteristics of precipitation retrieved from satellites. It interpolates precipitation by predicting rainfall in unobserved areas, demonstrating good interpolation performance across different time scales and spatial ranges. However, this spatiotemporal interpolation method has high computational complexity, requiring a large amount of training data and parameters, resulting in significant computational resource consumption. Furthermore, this method does not adequately address the spatial heterogeneity and spatiotemporal nonlinear correlations of the spatial data, leading to a decrease in interpolation accuracy. Summary of the Invention

[0005] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a CNN-GRU spatiotemporal interpolation method for rainfall based on an attention mechanism. This method combines the spatial heterogeneity of satellite-retrieved rainfall data with the high-precision point estimation characteristics of rain gauge data. It uses multi-source data as input, employs CNN and GRU to extract the spatial heterogeneity and temporal correlation of rainfall respectively, and introduces an attention mechanism to guide the neural network to focus on important features from both global and local perspectives, thereby improving the accuracy of rainfall interpolation and the robustness of the model.

[0006] To solve the above-mentioned technical problems, the present invention adopts the following technical solution.

[0007] The present invention provides a CNN-GRU spatiotemporal interpolation method for rainfall based on an attention mechanism, comprising the following steps:

[0008] Step 1. Obtain watershed rainfall data and preprocess the watershed rainfall data;

[0009] Step 2. Grid-process the watershed rainfall data;

[0010] Step 3. Establish a geographic coordinate transformation hash table, extract watershed rainfall data, and divide the data into training and testing sets;

[0011] Step 4. Construct a CNN-GRU rainfall spatiotemporal interpolation model based on the attention mechanism, confirm the structure of the convolutional neural network (CNN) and the bidirectional gated recurrent unit (GRU); introduce the attention mechanism, and calculate the probability corresponding to different feature vectors according to the weight allocation principle for the feature vectors output by the GRU network.

[0012] Step 5. Train the attention-based CNN-GRU rainfall spatiotemporal interpolation model using the training set, adjust the hyperparameters, and iterate to find the optimal model;

[0013] Step 6. Interpolate the test set and generate raster data, and finally evaluate the interpolation results.

[0014] Furthermore, the specific process of step 1 includes:

[0015] 1-1. Prepare watershed data, which includes point data and area data;

[0016] Point data: Historical meteorological and geographical data of all rain gauge stations within the basin, including rainfall and geographical coordinates;

[0017] Area data: Digital elevation information within the watershed and satellite-retrieved rainfall data with a resolution of 0.1°×0.1°;

[0018] 1-2. Missing and outlier values ​​in the watershed rainfall data were handled using mean interpolation, with the specific formula as follows:

[0019]

[0020] Where, x t-1 and x t+1 x represents the observation values ​​at time t-1 and t+1 of this grid point, respectively; t This is the result of the repair.

[0021] Furthermore, the specific process of step 2 includes:

[0022] 2-1. Using latitude and longitude as the standard, the watershed is divided into a grid with a resolution of 0.1° × 0.1°;

[0023] 2-2. The original satellite grid rainfall data with a resolution of 0.1°×0.1° was expanded to 0.05°×0.05° grid data by using interpolation.

[0024] Furthermore, the specific process of step 3 includes:

[0025] 3-1. Use latitude and longitude to locate the grid to determine the position of each grid: Create a hash table with latitude and longitude as the key and the row and column number of the matrix where the grid is located as the value, and put the grids into the hash table in turn for easy retrieval;

[0026] 3-2. Extracting watershed rainfall data: Based on latitude and longitude coordinates, satellite-retrieved rainfall data, digital elevation information, rain gauge data, and geographic location data are extracted sequentially to generate four-channel input data. The input data is then divided into training and testing sets.

[0027] Furthermore, the specific process of step 4 includes:

[0028] 4-1. The structure of the CNN-GRU rainfall spatiotemporal interpolation model based on the attention mechanism is confirmed. The model is mainly divided into an input layer, a CNN layer, a GRU layer, an attention mechanism layer, and an output layer.

[0029] 4-2. Constructing a Convolutional Neural Network (CNN) to extract spatial features of rainfall. The CNN layers take watershed rainfall data as input. Rainfall data of length n is preprocessed and then input into the prediction model. This indicates that the CNN layer includes 3 convolutional layers and 2 pooling layers. The specific convolution and pooling operations are as follows:

[0030]

[0031]

[0032] P1 = max(C2) + b3

[0033]

[0034] P2 = max(C3) + b5

[0035] Where C1, C2, and C3 are the outputs of convolutional layer 1, convolutional layer 2, and convolutional layer 3, respectively; P1 and P2 are the outputs of pooling layer 1 and pooling layer 2, respectively; W1, W2, and W3 are learnable weight matrices; and b1, b2, b3, b4, and b5 are learnable bias variables. This is a convolution operation; max() is an operation to retrieve the maximum value within a range.

[0036] 4-3. Introduce a global pooling layer to replace the fully connected layer. Perform average pooling on the feature map of the last layer along the channel direction to form a real feature point. Finally, combine the feature points after average pooling to form a feature vector H. c The specific calculation formula is as follows:

[0037] H c =f(average(p2))=σ(average(p2))

[0038] Where average() is the average value operation and σ is the sigmoid activation function;

[0039] 4-4. A bidirectional gated recurrent unit (BiGRU) is applied to extract the temporal features of rainfall. The feature vector sequence H extracted by the CNN layer is then used. c The data is input into the BiGRU model for learning; the BiGRU consists of a forward GRU and a backward GRU, which are used to learn historical data features and future data features, respectively.

[0040] Forward GRU eigenvectors The calculation formula is as follows:

[0041]

[0042]

[0043]

[0044]

[0045] in, For a learnable parameter matrix, The reverse eigenvector at time t-1 The input data is at time t. Let be the output feature vector at time t. To reset the door in reverse, This is a reverse forgetting gate;

[0046] Eigenvalues ​​of the inverse GRU The calculation method is the same as the formula above. Simply reverse the input feature vector set and then input it into the inverted GRU to calculate the output feature vector of the inverted GRU.

[0047] Finally, the forward and reverse results are processed and linearly fused to obtain the output formula at time t as follows:

[0048]

[0049] Where α t Let β be the weight of the inverse GRU hidden layer output at time t. t Let b be the weights of the positive output of the GRU hidden layer at time t. t This corresponds to the bias value;

[0050] 4-5. Using the attention mechanism, the probabilities corresponding to different feature vectors are calculated by assigning weights, and the weight parameter matrix is ​​iteratively updated during training. The calculation formula of the attention mechanism is as follows:

[0051] e t =u tanh(wh) t +b)

[0052]

[0053]

[0054] Among them, e t α is the output feature vector of the GRU layer at time t; t is the attention coefficient of the current feature vector; u and w are the learnable weight coefficients; b is the learnable bias coefficient; s t This is the output of the attention mechanism layer after weighting the feature vector at time t.

[0055] 4-6. Construct an output layer to receive the output of the attention mechanism layer, and perform linear fitting through a fully connected layer to generate the predicted value at time t. The formula is as follows:

[0056]

[0057] in, Let w0 be the interpolation result at time t, w0 be the learnable weight matrix, b0 be the learnable bias vector, and ReLU represent the activation function of the fully connected layer.

[0058] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0059] 1. This invention combines the spatial heterogeneity of satellite-retrieved rainfall data with the high-precision point estimation features of rain gauge data, and uses multi-source data as model input, that is, it improves the accuracy of the spatiotemporal interpolation algorithm for rainfall by using data diversity.

[0060] 2: This invention utilizes convolutional neural networks to fully extract the spatial heterogeneity of rainfall. At the same time, it introduces bidirectional gated recurrent units, which reduces the computational complexity of the model while fully extracting the temporal features of rainfall.

[0061] 3. This invention uses an attention mechanism to guide the neural network to focus on important features from both global and local perspectives, which accelerates the network convergence speed and also effectively improves the accuracy of rainfall interpolation and the robustness of the model. Attached Figure Description

[0062] The present invention will be further described below with reference to the accompanying drawings and embodiments:

[0063] Figure 1 This is a flowchart of a method according to an embodiment of the present invention.

[0064] Figure 2 This is a structural diagram of a CNN-GRU rainfall spatiotemporal interpolation model based on an attention mechanism, according to an embodiment of the present invention.

[0065] Figure 3 This is a structural diagram of a bidirectional gate control loop unit according to an embodiment of the present invention. Detailed Implementation

[0066] The technical solution of the present invention will be further described below with reference to embodiments and accompanying drawings.

[0067] This embodiment selects the Tunxi River Basin as the research object and provides a CNN-GRU spatiotemporal interpolation method for rainfall based on an attention mechanism. The Tunxi River Basin is located in southeastern Anhui Province, in the upper reaches of the Xin'an River Basin, with a basin area of ​​nearly 2700 km². 2 The average annual rainfall is around 1600 mm, with the summer being the rainiest season, accounting for 50% of the annual rainfall and making it highly susceptible to floods; autumn has less rainfall, accounting for only 20% of the annual rainfall, making it prone to droughts, and the rainfall is unevenly distributed throughout the year.

[0068] like Figure 1 As shown, the CNN-GRU rainfall spatiotemporal interpolation method based on an attention mechanism provided by this invention has the following specific steps:

[0069] Step 1. Obtain watershed rainfall data and preprocess the watershed rainfall data;

[0070] Step 2. Grid-process the watershed rainfall data;

[0071] Step 3. Establish a geographic coordinate transformation hash table, extract watershed rainfall data, and divide the data into training and testing sets;

[0072] Step 4. Construct a CNN-GRU rainfall spatiotemporal interpolation model based on the attention mechanism, confirm the structure of the convolutional neural network (CNN) and the bidirectional gated recurrent unit (GRU); introduce the attention mechanism, and calculate the probability corresponding to different feature vectors according to the weight allocation principle for the feature vectors output by the GRU network.

[0073] Step 5. Train the attention-based CNN-GRU spatiotemporal interpolation model for rainfall using the training set, adjust the hyperparameters, and iterate to find the optimal model;

[0074] Step 6. Interpolate the test set and generate raster data, and finally evaluate the interpolation results.

[0075] The specific process of step 1 includes:

[0076] 1-1. Acquire rainfall data in the Tunxi River Basin, including historical meteorological and geographical data of all rain gauge stations in the basin, digital elevation information within the basin, and satellite-retrieved rainfall data within the basin. Daily rainfall data from 2010 to 2019 were collected from 11 rain gauge stations with long-sequence observation data in the Tunxi River Basin.

[0077] 1-2. Missing and outlier values ​​in the watershed rainfall data were handled using mean interpolation, with the specific formula as follows:

[0078]

[0079] Where, x t-1 and x t+1 x represents the observation values ​​at time t-1 and t+1 of this grid point, respectively; t This is the result of the repair.

[0080] The specific process of step 2 includes:

[0081] 2-1. Using latitude and longitude as the standard, the watershed is divided into a grid with a resolution of 0.1° × 0.1°;

[0082] 2-2. The original satellite grid rainfall data with a resolution of 0.1°×0.1° was expanded to 0.05°×0.05° grid data by using interpolation.

[0083] The specific process of step 3 includes:

[0084] 3-1. Use latitude and longitude to locate the grid to determine the position of each grid: Create a hash table with latitude and longitude as the key and the row and column number of the matrix where the grid is located as the value, and put the grids into the hash table in turn for easy retrieval;

[0085] 3-2. Gridding the point data: The location of each pixel is determined by the latitude and longitude coordinates of the rain gauge station, and the rainfall value is filled in. Empty pixels without actual rain gauge station location are filled with 0. In order to enable the network to distinguish between pixels with a value of 0 and empty pixels, an additional channel containing the location information of the ground rain gauge station is added. If a pixel has an actual rain gauge station, it is set to 1, and other positions are set to 0.

[0086] For each ground rainfall station, a 7×7 subgrid (approximately 38.5km×38.5km) centered on the calibration point is used to match the grid point positions according to latitude and longitude, and the satellite inversion rainfall grid, rainfall station grid, rainfall station geographic coordinate grid and digital elevation grid at the corresponding grid location identified at each time step are extracted respectively.

[0087] The above four-channel grid images were used as input data for the CNN-GRU spatiotemporal interpolation model for rainfall based on the attention mechanism. The dataset was divided into training and test sets according to rainfall time and location of rainfall stations. Specifically, the rainfall data from Shimen Station, Yixian Station, Yanqian Station, Shangxikou Station, Rucun Station, Dalian Station, Wucheng Station, and Zuolong Station from 2010 to 2017 were used as the training set, and the rainfall data from 2018 to 2019 were used as test set one; the rainfall data from Tunxi Station, Xiuning Station, and Chengcun Station from 2010 to 2019 were used as test set two.

[0088] The specific process of step 4 includes:

[0089] 4-1. Confirm the structure of the attention-based CNN-GRU spatiotemporal interpolation model for rainfall, such as... Figure 2 As shown, the model is mainly divided into an input layer, a CNN layer, a GRU layer, an attention mechanism layer, and an output layer;

[0090] 4-2. Constructing a Convolutional Neural Network (CNN) to extract spatial features of rainfall. The CNN layers take watershed rainfall data as input. Rainfall data of length n is preprocessed and then input into the prediction model. This indicates that the CNN layer includes 3 convolutional layers and 2 pooling layers. The specific convolution and pooling operations are as follows:

[0091]

[0092]

[0093] P1 = max(C2) + b3

[0094]

[0095] P2 = max(C3) + b5

[0096] Where C1, C2, and C3 are the outputs of convolutional layer 1, convolutional layer 2, and convolutional layer 3, respectively; P1 and P2 are the outputs of pooling layer 1 and pooling layer 2, respectively; W1, W2, and W3 are the learnable weight matrices; and b1, b2, b3, b4, and b5 are the learnable bias variables. This is a convolution operation; max() is an operation to retrieve the maximum value within a range.

[0097] 4-3. Introduce a global pooling layer to replace the fully connected layer. Perform average pooling on the feature map of the last layer along the channel direction to form a real feature point. Finally, combine the feature points after average pooling to form a feature vector H. c The specific calculation formula is as follows:

[0098] H c =f(average(p2))=ρ(average(p2))

[0099] Where average() is the average value operation and ρ is the sigmoid activation function;

[0100] 4-4. A bidirectional gated recurrent unit (BiGRU) is applied to extract the temporal features of rainfall. The feature vector sequence H extracted by the CNN layer is then used. c The input is fed into the BiGRU model for learning; the BiGRU consists of a forward GRU and a backward GRU, which are used to learn historical data features and future data features, respectively.

[0101] Forward GRU eigenvectors The calculation formula is as follows:

[0102]

[0103]

[0104]

[0105]

[0106] in, For a learnable parameter matrix, The reverse eigenvector at time t-1 The input data is at time t. Let be the output feature vector at time t. To reset the door in reverse, This is a reverse forgetting gate;

[0107] Eigenvalues ​​of the inverse GRU The calculation method is the same as the formula above. It only requires reversing the input feature vector set and then inputting it into the inverse GRU to calculate the feature vector output by the inverse GRU.

[0108] Finally, the forward and reverse results are processed and linearly fused to obtain the output formula at time t as follows:

[0109]

[0110] Where α t Let β be the weight of the inverse GRU hidden layer output at time t. t Let b be the weights of the positive output of the GRU hidden layer at time t. t This corresponds to the bias value;

[0111] 4-5. An attention mechanism is used, which calculates the probabilities corresponding to different feature vectors by assigning weights, and iteratively updates the weight parameter matrix during training. The calculation formula for the attention mechanism is as follows:

[0112] e t =u tanh(wh) t +b)

[0113]

[0114]

[0115] Among them, e t α is the output feature vector of the GRU layer at time t; t is the attention coefficient of the current feature vector; u and w are the learnable weight coefficients; b is the learnable bias coefficient; s t This is the output of the attention mechanism layer after weighting the feature vector at time t.

[0116] 4-6. Construct an output layer to receive the output of the attention mechanism layer, and perform linear fitting through a fully connected layer to generate the predicted value at time t. The formula is as follows:

[0117]

[0118] in, Let w0 be the interpolation result at time t, w0 be the learnable weight matrix, b0 be the learnable bias vector, and ReLU represent the activation function of the fully connected layer.

[0119] The specific process of step 5 includes:

[0120] 5-1. In the case of no data available for the Tunxi station, data from nearby rain gauge stations, satellite-retrieved rainfall data, and digital elevation information were used as input data to train a CNN-GRU spatiotemporal interpolation model for rainfall based on an attention mechanism.

[0121] 5-2. Multiple experiments were conducted using a random search algorithm. The error and accuracy of the experimental results were analyzed, and the parameters of the CNN-GRU rainfall spatiotemporal interpolation model based on the attention mechanism were finally determined as follows: learning rate of 0.009, batch size of 256, and optimizer of Adam.

[0122] The specific process of step 6 includes:

[0123] To verify the effectiveness of the CNN-GRU spatiotemporal interpolation method for rainfall based on the attention mechanism proposed in this invention in rainfall prediction, the precipitation product GSMAP NRT Gauge, the random forest model, and the CNN-LSTM model were used as references. The correlation coefficient (CC), mean absolute percentage error (MAPE), bias, and root mean square error (RMSE) of each precipitation product and model prediction were calculated. The experimental results are shown in the table below:

[0124]

[0125] As shown in the table, the CNN-GRU precipitation spatiotemporal interpolation model based on the attention mechanism has a correlation coefficient of 0.87, a mean absolute percentage error of 1.63, and a root mean square error of 6.72, which is better than the precipitation products of GSMap NRT Gauge, Random Forest model, and CNN-LSTM model. The bias is 0.052, which is higher than GSMap NRT Gauge but lower than Random Forest model and CNN-LSTM model. This indicates that the CNN-GRU precipitation spatiotemporal interpolation method based on the attention mechanism can fit the residual relationship between satellite inversion data and ground precipitation data, and improve the accuracy of precipitation interpolation.

Claims

1. A CNN-GRU spatiotemporal interpolation method for rainfall based on an attention mechanism, characterized in that, Includes the following steps: Step 1. Obtain watershed rainfall data and preprocess the watershed rainfall data; Step 2. Grid-process the watershed rainfall data; Step 3. Establish a geographic coordinate transformation hash table, extract watershed rainfall data, and divide the data into training and testing sets; Step 4. Construct a CNN-GRU rainfall spatiotemporal interpolation model based on an attention mechanism, confirming the structure of the convolutional neural network (CNN) and the bidirectional gated recurrent unit (GRU); introduce an attention mechanism, and calculate the probability corresponding to different feature vectors for the feature vectors output by the GRU network according to the principle of weight allocation; Step 5. Train the attention-based CNN-GRU rainfall spatiotemporal interpolation model using the training set, adjust the hyperparameters, and iterate to find the optimal model; Step 6. Interpolate the test set and generate raster data, and finally evaluate the interpolation results.

2. The CNN-GRU rainfall spatiotemporal interpolation method based on an attention mechanism according to claim 1, characterized in that, The specific process of step 1 includes: 1-1. Obtain watershed rainfall data, including point data and area data; Point data: Historical meteorological and geographical data of all rain gauge stations within the basin, including rainfall and geographical coordinates; Area data: Digital elevation information within the watershed and satellite-retrieved rainfall data with a resolution of 0.1°×0.1°; 1-2. Missing and outlier values ​​in the watershed rainfall data were handled using mean interpolation, with the specific formula as follows: Where, x t-1 and x t+1 x represents the observation values ​​at time t-1 and t+1 of this grid point, respectively; t This is the result of the repair.

3. The CNN-GRU rainfall spatiotemporal interpolation method based on an attention mechanism according to claim 1, characterized in that: The specific process of step 2 includes: 2-1. Using latitude and longitude as the standard, the watershed is divided into a grid with a resolution of 0.1° × 0.1°; 2-2. The original satellite grid rainfall data with a resolution of 0.1°×0.1° was expanded to 0.05°×0.05° grid data by using interpolation.

4. The CNN-GRU rainfall spatiotemporal interpolation method based on an attention mechanism according to claim 1, characterized in that: The specific process of step 3 includes: 3-1. Use latitude and longitude to locate the grid and determine the position of each grid: Create a hash table with latitude and longitude as the key and the row and column number of the matrix where the grid is located as the value, and put the grid into the hash table for easy retrieval; 3-2. Extracting watershed rainfall data: Based on latitude and longitude coordinates, extract satellite-inverted rainfall data, digital elevation information, rain gauge data, and geographic location data in sequence to generate four-channel input data, and divide the input data into training set and test set.

5. The CNN-GRU rainfall spatiotemporal interpolation method based on an attention mechanism according to claim 1, characterized in that: The specific process of step 4 includes: 4-1. The structure of the CNN-GRU rainfall spatiotemporal interpolation model based on the attention mechanism is confirmed, mainly including the input layer, CNN layer, GRU layer, attention mechanism layer and output layer; 4-2. Constructing a Convolutional Neural Network (CNN) to extract spatial features of rainfall. The CNN layers take watershed rainfall data as input. Rainfall data of length n is preprocessed and then input into the prediction model. This indicates that the CNN layer includes 3 convolutional layers and 2 pooling layers. The specific convolution and pooling operations are as follows: P1 = max(C2) + b3 P2 = max(C3) + b5 Where C1, C2, and C3 are the outputs of convolutional layer 1, convolutional layer 2, and convolutional layer 3, respectively; P1 and P2 are the outputs of pooling layer 1 and pooling layer 2, respectively; W1, W2, and W3 are learnable weight matrices; and b1, b2, b3, b4, and b5 are learnable bias variables. This is a convolution operation; max() is an operation to retrieve the maximum value within a range. 4-3. Introduce a global pooling layer to replace the fully connected layer. Perform average pooling on the feature map of the last layer along the channel direction to form a real feature point. Finally, combine the feature points after average pooling to form a feature vector H. c The specific calculation formula is as follows: H c =f(average(p2))=σ(average(p2)) Where average() is the average value operation and σ is the sigmoid activation function; 4-4. A bidirectional gated recurrent unit (BiGRU) is applied to extract the temporal features of rainfall. The feature vector sequence H extracted by the CNN layer is then used. c The data is input into the BiGRU model for learning; the BiGRU consists of a forward GRU and a backward GRU, which are used to learn historical data features and future data features, respectively. Forward GRU eigenvectors The calculation formula is as follows: in, For a learnable parameter matrix, The reverse eigenvector at time t-1 The input data is at time t. Let be the output feature vector at time t. To reset the door in reverse, This is a reverse forgetting gate; Eigenvalues ​​of the inverse GRU The calculation method is the same as the formula above. Simply reverse the input feature vector set and then input it into the inverted GRU to calculate the output feature vector of the inverted GRU. Finally, the forward and reverse results are processed and linearly fused to obtain the output formula at time t as follows: Where α i Let β be the weight of the inverse GRU hidden layer output at time t. t Let b be the weights of the positive output of the GRU hidden layer at time t. t This corresponds to the bias value; 4-5. Using the attention mechanism, the probabilities corresponding to different feature vectors are calculated by assigning weights, and the weight parameter matrix is ​​iteratively updated during training. The calculation formula of the attention mechanism is as follows: e t =u tanh(wh t +b) Among them, e t α is the output feature vector of the GRU layer at time t; t is the attention coefficient of the current feature vector; u and w are the learnable weight coefficients; b is the learnable bias coefficient; s t This is the output of the attention mechanism layer after weighting the feature vector at time t. 4-6. Construct an output layer to receive the output of the attention mechanism layer, and perform linear fitting through a fully connected layer to generate the predicted value at time t. The formula is as follows: in, Let w0 be the interpolation result at time t, w0 be the learnable weight matrix, b0 be the learnable bias vector, and ReLU represent the activation function of the fully connected layer.