A lightning nowcasting method based on lightning location data and three-dimensional space-time transformer
By using a deep learning architecture based on a 3D spatiotemporal Transformer and combining it with lightning location data, this method solves the problems of insufficient long-range spatiotemporal dependency capture and difficulty in training due to sparsity in existing methods, achieving efficient lightning nowcasting and improving forecast accuracy and precision.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- UNIV OF SCI & TECH OF CHINA
- Filing Date
- 2026-04-15
- Publication Date
- 2026-07-21
AI Technical Summary
Existing deep learning methods for lightning nowcasting suffer from insufficient long-range spatiotemporal dependency capture and training difficulties due to the sparsity of lightning events. In particular, they have poor operability with radar and satellite data, and the sparsity of lightning location data leads the model to tend to predict 'no lightning'.
We adopt a deep learning architecture based on 3D spatiotemporal Transformer, combine lightning localization data, and construct an end-to-end model through spatiotemporal Transformer encoder and 3D convolutional decoder. We use self-attention mechanism to capture global long-range spatiotemporal dependencies, and introduce loss function with positive sample weights and morphological processing to solve the training strategy for sparse events.
It significantly improves the accuracy and precision of lightning nowcasting, can efficiently capture the global long-range dependence of lightning generation and dissipation, reduces system costs, and realizes efficient nowcasting based on single lightning location data, which has high operational deployment value.
Smart Images

Figure CN122432839A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the fields of atmospheric science and artificial intelligence research, and in particular relates to a lightning nowcasting method based on lightning location data and a three-dimensional spatiotemporal Transformer. Background Technology
[0002] Lightning, a highly destructive weather phenomenon, is often accompanied by strong winds, torrential rains, and other severe weather conditions, posing a serious threat to power systems, aviation safety, infrastructure, and people's lives and property. Therefore, accurate and timely 0-1 hour lightning nowcasting has crucial socio-economic value for disaster prevention and mitigation.
[0003] Traditional lightning nowcasting techniques generally follow two technical paths: numerical weather prediction based on physical models and extrapolation prediction based on observational data. Numerical weather prediction infers thunderstorm development by simulating complex atmospheric dynamics and thermodynamic processes, and is relatively effective in medium- and long-term forecasts. However, it suffers from high computational complexity and time consumption, and its accuracy and timeliness are insufficient for forecasting localized, short-duration, and sudden lightning events. Extrapolation-based prediction methods utilize observational data such as weather radar and ground-based lightning location networks to predict the future location of thunderstorm cells by identifying their historical movement trajectories. While simple and efficient, these methods are essentially based on linear assumptions about motion, making it difficult to accurately predict the initiation, dissipation, and nonlinear changes in the path of lightning. In recent years, with the development of artificial intelligence technology, deep learning, especially convolutional neural networks (CNNs) and recurrent neural networks (RNNs), has been widely applied in the field of lightning nowcasting and has shown potential to surpass traditional methods.
[0004] Existing deep learning-based methods can be mainly summarized into the following technical approaches:
[0005] Temporal prediction based on recurrent neural networks. This type of method, represented by models such as ConvLSTM and PredRNN, processes time-series data through recurrent structures. Although it can model the evolution of cloud images and radar echoes, it suffers from drawbacks such as low training efficiency, difficulty in gradient propagation, and frame-by-frame error accumulation, which limits its stability and accuracy in long-term time-series prediction.
[0006] Spatiotemporal modeling based on convolutional neural networks. These methods use U-Net and its variants, or cleverly designed stacked fully convolutional structures to capture spatiotemporal features. Although the models have high parallelism and are more efficient than RNNs, their ability to model long-range temporal dimensions is limited by the local receptive field of the convolutional kernels, making it difficult to effectively grasp sudden global dynamics.
[0007] Prediction based on multi-source data fusion. This type of method aims to fuse heterogeneous data from multiple sources such as radar, satellite, and lightning. Fusion methods often involve simple channel stitching at the input (early fusion) or mid-term fusion at the feature layer using parallel two-stream networks. However, it's worth noting that while fusing multi-source data theoretically allows the model to learn more usable information, practical applications face challenges: weather radar detection ranges are limited, and obtaining effective data is difficult in mountainous terrain like China; meteorological satellite data detection, processing, and transmission result in significant time delays, making it difficult to meet the real-time requirements of lightning nowcasting. Lightning location data is typically acquired by ground-based lightning location systems, providing real-time, high-precision lightning location results around the clock and unaffected by terrain, making it the ideal data source for practical engineering applications. However, lightning is a sparse event in space, and conventional loss functions struggle to learn useful information from sparse matrices, leading models to tend to predict "no lightning."
[0008] In summary, existing deep learning methods still face the following core challenges in the field of lightning nowcasting: 1. Existing models are mostly single-paradigm (pure RNN or pure CNN) or employ complex two-stage / dual-stream architectures, lacking a unified, end-to-end framework for efficiently handling long-range spatiotemporal dependencies and generating high-resolution predictions. 2. Radar and satellite data have poor operability in practical engineering applications of lightning nowcasting, while lightning location data, although possessing significant engineering application value, is a sparse event with highly imbalanced samples in space and time. Conventional loss functions can easily lead to insufficient learning of a few key positive samples, resulting in a tendency to predict "no lightning."
[0009] Therefore, there is an urgent need to develop a new deep learning architecture that can overcome the serialization limitations of RNNs and the locality constraints of CNNs, efficiently capture global long-range spatiotemporal dependencies within a unified end-to-end framework, and combine targeted training strategies to solve the core technical challenges of relying solely on lightning location data for nowcasting. Summary of the Invention
[0010] Purpose of the invention: The purpose of this invention is to provide a deep learning-based lightning nowcasting method to solve the problems of insufficient long-range spatiotemporal dependency capture due to model architecture limitations in existing methods, and training difficulties caused by the sparsity of lightning events.
[0011] Technical solution: The present invention provides a lightning nowcasting method based on lightning location data and a three-dimensional spatiotemporal Transformer, comprising the following steps:
[0012] S1. Acquire ground-based lightning location data and perform time-space dot-mapping processing to obtain a lightning frequency grid sequence;
[0013] S2. Perform quality control and sampling on the lightning frequency grid sequence to obtain a sample sequence;
[0014] S3. Divide the dataset based on the sample sequence and construct the model input and binary labels;
[0015] S4. Construct a deep learning model based on a three-dimensional spatiotemporal Transformer;
[0016] S5. Based on the training set and validation set, train the deep learning model according to the training strategy;
[0017] S6. Evaluate the performance of deep learning models based on the test set;
[0018] S7. Lightning proximity forecasting based on trained deep learning models.
[0019] Furthermore, step S1 specifically includes the following steps:
[0020] S11. Pre-set the start time T0 and end time T of data acquisition. n Latitude and longitude range (Lon0~Lon) n ,Lat0~Lat n ), time resolution t and spatial resolution r, requiring (T) n Both -T0) and 1 hour (hour) are divisible by t (Lon n -Lon0) and (Lat) n -Lat0) are all divisible by r;
[0021] S12. Obtain lightning location data of the ground-based lightning location system within a preset time period and latitude and longitude range, including the occurrence time and latitude and longitude coordinates (lon, lat) of each lightning strike.
[0022] S13. Based on the temporal resolution, the preset time period is divided into a sequence of n consecutive time windows ordered in ascending order of time. For each time window, the target area is divided into a two-dimensional grid according to the spatial resolution, where n = (T n -T0) / t, grid height H = (Lat) n -Lat0) / r, width W = (Lon n -Lon0) / r, the lightning count at each grid point in the grid is recorded as 0, generating the initial lightning frequency grid sequence;
[0023] S14. Divide the lightning location data into time windows according to the occurrence time, and calculate the grid coordinate position (i, j) of the lightning in the corresponding lightning frequency grid according to the latitude and longitude coordinates of the lightning, where i = [(lon - Lon0) / r], j = [(lat - Lat0) / r], and "[]" indicates rounding down;
[0024] S15. Count the cumulative number of lightning strikes in each grid point of the lightning frequency grid for each frame, and update the grid with the cumulative number of lightning strikes as the new lightning frequency to obtain a new lightning frequency grid sequence.
[0025] Furthermore, step S2 specifically includes the following steps:
[0026] S21. Use morphological filtering to perform quality control on the generated lightning frequency grid sequence: For any non-zero frequency grid point in each frame of lightning frequency grid, use a circular kernel with a radius of 0.1° (about 10km) to perform neighborhood analysis. The grid point will be retained if and only if there are at least 2 other non-zero frequency grid points in its neighborhood; otherwise, the lightning frequency of the grid point will be reset to 0.
[0027] S22. For the quality-controlled lightning frequency grid sequence, construct a sliding window of length L frames for sampling, requiring L≥4+1h / t. Starting from the first L frames of the lightning frequency grid, the lightning frequency grid sequence is detected from front to back with a sliding distance of 1 frame. In each detection, the lightning frequency grid sequence of length L that meets the following conditions is packaged into a sample: the total lightning frequency of the lightning frequency grid in the window is 0, and its total number of frames is less than L / 2.
[0028] S23. Arrange the samples according to the order of their generation to obtain a time-increasing sample sequence.
[0029] Furthermore, step S3 specifically includes the following steps:
[0030] S31. Divide the first 75% of the samples in the sample sequence into a training set, and divide the remaining 25% of the samples into a test set and a validation set.
[0031] S32. First, perform a logarithmic transformation on the lightning frequency grid of all samples in the training set to obtain logarithmic domain data; then, calculate the mean grid μ based on the logarithmic domain data. log and standard deviation grid σ log ;
[0032] S33. For each sample in all datasets, use the lightning frequency grid sequence of the first L-1h / t frames as input data and the lightning frequency grid sequence of the last 1h / t frames as supervision labels.
[0033] S34. Perform a logarithmic transformation on the lightning frequency grid of each frame in the input data, and then perform Z-score normalization:
[0034]
[0035] in, This is grid data for lightning frequency. ;
[0036] S35. Binarize the sample supervision labels: For each frame of the lightning frequency grid in the sequence, reset all grid points with a lightning frequency greater than 0 to 1 to generate a binary grid.
[0037] S36. For each frame of the binary grid in the sample supervision label, for all grid points with a value of 1, set the grid point values with a value of 0 within a radius of 0.06° (approximately 6km) to 1.
[0038] Furthermore, step S4 specifically includes the following steps:
[0039] S41. Construct the input preprocessor:
[0040] The input preprocessor consists of a patch embedding layer connected to a positional encoding layer. The patch embedding layer converts the gridded input data into a high-dimensional token sequence, and the positional encoding layer injects positional information into each token.
[0041] S42. Construct the spatiotemporal Transformer encoder:
[0042] The spatiotemporal Transformer encoder is the core unit for capturing the spatiotemporal evolution features of lightning. It consists of several TSST spatiotemporal coding layers stacked together and then connected to a normalization layer. Each TSST spatiotemporal coding layer contains four sequential, gated Transformer modules with a Pre-Norm Transformer structure. These four modules perform feature extraction and evolution in the time dimension, spatial dimension, spatial dimension, and time dimension respectively according to the forward input order, thereby efficiently capturing global spatiotemporal dependencies while reducing computational complexity.
[0043] S43. Construct a 3D convolutional decoder:
[0044] The 3D convolutional decoder consists of several stacked upsampling layers. Each upsampling layer is composed of a linear interpolation module, a 3D convolution module, and a thinning module in sequence. It is used to fuse the high-dimensional spatiotemporal context features output by the encoder to predict the future development of lightning and reconstruct the spatial resolution of lightning features in the process.
[0045] S44. Construct the complete model:
[0046] The sample input data is first converted into a high-dimensional token sequence with spatial location by an input preprocessor. Then, the token sequence is input into a spatiotemporal Transformer encoder to learn the spatiotemporal evolution of lightning through spatiotemporal decomposition and extract multi-scale spatiotemporal features. The token sequence output by the encoder is recombined into a tensor format adapted to the input of a 3D convolutional layer. This tensor is then input into a 3D convolutional decoder to predict the future development of lightning and perform upsampling reconstruction to restore the original spatial resolution. Finally, the data passes through a 3D convolutional projection layer to map the number of channels to 1, resulting in an output feature map with the same spatiotemporal size as the supervision label. The Sigmoid activation function is applied to each grid point of the output feature map to obtain a lightning occurrence probability map.
[0047] Furthermore, the training strategy described in step S5 is as follows: the loss function adopts the weighted BCE loss function with positive sample weights to solve the label class imbalance problem; the optimizer and learning rate scheduling use the adaptive moment estimation optimizer AdamW, combined with the learning rate scheduling strategy OneCycle, to achieve fast and stable convergence; regularization strategy: to prevent model overfitting, regularization techniques such as Dropout, DropPath, and gradient clipping are used in combination; data augmentation: during the training process, random scaling, random flipping, and rotation data augmentation operations are applied to the input data to improve the model's generalization ability.
[0048] Furthermore, the model performance evaluation method described in step S6 is as follows: input the sample input data from the test set into the model, calculate the probability prediction map output by the model; convert the probability prediction map into a binary prediction result according to the set threshold; construct a confusion matrix based on the grid-by-grid comparison between the prediction result and the supervision label, and calculate the hit rate (POD), false alarm rate (FAR), critical success index (CSI), F1 score, and area under the receiver operating characteristic curve (AUC) to comprehensively evaluate the spatiotemporal prediction performance of the model under sparse lightning events.
[0049] The present invention also discloses a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method of the present invention.
[0050] The present invention also discloses a computer-readable storage medium having a computer program / instructions stored thereon, which, when executed by a processor, implements the steps of the method of the present invention.
[0051] The present invention also discloses a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the method of the present invention.
[0052] Beneficial effects: Compared with the prior art, the present invention has the following significant improvements:
[0053] 1. This invention overcomes the bottleneck of long-range spatiotemporal dependency modeling, significantly improving forecast accuracy. It innovatively proposes a hybrid architecture that deeply integrates spatiotemporal Transformer and 3D convolution. Utilizing the self-attention mechanism of Transformer, it can directly establish connections between any two spatiotemporal locations in the feature space, thereby efficiently capturing the global long-range dependency of lightning occurrence and dissipation. Combined with a 3D convolutional decoder, it explicitly models the continuity of the temporal dimension while restoring high resolution, effectively avoiding inter-frame jumps in prediction results. Experimental results show that this invention significantly outperforms mainstream baseline models in core metrics such as the Key Success Index (CSI) and Area Under the Receiver Operating Characteristic (AUC), enabling more accurate prediction of lightning strike areas and morphological evolution within the next hour.
[0054] 2. A targeted training strategy for sparse lightning events was constructed, enabling efficient nowcasting based on single lightning location data. By introducing a positive sample weighted loss function and morphological processing, the problem of extremely unbalanced spatiotemporal distribution of lightning data was effectively solved. This allows the model to directly extract complex evolution patterns from sparse lightning point data, eliminating the reliance on complex fusion engineering of multi-source heterogeneous data (such as radar and satellite), significantly reducing system costs, and demonstrating high operational deployment value. Attached Figure Description
[0055] Figure 1 This is a flowchart illustrating the implementation of the lightning nowcasting method based on lightning location data and a three-dimensional spatiotemporal Transformer provided in this application.
[0056] Figure 2 This is a detailed structural diagram of the spatiotemporal Transformer encoder provided in this application, wherein (a) is the TSST spatiotemporal coding layer structure, (b) is the gated Transformer module structure, and (c) is the GLU feedforward network structure.
[0057] Figure 3 This is a schematic diagram of the overall architecture of the three-dimensional spatiotemporal Transformer model provided in this application;
[0058] Figure 4 This is a visualization of the lightning nowcast predictions made by the model provided in this application during the period from 00:24UTC to 01:24UTC on July 16, 2023, 6 minutes before and 6 minutes before the forecast. Detailed Implementation
[0059] The technical solution of the present invention will be further described below with reference to the accompanying drawings.
[0060] This application provides a lightning nowcasting method based on lightning location data and a three-dimensional spatiotemporal Transformer, as shown in the flowchart below. Figure 1 As shown, it specifically includes:
[0061] S1. Obtain the raw ground-based lightning location data and perform gridding processing. Specifically, this includes the following steps:
[0062] S11. The data acquisition period is pre-set to be from May to September 2021 to 2024, and the latitude and longitude range of the data acquisition is (109.6°E~117.28°E, 20.32°N~25.44°N), with a time resolution of 6 minutes and a spatial resolution of 0.02° (approximately 2km resolution).
[0063] S12. Obtain lightning location data of a ground-based lightning location system within a preset time period and latitude and longitude range. The data includes the occurrence time and latitude and longitude coordinates (lon, lat) of each lightning strike.
[0064] S13. Based on the time resolution, the preset time period is divided into a sequence of 146,880 consecutive time windows ordered in ascending order of time. For each time window, the target area is divided into a two-dimensional grid according to the spatial resolution. The grid height H=256 and the width W=384. The lightning count of each grid point is recorded as 0, and an initial lightning frequency grid sequence is generated.
[0065] S14. Divide the lightning location data into time windows according to the occurrence time, and calculate the grid coordinate position (i, j) of the lightning in the corresponding lightning frequency grid according to the latitude and longitude coordinates of the lightning, where i = [(lon – 109.6°E) / 0.02°], j = [(lat - 20.32°N) / 0.02°], and “[]” indicates rounding down;
[0066] S15. Count the cumulative number of lightning strikes in each grid point of the lightning frequency grid for each frame, and update the grid with the cumulative number of lightning strikes as the new lightning frequency to obtain a new lightning frequency grid sequence.
[0067] S2. Perform quality control and sampling on the lightning frequency grid sequence to obtain a sample sequence. Specifically, this includes the following steps:
[0068] S21. Use morphological filtering to perform quality control on the generated lightning frequency grid sequence: For any non-zero frequency grid point in each frame of lightning frequency grid, use a circular kernel with a radius of 0.1° (about 10km) to perform neighborhood analysis. The grid point will be retained if and only if there are at least 2 other non-zero frequency grid points in its neighborhood; otherwise, the lightning frequency of the grid point will be reset to 0.
[0069] S22. For the quality-controlled lightning frequency grid sequence, a sliding window of 20 frames (i.e. 2 hours) is constructed for sampling. Starting from the first 20 frames of lightning frequency grid, the lightning frequency grid sequence is detected from front to back with a sliding distance of 1 frame. In each detection, the continuous lightning frequency grid sequence of 20 frames that meets the following condition is packaged into a sample: the number of empty grid frames with a total lightning frequency of 0 in the window is less than 10.
[0070] S23. Arrange the selected samples according to their generation order to obtain a time-increasing sample sequence, which will serve as the basis for subsequent model training and evaluation.
[0071] S3. Divide the dataset based on the sample sequences and construct the model input and binary labels. This includes the following steps:
[0072] S31. Divide the sample sequence into a training set, a validation set, and a test set. In this embodiment, the sample data from May to September of 2021, 2022, and 2024 are used as the training set (accounting for approximately 75%), and the first half of the sample data from May to September of 2023 is divided into the test set, and the second half is divided into the validation set.
[0073] S32. Due to the long-tailed distribution of lightning frequencies, a logarithmic transformation is first performed on the lightning frequency grid of all samples in the training set to obtain logarithmic domain data; then, the mean grid μ is calculated based on the logarithmic domain data. log and standard deviation grid σ log These standardized parameters are calculated only from the training set and applied to the validation and test sets to prevent data leakage.
[0074] S33. For each sample in all datasets, use the lightning frequency grid sequence of the first 10 frames (first hour) as input data and the lightning frequency grid sequence of the last 10 frames (last hour) as supervision labels.
[0075] S34. Perform a logarithmic transformation on the lightning frequency grid of each frame in the input data, and then perform Z-score normalization, as shown in the following formula:
[0076]
[0077] Where X is the lightning frequency grid data, ε = 1×10⁻ 4 To prevent small constants from taking the logarithm of 0;
[0078] S35. Binarize the sample supervision labels: For each frame of the lightning frequency grid in the sequence, reset all grid positions with a lightning frequency greater than 0 to 1, and assign 0 to positions without lightning, to generate a binary grid.
[0079] S36. Considering the spatial diffusion characteristics of thunderstorm systems and to alleviate the problem of extreme sample imbalance, a morphological dilation operation is performed on the binarized grid of each frame in the sample supervision label. That is, for all grid points with a value of 1, the grid points with a value of 0 within a radius of 0.06° are also set to 1.
[0080] S4. Construct a deep learning model based on a 3D spatiotemporal Transformer. In this embodiment, the specific construction steps of this deep learning model are as follows:
[0081] S41. Construct the input preprocessor:
[0082] The input preprocessor consists of a patch embedding layer connected to a positional encoding layer. The patch embedding layer converts the gridded input data into a high-dimensional token sequence. The construction of the patch embedding layer computation is as follows:
[0083]
[0084] in Input to the model ( For batch size, The number of frames input for a single sample. (for spatial resolution) The output is a high-dimensional token sequence; the position encoding layer injects position information into each token, and the position encoding layer is constructed by calculation:
[0085]
[0086] E =
[0087] in This is the output after adding position encoding, where pos is the token position, i is the dimension index, PE is the position encoding result, and Flatten(⋅) indicates that the two-dimensional space dimension is... Flattened out, it is a one-dimensional space with dimension N.
[0088] S42. Construct the spatiotemporal Transformer encoder:
[0089] In this embodiment, the encoder is composed of two stacked TSST spatiotemporal coding layers connected to a normalization layer. For example... Figure 2 As shown in (a), a single TSST spatiotemporal coding layer contains four sequential, gated Transformer modules with a Pre-Norm Transformer structure. Each module is constructed using a multi-head self-attention layer and a GLU feedforward network, as shown in the diagram. Figure 2 As shown in (b) above, the internal structure of the further GLU feedforward network is as follows: Figure 2 As shown in (c) above, the calculation process for a single-layer module can be represented as follows:
[0090]
[0091]
[0092] in: Indicates the first Input features of the layer-gated Transformer module; LN(⋅) represents the layer normalization operation; Attention(⋅) represents the multi-head self-attention mechanism computation; This represents the intermediate features after computation by the attention layer and residual connections; SwigLU(⋅) represents a gated linear unit feedforward network using the Swish activation function; Indicates the first Output characteristics of the layer-gated Transformer module.
[0093] A single TSST spatiotemporal coding layer employs a four-fold decomposition architecture, with four gated Transformer modules performing feature extraction and evolution along the temporal-spatial-temporal (TSST) dimensions in the order of the forward input. The module computation flow is represented as follows:
[0094]
[0095]
[0096]
[0097]
[0098] Where: E represents the spatiotemporal feature sequence input to this spatiotemporal coding layer; GT time (⋅) represents a gated Transformer module that performs calculations in the time dimension; GT space(⋅) represents the gated Transformer module that performs computation in the spatial dimension; Z1, Z2, and Z3 represent the intermediate output features of each stage; Z4 represents the final output feature of the coding layer.
[0099] By reshaping the tensor shape across different dimensions using the aforementioned Reshape operation to separately compute temporal and spatial attention, the computational complexity is reduced from... Reduce to This significantly improves computational efficiency. In this embodiment, the specific parameters of the spatiotemporal Transformer encoder are set as follows: feature dimension dim=256, number of attention heads heads=8, and gated Transformer depth depth=1 within each TSST spatiotemporal coding layer.
[0100] S43. Construct a 3D convolutional decoder:
[0101] The 3D convolutional decoder receives the high-dimensional spatiotemporal features output by the encoder and reconstructs the spatial resolution of future lightning sequences through progressive upsampling. The decoder employs a progressive three-stage upsampling strategy, consisting of three stacked upsampling layers. Each upsampling layer comprises a linear interpolation module (Upsample), a 3D convolutional module (Conv3D), and a refinement module (RefineBlock) in sequence. The decoding computation process for a single upsampling layer is represented as follows:
[0102]
[0103] Upsample_trilinear is a trilinear interpolation method that magnifies the feature map by a factor of 2 in the spatial dimension while keeping the temporal dimension unchanged. Conv3D uses a 3×3×3 convolutional kernel to perform feature fusion in the spatiotemporal joint domain. RefineBlock3D uses a residual connection structure to eliminate artifacts and sharpen lightning boundaries. The decoder consists of three stages, upsampling the spatial resolution from 32×48 to 64×96, 128×192, and 256×384 respectively.
[0104] S44. Construct the complete model:
[0105] Building a complete model, such as Figure 3 As shown, the model architecture and data flow are as follows: The input data is first converted into a high-dimensional token sequence with spatial location by the input preprocessor; then the token sequence is input into the spatiotemporal Transformer encoder to extract multi-scale spatiotemporal features; the encoder output sequence is recombined into a tensor format [B, dim, T, H] adapted to the 3D convolution input. p W pThe input is a 3D convolutional decoder that predicts future developments and restores the original spatial resolution. Finally, it passes through a 1×1×1 3D convolutional projection layer, mapping the number of channels to 1, resulting in a feature map with an output shape of [B, 1, T, H, W]. A Sigmoid activation function is applied to each grid point of the feature map to convert it into a probability value, yielding a lightning occurrence probability map. When the single-channel dimension is omitted, it can be denoted as [B, T, H, W].
[0106]
[0107] Where: E represents the feature sequence output by the encoder; Decoder(⋅) represents the processing of the 3D convolutional decoder; Proj(⋅) represents the 3D projective convolution of the output layer; Sigmoid(⋅) represents the activation function used to map the output to... Probability interval; Y pred The output of the model represents the probability map of lightning occurrence; τ represents the binarization threshold (set to 0.5 by default in this embodiment); I(⋅) represents the indicator function, which takes the value 1 when the condition is met and 0 otherwise; Y pred_binary This represents the final generated binary image of lightning warning (1 represents lightning, 0 represents no lightning).
[0108] The complete end-to-end process of the model can be represented as follows:
[0109]
[0110] in: This represents the input, a standardized grid sequence of lightning frequency counts.
[0111] S5. Based on the training set and validation set, train the deep learning model according to the training strategy.
[0112] An end-to-end training strategy is used to optimize the model built with S4. The specific training strategy is as follows:
[0113] Loss function: The weighted binary cross-entropy loss function (BCE Loss) with positive sample weights is used. The loss value is calculated for each spatiotemporal pixel in the input sequence as follows:
[0114]
[0115] Where y is the true label, ŷ is the predicted value, and w represents the positive sample weight coefficient. In this embodiment, w is preferably set to 8.0 to force the model to focus on learning key positive samples (lightning events) and solve the problem of extreme imbalance in sparse event labels.
[0116] Optimizer and learning rate scheduling: The AdamW adaptive moment estimation optimizer is used in conjunction with the OneCycle learning rate scheduling strategy (the first 30% of training steps are a warm-up phase) to achieve fast and stable convergence.
[0117] Regularization strategies: To prevent model overfitting, a combination of regularization techniques such as Dropout, DropPath, and gradient clipping are used.
[0118] Data augmentation: During training, random scaling, cropping, 180-degree random rotation, and flipping are applied to the input data to improve the model's generalization ability.
[0119] S6. Evaluate the performance of deep learning models based on the test set.
[0120] In this embodiment, in order to comprehensively evaluate the forecasting performance of the proposed three-dimensional spatiotemporal Transformer model, the present invention adopts five key indicators widely used in the field of meteorological forecasting: Area Under the Receiver Operating Characteristic (AUC), Critical Success Index (CSI), Point of Detection (POD), Failure Rate (FAR), and F1 score.
[0121] First, in this embodiment, the sample input data from the test set is input into the model, and the probability prediction map output by the model is calculated. Further, based on experience, a threshold of 0.5 is set, and the probability prediction map output by the model is converted into a binary prediction result according to the set threshold (grid points ≥0.5 are set to 1, and grid points <0.5 are set to 0). Finally, based on a grid-by-grid comparison between the prediction result and the supervision label, a confusion matrix is constructed, and the following four basic quantities are statistically analyzed:
[0122] TP (True Positive): Hit, i.e., the number of grid points where lightning was predicted and actually occurred; FP (False Positive): False alarm, i.e., the number of grid points where lightning was predicted but actually did not occur; FN (False Negative): False miss, i.e., the number of grid points where lightning was predicted but actually occurred; TN (True Negative): True negation, i.e., the number of grid points where lightning was predicted and actually did not occur.
[0123] Based on the above fundamental quantities, the calculation formulas and meanings of each evaluation indicator are as follows:
[0124] Probability of Detection (POD): Measures the ability of a model to successfully predict real lightning events.
[0125] A higher POD indicates fewer missed cases.
[0126] False Alarm Ratio (FAR): Measures the proportion of false alarms in model forecasts.
[0127] The lower the FAR, the more accurate the forecast.
[0128] Critical Success Index (CSI): This index comprehensively measures a model's ability to balance hits and false alarms, and is the most critical indicator in sparse event forecasting.
[0129] A higher CSI (range 0-1) indicates a stronger overall forecasting skill of the model.
[0130] F1 score: This score combines the model's hit rate and precision, and is calculated using the following formula:
[0131]
[0132] A higher F1 score indicates better overall predictive performance of the model under imbalanced positive and negative sample conditions.
[0133] AUC (Area Under Curve): The area under the ROC curve, used to measure the overall ability of a model to distinguish between "lightning" and "no-lightning" samples at different thresholds. The closer the AUC is to 1, the better the model performance.
[0134] In this embodiment, the model of the present invention was compared with the mainstream spatiotemporal sequence prediction model ConvGRU on a test set. All models were given lightning density data of the past hour (10 frames) as input and predicted the lightning distribution of the next hour (10 frames). The results show that the present model is superior in all evaluation metrics. The specific results are shown in Table 1.
[0135] Table 1
[0136] ConvGRU 0.3025 0.8107 0.1367 0.2146 0.8569 This model 0.5514 0.6183 0.2413 0.3069 0.9913
[0137] S7. Lightning proximity forecasting based on trained deep learning models.
[0138] The real-time ground-based lightning location data to be predicted is processed into a real-time lightning frequency grid sequence according to the above steps. The first 10 frames are then input into the S5-trained 3D spatiotemporal Transformer model. The model will directly output, end-to-end, pixel-by-pixel lightning occurrence probability maps and binarized warning maps for the next 10 frames (i.e., within the next hour), thereby achieving accurate lightning nowcasting. Figure 4The image shows a visualization of the model's prediction results for the first frame (first 6 minutes) and the last frame (last 6 minutes) during the period from 00:24 UTC to 01:24 UTC on July 16, 2023. The colored contour lines in the image represent the probability prediction results, and the black scatter dots represent the actual lightning locations that occurred later. The results in the image show that the model can accurately predict the occurrence and development of lightning.
[0139] The above embodiments are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make several improvements and equivalent substitutions without departing from the principle of the present invention. All such improvements and equivalent substitutions to the claims of the present invention fall within the protection scope of the present invention.
Claims
1. A lightning nowcasting method based on lightning location data and a three-dimensional spatiotemporal Transformer, characterized in that, Includes the following steps: S1. Acquire ground-based lightning location data and perform time-space dot-mapping processing to obtain a lightning frequency grid sequence; S2. Perform quality control and sampling on the lightning frequency grid sequence to obtain a sample sequence; S3. Divide the dataset based on the sample sequence and construct the model input and binary labels; S4. Construct a deep learning model based on a three-dimensional spatiotemporal Transformer; S5. Based on the training set and validation set, train the deep learning model according to the training strategy; S6. Evaluate the performance of deep learning models based on the test set; S7. Lightning proximity forecasting based on trained deep learning models.
2. The lightning nowcasting method based on lightning location data and a three-dimensional spatiotemporal Transformer according to claim 1, characterized in that, Step 1 specifically includes the following steps: S11. Pre-set the start time T0 and end time T of data acquisition. n Latitude and longitude range (Lon0~Lon) n ,Lat0~Lat n ), time resolution t and spatial resolution r, requiring (T) n Both -T0) and 1 hour duration are divisible by t (Lon n -Lon0) and (Lat) n -Lat0) are all divisible by r; S12. Obtain lightning location data of the ground-based lightning location system within a preset time period and latitude and longitude range, including the occurrence time and latitude and longitude coordinates (lon, lat) of each lightning strike. S13. Based on the temporal resolution, the preset time period is divided into a sequence of n consecutive time windows ordered in ascending order of time. For each time window, the target area is divided into a two-dimensional grid according to the spatial resolution, where n = (T n -T0) / t, grid height H = (Lat) n -Lat0) / r, width W = (Lon n -Lon0) / r, the lightning count at each grid point in the grid is recorded as 0, generating the initial lightning frequency grid sequence; S14. Divide the lightning location data into time windows according to the occurrence time, and calculate the grid coordinate position (i, j) of the lightning in the corresponding lightning frequency grid according to the latitude and longitude coordinates of the lightning, where i = [(lon - Lon0) / r], j = [lat - Lat0) / r], and [] indicates rounding down; S15. Count the cumulative number of lightning strikes in each grid point of the lightning frequency grid for each frame, and update the grid with the cumulative number of lightning strikes as the new lightning frequency to obtain a new lightning frequency grid sequence.
3. The lightning nowcasting method based on lightning location data and a three-dimensional spatiotemporal Transformer according to claim 1, characterized in that, Step 2 specifically includes the following steps: S21. Use morphological filtering to perform quality control on the generated lightning frequency grid sequence: For any non-zero frequency grid point in each frame of lightning frequency grid, use a circular kernel with a radius of 0.1° to perform neighborhood analysis. The grid point will be retained if and only if there are at least 2 other non-zero frequency grid points in its neighborhood; otherwise, the lightning frequency of the grid point will be reset to 0. S22. For the quality-controlled lightning frequency grid sequence, construct a sliding window of length L frames for sampling, requiring L≥4+1h / t. Starting from the first L frames of the lightning frequency grid, the lightning frequency grid sequence is detected from front to back with a sliding distance of 1 frame. In each detection, the lightning frequency grid sequence of length L that meets the following conditions is packaged into a sample: the total lightning frequency of the lightning frequency grid in the window is 0, and its total number of frames is less than L / 2. S23. Arrange the samples according to the order of their generation to obtain a time-increasing sample sequence.
4. The lightning nowcasting method based on lightning location data and a three-dimensional spatiotemporal Transformer according to claim 1, characterized in that, Step 3 specifically includes the following steps: S31. Divide the first 75% of the samples in the sample sequence into a training set, and divide the remaining 25% of the samples into a test set and a validation set. S32. First, perform a logarithmic transformation on the lightning frequency grid of all samples in the training set to obtain logarithmic domain data; then, calculate the mean grid μ_log and the standard deviation grid σ_log based on the logarithmic domain data. S33. For each sample in all datasets, use the lightning frequency grid sequence of the first L-1h / t frames as input data and the lightning frequency grid sequence of the last 1h / t frames as supervision labels. S34. Perform a logarithmic transformation on the lightning frequency grid of each frame in the input data, and then perform Z-score normalization: ; in, This is grid data for lightning frequency. ; S35. Binarize the sample supervision labels: For each frame of the lightning frequency grid in the sequence, reset all grid points with a lightning frequency greater than 0 to 1 to generate a binary grid. S36. For each frame of the binary grid in the sample supervision label, for all grid points with a value of 1, set the grid point values with a value of 0 within a radius of 0.06° to 1 as well.
5. The lightning nowcasting method based on lightning location data and a three-dimensional spatiotemporal Transformer according to claim 1, characterized in that, Step 4 specifically includes the following steps: S41. Construct the input preprocessor: The input preprocessor consists of a patch embedding layer connected to a positional encoding layer. The patch embedding layer converts the gridded input data into a high-dimensional token sequence, and the positional encoding layer injects positional information into each token. S42. Construct the spatiotemporal Transformer encoder: The spatiotemporal Transformer encoder is the core unit for capturing the spatiotemporal evolution features of lightning. It consists of several TSST spatiotemporal coding layers stacked together and then connected to a normalization layer. Each TSST spatiotemporal coding layer contains four sequential, gated Transformer modules with a Pre-Norm Transformer structure. These four modules perform feature extraction and evolution in the time dimension, spatial dimension, spatial dimension, and time dimension respectively according to the forward input order, thereby efficiently capturing global spatiotemporal dependencies while reducing computational complexity. S43. Construct a 3D convolutional decoder: The 3D convolutional decoder consists of several stacked upsampling layers. Each upsampling layer is composed of a linear interpolation module, a 3D convolution module, and a thinning module in sequence. It is used to fuse the high-dimensional spatiotemporal context features output by the encoder to predict the future development of lightning and reconstruct the spatial resolution of lightning features in the process. S44. Construct the complete model: The sample input data is first converted into a high-dimensional token sequence with spatial location by an input preprocessor. Then, the token sequence is input into a spatiotemporal Transformer encoder to learn the spatiotemporal evolution of lightning through spatiotemporal decomposition and extract multi-scale spatiotemporal features. The token sequence output by the encoder is recombined into a tensor format adapted to the input of a 3D convolutional layer. This tensor is then input into a 3D convolutional decoder to predict the future development of lightning and perform upsampling reconstruction to restore the original spatial resolution. Finally, the data passes through a 3D convolutional projection layer to map the number of channels to 1, resulting in an output feature map with the same spatiotemporal size as the supervision label. The Sigmoid activation function is applied to each grid point of the output feature map to obtain a lightning occurrence probability map.
6. The lightning nowcasting method based on lightning location data and a three-dimensional spatiotemporal Transformer according to claim 1, characterized in that, The training strategy described in step 5 is as follows: The loss function adopts the weighted cross-entropy loss function with positive sample weights to solve the label class imbalance problem; the optimizer and learning rate scheduling use the adaptive moment estimation optimizer AdamW, combined with the learning rate scheduling strategy OneCycle to achieve fast and stable convergence; regularization strategy: to prevent model overfitting, a combination of Dropout, DropPath and gradient clipping regularization techniques are used; data augmentation: during training, random scaling, random flipping and rotation data augmentation operations are applied to the input data to improve the model's generalization ability.
7. The lightning nowcasting method based on lightning location data and a three-dimensional spatiotemporal Transformer according to claim 1, characterized in that, The model performance evaluation method described in step 6 is as follows: input the sample input data from the test set into the model, calculate the probability prediction map output by the model; convert the probability prediction map into a binary prediction result according to the set threshold; construct a confusion matrix based on the grid-by-grid comparison between the prediction result and the supervision label, and calculate the hit rate (POD), false alarm rate (FAR), critical success index (CSI), F1 score, and area under the receiver operating characteristic (AUC) curve to comprehensively evaluate the spatiotemporal prediction performance of the model under sparse lightning events.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method of claim 1.
9. A computer-readable storage medium having a computer program / instructions stored thereon, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method of claim 1.
10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method of claim 1.