A soil carbon flux prediction method and device
By introducing feature enhancement and distribution offset correction into the Autoformer model, the problems of insufficient feature extraction and distribution offset in soil carbon flux prediction are solved, and more accurate soil carbon flux prediction is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUZHOU UNIVERSITY
- Filing Date
- 2026-04-17
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies for predicting soil carbon flux suffer from insufficient model feature extraction and feature distribution offset between the lookback window and the prediction window, resulting in low prediction accuracy.
An Autoformer-based temporal prediction model is adopted, and feature enhancement and distribution offset correction are performed, including temporal decomposition, adaptive fusion, adaptive feature attention mechanism and Dish offset correction module, to enhance the model's ability to extract multi-dimensional temporal features and correct feature distribution offset.
It significantly improves the accuracy and reliability of soil carbon flux prediction, enhances the model's generalization ability and stability, and achieves more accurate predictions of carbon flux at future time steps.
Smart Images

Figure CN122492415A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the intersection of environmental monitoring and artificial intelligence technologies, specifically to a method and apparatus for predicting soil carbon flux, and more particularly to a soil carbon flux prediction technology based on a time-series prediction model. Background Technology
[0002] Soil carbon flux is a key parameter for assessing ecosystem carbon cycling and climate change response. Accurate prediction of soil carbon flux is crucial for agricultural soil management, ecosystem carbon cycle assessment, and climate change research. Currently, using time-series monitoring data combined with machine learning or deep learning models for prediction has become an important technique. Among these, time-series prediction models based on encoder-decoder architectures are widely used because they can effectively capture long-term dependencies in the sequence. However, existing technologies still have limitations when applied to time-series data like soil carbon flux, which exhibits complex periodicity and trends. The closest existing technology typically uses standard encoder-decoder models directly to predict soil carbon flux monitoring data. These models often struggle to fully extract the multi-dimensional and complex features hidden within the time-series data, such as the interaction between long-term trends and seasonal variations. Furthermore, due to potential distributional differences between the historical data used for model training and the future data to be predicted (i.e., distribution shift), the time-series feature representation used by the model in the decoding and prediction stage is inconsistent with the feature distribution of the actual future data, thus affecting the accuracy of the prediction. Therefore, existing technologies suffer from limitations in soil carbon flux prediction accuracy due to insufficient model feature extraction capabilities and feature distribution shifts between the lookback window and the prediction window. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to overcome the defects of the existing soil carbon flux prediction methods, which have low prediction accuracy due to insufficient model feature extraction and distribution offset between the lookback window and the prediction window.
[0004] To address the aforementioned technical problems, this invention provides a method for predicting soil carbon flux. The method includes acquiring soil carbon flux monitoring data for a target area, wherein the soil carbon flux monitoring data constitutes a continuous time series. The soil carbon flux monitoring data is preprocessed to obtain a standardized time series dataset. A time series prediction model is used to process the standardized time series dataset to output predicted carbon flux values for future time steps. Specifically, the time series prediction model, in its encoding / decoding architecture, performs feature enhancement processing and distribution offset correction processing on the input sequence.
[0005] Furthermore, the preprocessing includes at least one of outlier removal, missing value imputation, noise suppression, and normalization. As one implementation, the outlier removal employs a criterion based on statistical distribution patterns, and the missing value imputation employs an interpolation method based on temporal continuity.
[0006] Furthermore, the temporal prediction model is an autoregressive prediction model comprising an encoder and a decoder. The feature enhancement processing operates within the encoder and / or decoder to enhance the model's ability to extract multi-dimensional temporal features. The distribution offset correction processing operates between the encoder and the decoder to correct the feature distribution offset between the lookback window and the prediction window.
[0007] In one embodiment, the feature enhancement process includes temporal decomposition of the input sequence to obtain trend components and seasonal components. Adaptive parameters are generated based on the interaction between the trend components and the seasonal components. The adaptive parameters are then used to adaptively fuse the temporal feature representation of the input sequence. The temporal decomposition of the input sequence employs Fourier decomposition. The adaptive fusion of the temporal feature representation of the input sequence using the adaptive parameters includes channel-dimensional aggregation of the fused temporal feature representation through one-dimensional convolution.
[0008] In another embodiment, the distribution offset correction process includes calculating a distribution offset based on the temporal feature representation of the lookback window and the temporal feature representation of the prediction window. Furthermore, based on the distribution offset, the temporal feature representation of the temporal prediction model during the decoding stage is corrected. Specifically, calculating the distribution offset based on the temporal feature representation of the lookback window and the temporal feature representation of the prediction window includes learning a first distribution parameter of the temporal feature representation of the lookback window using a first neural network. A second distribution parameter of the temporal feature representation of the prediction window is learned using a second neural network. The distribution offset is determined based on the first distribution parameter and the second distribution parameter.
[0009] Furthermore, the method also includes a step of training the time series prediction model, which includes adopting a phased training strategy and introducing regularization terms and early stopping strategies during the training process.
[0010] Furthermore, after outputting the predicted carbon flux values for future time steps, the method further includes inverse normalization of the predicted carbon flux values to obtain prediction results with true dimensions. And / or, generating a visualization chart of the prediction results. Furthermore, the method can be applied to agricultural soil management, ecosystem carbon cycle assessment, or climate change research.
[0011] To address the same technical problem, this invention also provides a soil carbon flux prediction device. The device includes a data acquisition module for acquiring soil carbon flux monitoring data of a target area, wherein the soil carbon flux monitoring data constitutes a continuous time series. A preprocessing module is used to preprocess the soil carbon flux monitoring data to obtain a standardized time series dataset. A prediction processing module is used to process the standardized time series dataset using a time series prediction model to output predicted carbon flux values for future time steps. The time series prediction model, in its encoding / decoding architecture, performs feature enhancement processing and distribution offset correction processing on the input sequence.
[0012] Furthermore, the prediction processing module includes an encoding unit for encoding the input sequence to obtain a temporal feature representation, and performing the feature enhancement processing during the encoding process. An offset correction unit is used to perform the distribution offset correction processing on the temporal feature representation to obtain a corrected temporal feature representation. A decoding unit is used to decode the corrected temporal feature representation and output the predicted carbon flux value.
[0013] To address the same technical problem, the present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the program to implement the above-described soil carbon flux prediction method.
[0014] To address the same technical problem, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described method for predicting soil carbon flux.
[0015] Compared with the closest prior art, this invention has the following beneficial effects. The technical solution provided by this invention effectively solves the problems of insufficient feature extraction and low prediction accuracy caused by distribution offset in existing technologies by introducing feature enhancement and distribution offset correction into the encoding and decoding architecture of the time-series prediction model. Specifically, feature enhancement, through methods such as temporal decomposition and adaptive fusion, can more finely separate and fuse multi-dimensional features such as trends and seasons from the input sequence, thereby enhancing the model's ability to extract the inherent laws of complex temporal patterns in soil carbon flux. Distribution offset correction, by quantifying and correcting the feature distribution differences between the lookback window and the prediction window, makes the feature representation used in the decoding stage closer to the true distribution of future data, reducing prediction bias introduced by distribution inconsistency. The combination of these two processes enables the model to obtain richer and more accurate temporal features in the encoding stage and performs distribution alignment before the features are passed to the decoding stage, thus significantly improving the accuracy of carbon flux predictions for future time steps. Furthermore, preprocessing steps including outlier removal and missing value imputation improve the quality of the input data, laying the foundation for accurate prediction by the model. By employing a training method that includes regularization terms and an early stopping strategy, the generalization ability and stability of the model are improved. Therefore, this invention enables more accurate and reliable prediction of soil carbon flux. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 A flowchart of a soil carbon flux prediction method provided in one embodiment of this application is shown; Figure 2 This paper shows an overall principle block diagram of a regression prediction model provided in one embodiment of the present application; Figure 3 This illustration shows a schematic diagram illustrating the working principle of an adaptive feature attention mechanism provided in one embodiment of this application; Figure 4 This illustration shows a schematic diagram illustrating the working principle of a coordinate attention mechanism provided in one embodiment of this application; Figure 5 This application provides a model that balances accuracy and recall performance in one embodiment; Figure 6 A block diagram of a soil carbon flux prediction device according to an embodiment of this application is shown; Figure 7 A schematic diagram of the structure of a computer device provided in one embodiment of this application is shown. Detailed Implementation
[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0019] The embodiments of this invention aim to provide a method, apparatus, electronic device, and storage medium for predicting soil carbon flux that can effectively improve prediction accuracy. This method is mainly applied in fields such as agricultural soil management, ecosystem carbon cycle assessment, or climate change research. In these fields, accurate soil carbon flux data is the foundation for scientific assessment and management decisions. Traditional prediction methods suffer from limited accuracy due to insufficient model feature extraction and the distribution offset problem between the lookback window and the prediction window. This invention effectively solves the above problems by introducing feature enhancement processing and distribution offset correction processing.
[0020] Figure 1 A flowchart illustrating the method for predicting soil carbon flux is shown. Figure 1 As shown, an embodiment of the present invention provides a method for predicting soil carbon flux, which includes steps S1, S2, and S3. The details are as follows: Step S1, acquiring soil carbon flux monitoring data for a target area, which constitutes a continuous time series; Step S2, preprocessing the soil carbon flux monitoring data to obtain a standardized time series dataset; Step S3, processing the standardized time series dataset using a time series prediction model to output predicted carbon flux values for future time steps. The time series prediction model, in its encoding / decoding architecture, performs feature enhancement processing and distribution offset correction processing on the input sequence.
[0021] The above steps, through feature enhancement, enable the model to extract more refined multi-dimensional features such as trends and seasonality from the data; through distribution offset correction, the difference in feature distribution between historical data and future prediction data can be reduced. The combination of these two methods fundamentally solves the technical problems of low prediction accuracy caused by insufficient feature extraction and distribution offset in the background techniques, achieving a significant improvement in the accuracy of soil carbon flux prediction.
[0022] In this embodiment, step S1, obtaining soil carbon flux monitoring data for the target area, is specifically implemented as follows: Using soil samples from the target area as the research object, covering different soil types (such as red soil and paddy soil) and different land use types (such as cultivated land and forest land), a soil carbon flux monitoring device developed using the TDLAS system was employed to collect time-series data, ensuring the representativeness and comprehensiveness of the samples. The soil carbon flux monitoring device developed using the TDLAS system is based on tunable semiconductor laser absorption spectroscopy technology, enabling real-time, non-destructive monitoring without damaging the soil samples, and covering a wide monitoring range. The accuracy is no less than The monitoring frequency can be adaptively adjusted as needed, with hourly forecasts every hour and daily forecasts every 24 hours. The collected continuous carbon flux time-series data for 2023-2024 includes both hourly and daily time scales, covering monitoring time, monitoring point location, soil and land use types, carbon flux values, etc., forming data exhibiting continuous time series characteristics. The data is transmitted to the system wirelessly in real time and also supports offline import. During the collection process, obviously invalid data such as sensor malfunctions and data outside the monitoring range are initially removed to ensure data integrity and timeliness.
[0023] Step S2 preprocessing includes outlier removal in sub-step S21a and missing value imputation in sub-step S21b. Sub-step S21a, outlier removal, employs criteria based on statistical distribution patterns, such as the Laida criterion (3σ criterion). This involves calculating the mean and standard deviation of the data series, and identifying and removing data points whose absolute difference from the mean exceeds three times the standard deviation. Sub-step S21b, missing value imputation, uses interpolation methods based on temporal continuity, such as cubic spline interpolation. A smooth curve is fitted using known data points to estimate the values of missing points, ensuring the continuity of the time series.
[0024] Through data interaction and processing in sub-steps S21a and S21b, the function of cleaning data and ensuring data quality in step S2 is realized.
[0025] The preprocessing in step S2 may also include noise suppression (such as removing high-frequency noise through wavelet transform) and normalization (such as Min-Max normalization to map the data to the [0,1] interval) to further improve data quality. Data preprocessing can eliminate noise and dimensional differences in the original monitoring data, providing high-quality standardized input for subsequent time-series prediction models, which is a crucial foundation for achieving high-precision prediction.
[0026] In this embodiment, the temporal prediction model is an autoregressive prediction model that includes an encoder and a decoder. Step S3 includes sub-step S31a, feature enhancement processing, and sub-step S31b, distribution offset correction processing.
[0027] It should be noted that the autoregressive prediction model, which includes an encoder and decoder, is based on the Autoformer framework. By introducing adaptive feature attention and coordinate attention mechanisms within the encoder and / or decoder, and by setting up Dish offset correction modules in the encoder and decoder, it achieves multi-dimensional temporal feature extraction, distribution offset correction, and regression prediction. The overall principle block diagram of the autoregressive prediction model is shown below. Figure 2 As shown, a specific implementation process is as follows: The basic Autoformer framework, consisting of an encoder and a decoder, effectively captures the short- and long-term dependencies in carbon flux time-series data using a self-attention mechanism and a feedforward neural network. The encoder's input dimension corresponds to the T value, where short-term prediction T = 7-14 and long-term prediction T = 15-30. The model dimension d_model = 512, with two encoding layers and one decoding layer, dropout = 0.1, and GELU activation function. The encoder contains 3-5 self-attention layers and a feedforward neural network layer. The self-attention layers employ a multi-head structure to extract deep temporal features, while the feedforward neural network contains two fully connected layers using the ReLU activation function to achieve non-linear transformation of temporal features. The decoder employs a future masking mechanism to prevent information leakage, ensuring predictions are based solely on historical data. Its internal structure corresponds to that of the encoder, and it ultimately outputs preliminary carbon flux prediction results.
[0028] The adaptive feature attention mechanism decomposes the input time series into trend features and seasonal features through Fourier decomposition, generates adaptive parameters α and β using multilayer perceptron (MLP) and global average pooling (GAP), and combines one-dimensional convolution and residual connection to adaptively aggregate and correct features of different dimensions, so as to enhance the model's ability to jointly model trend and seasonal patterns in carbon flux data.
[0029] Among them, T c As a trend feature, S c For seasonal features, CG is the feature correction function, and K1 and K2 are convolutional kernels. The working principle of the adaptive feature attention mechanism is as follows: Figure 3 As shown.
[0030] Simultaneously, the Coordinate Attention mechanism transforms the attention across different channels in image processing into temporal dimension attention in temporal prediction. By adaptively selecting the kernel size k, one-dimensional convolution is performed on the temporal features to generate attention weights ω at different time steps, thereby adaptively adjusting the importance of features at different time steps in the historical sequence and strengthening key temporal information. The kernel size k is determined by mapping through the sequence length L, using the following formula: in The `odd` option is an odd-number operation to ensure that `k` is odd. Temporal channel weights are generated through one-dimensional convolution. It adaptively adjusts the weights of features at different time steps, strengthens key temporal information, suppresses redundant noise, and adds only k parameters, without significantly increasing computational cost. The working principle of the coordinate attention mechanism is as follows: Figure 4 As shown.
[0031] The Dish offset correction module, located between the encoder and decoder in Autoformer, compensates for the potential offset between the lookback window (historical data from T time steps) and the prediction window (future prediction data), optimizing the model's accuracy in capturing long- and short-term temporal dependencies. It employs a dual CONET architecture (also known as a context optimization network). BACKCONET learns the distribution coefficients of the input lookback window, normalizing the input sequence before prediction; HORICONET learns the distribution coefficients of the output prediction window, de-normalizing the output after prediction. This two-stage correction effectively compensates for the potential distribution offset between the lookback window and the prediction window. The module works as follows: First, the offset and its degree are determined by calculating the mean difference and variance of the temporal data in the two windows. Second, a linear correction algorithm is used to compensate for the offset, adjusting the temporal feature distribution of the prediction window to align with that of the lookback window. Finally, the corrected temporal features are input into the decoder to ensure the decoder accurately utilizes the historical temporal features extracted by the encoder, improving prediction accuracy.
[0032] Continue as Figure 1 As shown, the improved Autoformer model output layer uses two fully connected layers. The first fully connected layer has the same input dimension as the decoder output dimension, with an output dimension of 64, and uses ReLU activation. The second fully connected layer has an input dimension of 64 and an output dimension of 1, corresponding to the carbon flux prediction value at a single time step. A Sigmoid activation function is then connected to the output layer to map the prediction value to the [0,1] interval, consistent with the normalization range in the data preprocessing stage.
[0033] Based on the above introduction to the structure and working principle of the autoregressive prediction model, it can be understood that: The feature enhancement process in sub-step S31a specifically includes: First, performing a temporal decomposition on the input sequence to obtain trend components and seasonal components. As a specific implementation, the temporal decomposition can employ Fourier decomposition. Second, generating adaptive parameters based on the interaction between the trend components and the seasonal components. Finally, adaptively fusing the temporal feature representation of the input sequence using the adaptive parameters. The fusion process may include channel-dimensional aggregation of the fused temporal feature representation through one-dimensional convolution to enhance key features.
[0034] The distribution offset correction process in sub-step S31b operates between the encoder and the decoder to correct the feature distribution offset between the lookback window and the prediction window. Specifically, it includes: First, calculating the distribution offset based on the temporal feature representations of the lookback window and the prediction window. Specifically, a first distribution parameter (such as mean and variance) of the temporal feature representation of the lookback window can be learned through a first neural network, and a second distribution parameter of the temporal feature representation of the prediction window can be learned through a second neural network. Then, the distribution offset is determined based on the first and second distribution parameters. Second, the temporal feature representation of the temporal prediction model in the decoding stage is corrected according to the distribution offset.
[0035] Through the processing logic of sub-steps S31a and S31b, the model obtains richer feature representations during the encoding stage and performs distribution alignment before passing the features to the decoder, thereby making the final output carbon flux prediction more accurate.
[0036] In this embodiment, the method may further include step S4. Adding step S4 to the method flow, namely the step of training the time series prediction model, enables the model to learn patterns from historical data, which is a prerequisite for realizing the prediction function.
[0037] One specific implementation process of step S4 is as follows: (1) Dataset partitioning: The standardized carbon flux time series dataset was divided into training, validation, and test sets in a 7:2:1 ratio. The training set was used for model parameter training and updates, the validation set was used for adjusting hyperparameters and monitoring overfitting, and the test set was used to evaluate the final performance of the model and verify prediction accuracy and generalization ability. Stratified sampling was used to partition the dataset to ensure that the sample distribution of the three datasets was consistent with the original dataset, that is, the sample proportions of different soil types and different land use types remained unchanged, avoiding model training bias due to uneven sample distribution.
[0038] (2) Model Training: The Adam optimizer was used for model training. This optimizer has a fast convergence speed and can adaptively adjust the learning rate, which can effectively improve training efficiency. The initial learning rate was set to 1e-4, and a cosine annealing strategy was adopted. The learning rate was adjusted with a decay coefficient of 0.9 every 10 epochs to balance fast convergence in the early stage of training and fine-tuning of parameters in the later stage, thereby improving model accuracy. An early stopping strategy (patience=7) was adopted for training. Training was stopped when the validation set loss did not decrease for 7 consecutive epochs, and the model parameters with the minimum validation set loss were saved to avoid overfitting. The mean squared error (MSE) was used as the loss function to measure the deviation between the predicted value and the true value. At the same time, L2 regularization (regularization coefficient) was introduced into the fully connected layer. =1e-5), the loss function after regularization is (n is the sample size, For the true value, (where w is the predicted value and w is the model parameter). By penalizing excessively large parameters and reducing parameter redundancy, overfitting is further prevented and the model's generalization ability is improved.
[0039] (3) Parameter optimization: The model hyperparameters were optimized using a grid search method. All combinations of the number of self-attention layers (3 / 4 / 5), the number of attention heads (4 / 8 / 16), the output dimension of the feedforward neural network (64 / 128 / 256), the learning rate (1e-5 / 1e-4 / 1e-3), and the Dish offset correction coefficient (0.1 / 0.2 / 0.3) were traversed. The models of each combination were trained and the validation set loss was calculated. The combination with the smallest loss was selected to complete the parameter fine-tuning and obtain the optimal Autoformer prediction model. The optimal hyperparameter combination is as follows: number of self-attention layers (3 layers for hourly level, 5 layers for daily level), number of attention heads (8), output dimension of the feedforward neural network (64 for hourly level, 128 for daily level), initial learning rate (1e-4), Dish offset correction coefficient (0.15 for hourly level, 0.25 for daily level), ECA module convolution kernel γ=2, b=1.
[0040] (4) Model Validation: Mainstream time-series prediction models such as LSTM, Transformer, the original Autoformer, SCINet, Informer, and Linear were selected as comparison models. Root mean square error (RMSE), correlation coefficient (CC), mean absolute error (MAE), and dynamic time warping (DTW) were used as performance evaluation indicators. The evaluation criteria were that the smaller the RMSE and MAE, the smaller the deviation and average error between the predicted and actual values; the closer the CC was to 1, the stronger the correlation between the predicted and actual values. Experimental verification showed that the Autoformer model of this invention outperformed the comparison models in all evaluation indicators and performed well in the soil carbon flux time-series prediction task. The calculation formulas for each evaluation indicator are as follows: in, To test the actual carbon flux values, To predict carbon flux values for the model, The average of the true values in the test set. is the average value predicted by the model, and n is the number of samples in the test set.
[0041] S5. Soil Carbon Flux Prediction: The preprocessed real-time carbon flux time-series data is input into the optimal Autoformer prediction model obtained in S4. This enables accurate short-term predictions and long-term trend forecasts of soil carbon flux. The input consists of standardized carbon flux time-series data from the most recent T time steps (T values range from 7 to 30). For short-term predictions (hourly and daily), T = 7-14, using real-time data from the most recent 7-14 time steps; for long-term predictions (monthly), T = 15-30, using real-time data from the most recent 15-30 time steps. After feature extraction, time-series modeling, and offset correction, the model outputs short-term carbon flux predictions for the next 1-7 time steps or long-term trend predictions for the next 1-12 months. The results are then processed using an inverse normalization formula. (x is the actual carbon flux value,) For normalized predicted values, , (The maximum and minimum values of the time series recorded in S2.3), the predicted values are converted back to units of The system calculates the 95% confidence interval while outputting the actual physical quantity of carbon flux, thus clarifying the reliability of the prediction and providing users with a comprehensive reference.
[0042] S6. Visualization and Log Storage of Prediction Results: The prediction results will be visualized and prediction logs will be automatically saved for easy subsequent querying, tracing, and analysis. Visualization will use line charts, bar charts, etc., to compare and display predicted carbon flux values with historical actual values, intuitively presenting trends. Statistical tables containing prediction time, predicted values, and confidence intervals will be generated for quick viewing of details. Visualized charts support zooming in, zooming out, and saving in formats including PNG and PDF. Prediction logs will be automatically saved, covering prediction time, monitoring point location, soil type, land use type, prediction parameters (prediction time scale, T-value, model hyperparameters), prediction results (including confidence intervals), and model performance indicators (RMSE, CC, MAE, DTW). Logs will be saved in txt or Excel format, categorized by time, monitoring point, and soil type, with a retention period of no less than 3 years.
[0043] In summary, step S4, training the time-series prediction model, includes sub-steps S41a and S41b. Sub-step S41a employs a phased training strategy. For example, the basic encoding / decoding structure of the model can be trained first, then some layers can be frozen, and the feature enhancement module or distribution offset correction module can be trained separately. Sub-step S41b introduces regularization terms and early stopping strategies during training. Regularization terms (such as L2 regularization) can be added to the loss function to penalize excessively large model parameters and prevent overfitting; the early stopping strategy terminates training prematurely when the model's performance on the validation set no longer improves, thus avoiding overlearning on the training set. Through sub-steps S41a and S41b, the model training process can be optimized, improving the model's generalization ability and stability.
[0044] In this embodiment, after outputting the predicted carbon flux value for the future time step, step S5 is further included. Step S5 includes sub-steps S51 and / or S52. Sub-step S51 involves denormalizing the predicted carbon flux value to obtain the prediction result with true dimensions. Specifically, using the normalization parameters (such as minimum and maximum values) recorded during preprocessing, the predicted values in the [0,1] interval output by the model are restored to their original physical dimensions (e.g., ...). Sub-step S52 involves generating a visualization chart of the prediction result, such as a line chart showing the comparison trend between historical data and future prediction values. Adding step S5 makes the prediction result easier to understand and use, facilitating user decision analysis.
[0045] Furthermore, the specific implementation of the time-series prediction model can also include inputting the time-series feature representation extracted by the encoder into the decoder for autoregressive decoding, progressively generating predicted values for multiple future time steps. The model can be trained using the Adam optimizer, with a cosine annealing strategy to dynamically adjust the learning rate. For data such as soil carbon flux, the input sequence length (T-value) and some hyperparameters can be adaptively adjusted according to different prediction time scales (e.g., hourly, daily) to improve the model's adaptability.
[0046] This application also provides an Autoformer-based soil carbon flux prediction system, comprising: a data acquisition module, a data preprocessing module, a model building and training module, a carbon flux prediction module, a result visualization module, a log storage module, and a user interaction module. It is configured to execute the aforementioned Autoformer-based soil carbon flux prediction method. The system is designed based on the Streamlit framework and is a lightweight web application. The specific configurations of each module are as follows: (a) Data acquisition module, configured as a soil carbon flux monitoring device developed through the TDLAS system, to collect time series data of carbon flux under different soil types, different land use and cover scenarios in the target area, supports real-time acquisition and offline import, and can adjust the monitoring frequency to ensure the comprehensiveness and timeliness of the data; (b) Data preprocessing module, configured to connect with data acquisition module, cleans, denoises, normalizes and calibrates the acquired carbon flux time series data, outputs standardized carbon flux time series dataset, supports batch processing, and improves data processing efficiency; (c) Model building and training module, configured to connect with the data preprocessing module, builds the Autoformer prediction model (introducing an adaptive feature attention mechanism and a Dish offset correction module), uses a standardized carbon flux time series dataset to train the model and optimize parameters, supports training and performance comparison of mainstream comparative models, and supports model saving and loading; (d) Carbon flux prediction module, configured to connect with the model building and training module, inputs the preprocessed real-time carbon flux time series data into the trained Autoformer prediction model, and outputs short-term or long-term trend prediction values of soil carbon flux, supporting multi-time scale prediction. (e) Results visualization module, configured to connect with carbon flux prediction module, to visualize prediction results in the form of charts such as line charts and bar charts, and to support chart zooming, zooming and saving operations, so that users can intuitively view the trend of carbon flux changes; (f) Log saving module, configured to connect to the carbon flux prediction module and the result visualization module respectively, automatically save prediction logs, including prediction time, prediction parameters, prediction results, model performance indicators and other information, and support log query, export and other operations; (g) User interaction module, configured with a graphical interface designed using the Streamlit framework, is easy to operate and supports users to set data acquisition parameters, preprocessing parameters, model hyperparameters, start model training and prediction, view visualization results and prediction logs, and adapt to the usage needs of users at different levels.
[0047] Furthermore, in the steps performed by the data preprocessing module, data cleaning uses the Laida criterion (3σ criterion) to remove outliers and cubic spline interpolation to fill missing values; data denoising uses db4 wavelet decomposition at three levels to extract low-frequency components and reconstruct time-series data; data normalization uses the Min-Max normalization method to map the data to the [0,1] interval, and the normalization formula satisfies: Where x represents the original carbon flux data. This represents the minimum value of carbon flux data in this time series. This represents the maximum value of the carbon flux data in this time series. The data is normalized; the time series calibration is based on the time of the benchmark monitoring point, correcting the time deviation of other monitoring points, and the time format is unified as "year-month-day-hour".
[0048] Furthermore, the Autoformer prediction model constructed by the model building and training module includes a basic Autoformer framework comprising 3-5 self-attention layers and a feedforward neural network layer. The self-attention layers employ a multi-head self-attention mechanism, and the feedforward neural network layer employs the ReLU activation function. An adaptive feature attention mechanism is embedded in the self-attention layers, and Q, K, and V matrices are obtained through linear transformation. Attention weights are calculated and weighted summation is performed to obtain the enhanced temporal feature matrix. The Dish offset correction module is located between the encoder and decoder. The offset is determined by calculating the mean difference and variance between the lookback window and the prediction window, and a linear correction algorithm is used to compensate for the offset. The output layer consists of two fully connected layers, with the output end connected to a Sigmoid activation function to map the predicted value to the [0,1] interval.
[0049] Furthermore, the model training process executed by the model building and training module employs the Adam optimizer with an initial learning rate of 1e-4. A cosine annealing strategy is used to adjust the learning rate, which decays every 10 epochs with a decay coefficient of 0.9. An early stopping strategy (training stops if the validation set loss does not decrease for 15 consecutive epochs) and L2 regularization (regularization coefficient 1e-5) are used to prevent overfitting. The training loss function satisfies: Where n is the number of samples. This represents the actual carbon flux value. To predict carbon flux values for the model, is the L2 regularization coefficient, and w is the model parameter.
[0050] Furthermore, the model building and training module uses a grid search method to optimize hyperparameters. The hyperparameters to be optimized include the number of self-attention layers in the Autoformer encoder / decoder (3 / 4 / 5), the number of attention heads (4 / 8 / 16), the output dimension of the feedforward neural network (64 / 128 / 256), the learning rate (1e-5 / 1e-4 / 1e-3), and the Dish offset correction coefficient (0.1 / 0.2 / 0.3). The combination of hyperparameters with the minimum loss on the validation set is selected as the optimal parameters.
[0051] Furthermore, the model validation process performed by the model building and training module compares LSTM models, Transformer models, and the original Autoformer model. Performance evaluation metrics include RMSE, CC, and MAE, and the calculation formulas for each metric satisfy the following: in, To test the actual carbon flux values, To predict carbon flux values for the model, The average of the true values in the test set. is the average value predicted by the model, and n is the number of samples in the test set.
[0052] Furthermore, in the prediction process executed by the carbon flux prediction module, the T value of the input data ranges from 7 to 30. For short-term predictions (hourly and daily levels), T = 7-14 is used, and for long-term trend predictions (monthly levels), T = 15-30 is used. The prediction output is a normalized value, which is then denormalized to restore the actual carbon flux physical quantity. The denormalization formula satisfies: Where x is the actual carbon flux value. The normalized predicted value output by the model. , These are the minimum and maximum values of the corresponding time series recorded during the data preprocessing stage. The unit for the actual carbon flux value is... It also outputs a 95% confidence interval to clearly demonstrate the reliability of the prediction.
[0053] Furthermore, the results visualization module supports the display of charts such as line charts and bar charts, and supports chart zooming, zooming, and saving, while simultaneously generating a statistical table of prediction results; the log saving module saves log content including prediction time, prediction parameters, prediction results, model performance indicators, monitoring point information, soil type and land use type, and saves in txt or Excel format, supports classification and management by time and monitoring point, and the retention period is not less than 3 years.
[0054] The inventive concept of the above embodiments lies in: The core mechanism of this invention lies in achieving high-precision short-term prediction and long-term trend forecasting of soil carbon flux through a technical path of "precise time-series data acquisition - multi-step data preprocessing - Autoformer modeling - multi-dimensional verification and optimization". Its key mechanisms include the following four aspects: 1. TDLAS Time-Series Data Accurate Acquisition Mechanism: The TDLAS soil carbon flux monitoring device is based on tunable semiconductor laser absorption spectroscopy technology. Its core advantages are real-time, non-destructive monitoring, avoiding damage to soil samples, and accurate and continuous monitoring data. Its core mechanism is: through the absorption characteristics of specific wavelength lasers, it accurately captures subtle changes in soil carbon flux, with a monitoring range of 0-10. The monitoring accuracy is no less than ±0.01. The monitoring frequency can be adaptively adjusted according to hourly or daily forecasting needs. During the data collection process, the main soil types in the target area, such as red soil, paddy soil, and alluvial soil, as well as land use types such as cultivated land, forest land, and orchard land, are covered. A combination of 4G / 5G wireless transmission and offline import is used to ensure timely and complete data. At the same time, invalid information such as sensor malfunctions and data exceeding reasonable ranges is initially screened out to provide high-quality raw data support for subsequent data preprocessing.
[0055] 2. Multi-step time-series data preprocessing mechanism: Soil carbon flux time-series data suffers from outliers, noise, dimensional differences, and time-series biases, which can affect the accuracy of model predictions. The core mechanism of multi-step preprocessing is to gradually eliminate data defects through hierarchical processing and construct a standardized time-series dataset. Specifically, outliers are first removed using the Laida criterion (3σ criterion), and missing values are filled in and duplicates are removed using cubic spline interpolation to ensure data integrity. Then, db4 wavelet 3-level decomposition is used to denoise, separating the real signal (low-frequency component) from the noise signal (high-frequency component). After reconstruction, the true trend of carbon flux changes is preserved, reducing environmental and sensor error interference. Subsequently, Min-Max normalization is used to map the data to the [0,1] interval to eliminate dimensional differences, and extreme values are recorded for subsequent inverse normalization to ensure that the prediction results can be restored to the real physical quantity. Finally, time-series calibration is used to correct the time deviation of multiple monitoring points and unify the time format to ensure the temporal consistency of the time-series data, laying the foundation for the model to capture long-term and short-term dependencies.
[0056] 3. Autoformer Modeling Mechanism: Based on the Autoformer framework, this model addresses its shortcomings in carbon flux prediction, such as insufficient channel information capture and misalignment between the lookback window and the prediction window. It introduces an adaptive feature attention mechanism and a Dish offset correction module. The core principle is to achieve accurate extraction of temporal features and effective capture of temporal dependencies through hierarchical optimization. Specifically, the basic Autoformer uses a multi-head self-attention mechanism in the encoder and decoder to capture the long-term and short-term dependencies in carbon flux. The adaptive feature attention mechanism, embedded in the self-attention layer, calculates attention weights for different channels and time steps to focus on key features affecting carbon flux changes, suppressing redundant information and improving the targeting of feature extraction. The Dish offset correction module, located between the encoder and decoder, determines the offset by calculating the mean difference and variance between the lookback window (historical data) and the prediction window (future data). Linear correction ensures consistent temporal feature distribution between the two windows, optimizing the accuracy of temporal dependency capture. The output layer uses a fully connected layer and a sigmoid activation function to map the predicted values to the corresponding intervals, adapting to the preprocessed data and providing support for subsequent inverse normalization.
[0057] 4. Model Training, Validation, and Prediction Optimization Mechanism: The core mechanism of model training, validation, and prediction optimization is to ensure the model's generalization ability and prediction accuracy through scientific training strategies, parameter optimization, and multi-dimensional validation, achieving accurate and traceable prediction results. Specifically, a 7:2:1 stratified sampling method is used to divide the dataset, ensuring consistent sample distribution across the training, validation, and test sets to avoid training bias. The Adam optimizer, cosine annealing learning rate adjustment, early stopping strategy, and L2 regularization are used to achieve rapid model convergence and prevent overfitting. A grid search method is used to traverse hyperparameter combinations to select the optimal parameters to improve model performance. Simultaneously, the model's superiority is verified by comparing it with mainstream models such as LSTM and Transformer using RMSE, CC, and MAE metrics. In the prediction phase, the input time series length is adaptively selected according to the time scale. After model feature extraction and offset correction, the normalized predicted value is output. Then, the true carbon flux value is restored through inverse normalization. The reliability is determined by calculating the 95% confidence interval. Simultaneously, the prediction results are presented intuitively and tracked for a long time through visualization and log saving, providing support for soil carbon flux monitoring and analysis.
[0058] The effect of the inventive concept in this application is as follows: This invention addresses the shortcomings of traditional soil carbon flux detection methods and the deficiencies of existing time-series prediction models. By combining TDLAS technology, the Autoformer model, and the Streamlit framework, it provides an Autoformer-based soil carbon flux prediction method and system, which offers the following significant technical advantages compared to existing technologies: 1. High prediction efficiency and non-destructive monitoring: The soil carbon flux monitoring device developed using the TDLAS system enables real-time and non-destructive monitoring of soil carbon flux, avoiding damage to soil samples. The monitoring frequency can be adaptively adjusted, solving the problems of long detection cycles, time-consuming and labor-intensive, high cost and strong destructiveness of traditional methods. At the same time, it achieves rapid prediction through the Autoformer model, with a prediction response time of no more than 10 seconds, which significantly improves the prediction efficiency of soil carbon flux.
[0059] 2. High prediction accuracy: Ablation experiments have verified that the adaptive feature attention mechanism improves the model's ability to capture key temporal features by 30%, the improved ECA attention mechanism improves the model's correlation coefficient (CC) by 67.1%, and the Dish offset correction module reduces the offset error between the back window and the prediction window by 20%. The synergistic effect of the three mechanisms reduces the model's MSE by 32.1% compared to the original Autoformer, and the prediction accuracy is significantly better than existing models.
[0060] 3. Strong adaptability: The research object is carbon flux data of different soil types, land use and cover scenarios in the target area. The sample data is highly representative. The model has been trained and optimized in a targeted manner and can adapt to the soil carbon flux prediction needs under different soil types and land use scenarios. It has strong generalization ability. At the same time, it supports multi-time scale prediction and can meet the diversified needs of short-term monitoring and long-term trend prediction.
[0061] 4. Easy to operate and highly practical: Based on the Streamlit framework, this lightweight web application integrates functions such as data acquisition, preprocessing, model training, prediction, result visualization, and log saving, achieving integrated operation. The graphical interface is simple and intuitive, easy to operate, supports offline operation, and adapts to the needs of users at different levels. Prediction operations can be completed without professional technical personnel, facilitating the promotion and application of the technology.
[0062] 5. Data traceability and easy analysis: Automatically saves prediction logs, records various information during the prediction process, and retains them for no less than 3 years. It supports log classification query and export, which facilitates users to trace and analyze prediction data in the future, and provides reliable data support for soil carbon flux monitoring and soil resource management.
[0063] 6. Wide range of applications: This invention can quickly and accurately predict soil carbon flux and can be widely applied to fields such as agricultural development, soil resource management, global carbon cycle research, and climate change assessment. It provides efficient and non-destructive technical support for soil carbon flux monitoring, helps sustainable agricultural development and global climate change response, and has important theoretical value and practical application prospects.
[0064] The following provides more detailed implementation examples of the above inventive concept for the understanding of those skilled in the art, as follows: Example 1: Specific Implementation of the Soil Carbon Flux Prediction Method Based on Autoformer 1.1 Sample Data Collection Two monitoring areas were selected in Huzhou City: paddy soil (cultivated land) and red soil (forest land). Three monitoring points were set up in each area. The TDLAS soil carbon flux monitoring device was used to collect carbon flux time-series data from January 2023 to December 2024. Monitoring parameters were set as follows: daily monitoring, monitoring range 0-10. Accuracy ±0.01 The collected data includes monitoring time, monitoring point location, soil and land use type, and carbon flux value, with the carbon flux of paddy soil ranging from 1.2 to 6.8. Red soil 0.8-5.3 Data is transmitted to the system in real time via 4G wireless, while outliers caused by sensor malfunctions (carbon flux > 10 or < 0) are removed to ensure data integrity and validity.
[0065] 1.2 Data Preprocessing The collected carbon flux time-series data underwent cleaning, denoising, normalization, and time-series calibration. Specifically, the Laida criterion (3σ criterion) was used to remove 32 outlier data points, cubic spline interpolation was used to fill in 18 missing data points, and 5 duplicate data points were removed, resulting in 715 valid time-series data points. A 3-level decomposition was performed using db4 wavelets, and high-frequency noise was processed through thresholding and data reconstruction to remove interference. Min-Max normalization was used to map the data to the [0,1] interval, where the maximum carbon flux in paddy soil ranged from 1.2 to 6.8. The red soil forest area has a density of 0.8-5.3. The maximum and minimum values of various types of data are recorded synchronously for subsequent inverse normalization. Based on the time of the benchmark monitoring point, the time deviation of other monitoring points is corrected and the time format is unified. Combined with the daily short-term forecasting requirements, T=7 is taken. The preprocessed data is sorted by time to construct time series samples, and finally 694 standardized time series samples are obtained, providing high-quality data support for model training.
[0066] 1.3 Autoformer Prediction Model Construction Based on the Autoformer framework, an adaptive feature attention mechanism and a Dish offset correction module are introduced to construct an Autoformer soil carbon flux prediction model. Specific parameter settings are as follows: In the basic Autoformer framework, the encoder and decoder each have four self-attention layers, each containing eight attention heads. The feedforward neural network output dimension is 128, the encoder input dimension is 7 (corresponding to 7 consecutive days of carbon flux data), and the decoder output dimension is 1 (corresponding to a predicted value at one time step). A future masking mechanism is used to avoid future information leakage. The adaptive feature attention mechanism is embedded in the respective attention layers of the encoder and decoder. The attention weights are calculated using a Softmax function for normalization, and the attention dropout probability is set to 0.1 to enhance the model's generalization ability. The Dish offset correction module is located between the encoder and decoder, with an offset correction coefficient of 0.2. A linear correction algorithm is used to compensate for the offset between the lookback window and the prediction window, ensuring the accuracy of capturing temporal dependencies. The output layer consists of two fully connected layers. The first layer has an input dimension of 128 and an output dimension of 64, and uses the ReLU activation function. The second layer has an input dimension of 64 and an output dimension of 1, and uses the Sigmoid activation function to map the predicted values to the [0,1] interval, which is consistent with the normalization range of the preprocessed data.
[0067] 1.4 Model Training and Validation Using the Autoformer prediction model constructed above, model training, parameter optimization, and performance validation were conducted using a standardized carbon flux time-series dataset. First, 694 time-series samples were stratified into training, validation, and test sets in a 7:2:1 ratio. The training set contained 486 samples (249 paddy soil farmland samples and 237 red soil forest samples), the validation set contained 139 samples (71 paddy soil farmland samples and 68 red soil forest samples), and the test set contained 69 samples (36 paddy soil farmland samples and 33 red soil forest samples), ensuring consistent sample distribution across datasets. Model training employed the Adam optimizer with an initial learning rate of 1e-4. The learning rate was adjusted using cosine annealing (decreasing every 10 epochs with a decay coefficient of 0.9). MSE was used as the loss function, and L2 regularization (regularization coefficient 1e-5) was applied to prevent overfitting. An early stopping strategy was employed, and the model was stopped after 28 epochs, with the optimal model parameters saved. Parameter optimization was performed using a grid search method, iterating through combinations of hyperparameters including the number of self-attention layers, the number of attention heads, the output dimension of the feedforward neural network, the learning rate, and the Dish offset correction coefficient, to determine the optimal hyperparameter combination (4 self-attention layers, 8 attention heads, 128 feedforward output dimensions, 1e-4 learning rate, and 0.2 offset correction coefficient), which minimized the validation set loss (MSE = 0.0021). Model validation used LSTM, Transformer, and the original Autoformer as comparison models, employing RMSE, CC, and MAE as evaluation metrics. The test set validation results showed that the Autoformer model outperformed the comparison models in all evaluation metrics, exhibiting stronger prediction accuracy and generalization ability, and better adapting to the task of soil carbon flux time series prediction.
[0068] 1.5 Soil carbon flux prediction One monitoring point each for paddy soil (cultivated land) and red soil (forest land) in Huzhou City was selected to collect real-time carbon flux data from December 1st to 7th, 2024. After preprocessing, the data were input into a trained Autoformer prediction model (T=7) to predict daily carbon flux values from December 8th to 14th, 2024. The normalized values for paddy soil after preprocessing were 0.21, 0.23, 0.25, 0.24, 0.26, 0.28, and 0.27. After inverse normalization (x_min=1.2, x_max=6.8), the predicted values were 2.54, 2.68, 2.82, 2.75, 2.96, 3.10, and 3.03, respectively. The prediction confidence interval is ±0.03. The pretreated red soil (forest land) normalized values were 0.18, 0.20, 0.19, 0.21, 0.23, 0.22, and 0.24. After inverse normalization (x_min=0.8, x_max=5.3), the predicted values were 1.61, 1.75, 1.68, 1.82, 1.96, 1.89, and 2.03, respectively. The confidence interval is ± Comparing the predicted values with the actual monitoring values from December 8th to 14th, the average deviation of the predicted values for paddy soil was 0.08. The average deviation for red soil prediction was 0.07. The prediction accuracy meets the actual monitoring needs.
[0069] 1.6 Visualization and Log Storage of Prediction Results A web application developed using the Streamlit framework visualizes the results. Line charts display the historical trends of actual and predicted carbon flux from December 1st to 14th, while bar charts compare the daily deviations between predicted and actual values. Statistical tables are generated, including predicted values, actual values, deviations, and confidence intervals. All charts can be saved in PNG format for easy analysis and display. Simultaneously, the system automatically saves a prediction log, covering the prediction time, prediction parameters, carbon flux prediction results from December 8th to 14th, model performance indicators, and monitoring point information. The log is saved in Excel format to the system log repository for a five-year retention period, facilitating future retrieval and traceability.
[0070] Example 2: Specific Implementation of a Soil Carbon Flux Prediction System Based on Autoformer A phased training strategy is adopted to train the model in the system. This embodiment is based on the Streamlit framework to build a lightweight soil carbon flux prediction web application system to implement the soil carbon flux prediction method in Embodiment 1. The system is deployed on a local server and supports multiple users accessing it simultaneously. The specific steps are as follows: 2.1 System Deployment The system is developed using Python, based on Streamlit version 1.28.2, and depends on libraries such as TensorFlow 2.10.0, Pandas 1.5.3, NumPy 1.24.3, and Matplotlib 3.7.1. It is deployed on a local server with an Intel Core i7-12700H CPU, 16GB of memory, and a 512GB hard drive. The operating system is Windows 10 Professional, and it supports 4G / 5G wireless data transmission. The system can be accessed through a browser.
[0071] 2.2 Functional Verification of Each Module 2.2.1 Data Acquisition Module: Connects to the soil carbon flux monitoring device developed for the TDLAS system, set to a monitoring frequency of 24 hours / time, to collect carbon flux data in real time from monitoring points in paddy soil farmland and red soil forest land in Huzhou City. Data is transmitted to the system wirelessly via 4G, and offline data in Excel format can also be imported into the system; when the collected carbon flux value is 10.2... When the sensor exceeds a reasonable range, the system will automatically issue an alert, allowing users to check the sensor status in a timely manner.
[0072] 2.2.2 Data Preprocessing Module: Import the 715 carbon flux data points collected in Example 1, perform batch cleaning, denoising, normalization, and time series calibration processing, with a processing efficiency of 580 data points / minute; the user-defined outlier removal threshold is 3.2σ, the interpolation method is cubic spline interpolation, and the denoising parameters are set to db4 wavelet 3-level decomposition. After processing, a standardized carbon flux time series dataset is output, which can be directly used for model training.
[0073] 2.2.3 Model Building and Training Module: Automatically builds an Autoformer prediction model, integrating an adaptive feature attention mechanism and a Dish offset correction module. Users can manually adjust hyperparameters such as the number of self-attention layers and the learning rate. GPU-accelerated training is initiated, with a training time of 1.2 hours for 100 epochs. The module displays the training set loss and validation set loss change curves in real time. After training, the module automatically calculates model performance metrics and generates a performance comparison report with LSTM, Transformer, and the original Autoformer model. The module supports saving the model in h5 format for direct loading and use later.
[0074] 2.2.4 Carbon Flux Prediction Module: Import real-time carbon flux data from December 1st to 7th, 2024, set the prediction time step to 7 days, and after clicking the "Prediction" button, the system will output the predicted carbon flux values and 95% confidence intervals for December 8th to 14th within 8 seconds, automatically complete the inverse normalization process, and output the actual physical quantity of carbon flux; it supports importing data from 3 monitoring points simultaneously for batch prediction, with a prediction response time of 15 seconds.
[0075] 2.2.5 Results Visualization Module: Automatically generates line charts of carbon flux change trends, bar charts comparing predicted and actual values, and statistical tables of prediction results. Supports chart zooming, panning, and other operations, and can save charts in PNG and PDF formats. It also displays the model's performance indicators such as RMSE, CC, and MAE, making it easy for users to intuitively understand the prediction accuracy.
[0076] 2.2.6 Log Saving Module: Automatically saves detailed logs for each prediction, categorized by "prediction time + monitoring point". Users can query logs by time and monitoring point, and logs can be exported to Excel and TXT formats. Logs are stored locally on the server for a period of 5 years to ensure data traceability.
[0077] 2.2.7 User Interaction Module: Divided into two permissions: ordinary user and administrator. Ordinary users can perform operations such as data viewing, prediction, result viewing, log querying and exporting; administrators can set system parameters (such as monitoring frequency, log retention period), manage data (import, delete, backup), maintain models (update, delete) and manage user permissions; the system supports offline operation mode. After disconnecting from the network, local data processing, model training and prediction operations can be performed normally, and data will be automatically synchronized after the network is restored.
[0078] 2.3 System Performance This system is stable and easy to operate; ordinary users can get started after simple training. Data acquisition is real-time and accurate, data preprocessing is efficient, model training is fast, prediction response is timely, and prediction accuracy meets the needs of soil carbon flux monitoring. Logs are completely saved and have strong traceability. It can realize integrated operation of soil carbon flux prediction, effectively solving the shortcomings of traditional detection methods. It can be widely used in soil carbon flux monitoring scenarios in Huzhou City, providing reliable technical support for soil resource management.
[0079] Example 3: Implementation across multiple soil types and time scales This embodiment expands the soil type coverage and adds time scale types based on Embodiment 1 to verify the generalization ability and adaptability of the method of the present invention.
[0080] 3.1 Sample Data Collection The soil carbon flux monitoring device developed in Step 1 using the TDLAS system employs tunable semiconductor laser absorption spectroscopy technology. Designed as a three-channel structure, it features a foldable baffle at the bottom to conform to the ground, a uniformly perforated plate (2.5mm aperture, 2mm edge spacing) at the top, and six data acquisition sensors and a vertically moving multiple reflection cell (White cell structure) in the middle. Gas diffuses vertically through three open gas chambers, enabling data acquisition at different gradients and avoiding data homogenization. This device can achieve real-time, non-destructive monitoring of soil carbon flux, with an adaptively adjustable monitoring frequency and a monitoring range covering 0-10. The monitoring accuracy is no less than ±0.01. .
[0081] 3.2 Data Preprocessing Following the preprocessing workflow of Example 1, the preprocessing parameters were optimized to suit the characteristics of data from multiple soil types and time scales: Outliers were removed using the Laida criterion (3.3σ), with thresholds set for different soil types, resulting in the removal of 47 outlier data points. For the 23 missing data points, cubic spline interpolation was used to impute data continuity, retaining 1086 valid data points after deduplication (423 from paddy soil, 387 from red soil, and 276 from alluvial soil). Data denoising still employed db4 wavelet 3-level decomposition, with an additional high-frequency component threshold of 0.05 set for hourly data to further remove high-frequency noise and preserve the true signal trend. Data normalization used the Min-Max method, processing the data separately for the three soil types, recording x_min and x_max for each type of data for subsequent inverse normalization. The time series reconstruction sets two time scales: hourly short-term prediction with T=24 and daily medium-term prediction with T=30. Time series samples containing input features and labels are constructed, and finally a standardized carbon flux time series dataset containing 1028 time series samples is formed.
[0082] 3.3 Autoformer Prediction Model Optimization Based on the model in Example 1, the model parameters were optimized to improve the model's generalization ability, taking into account the prediction needs of multiple soil types and multiple time scales. 3.3.1 Basic Autoformer framework: The number of self-attention layers in the encoder and decoder is adjusted to 3-5 layers (3 layers for hourly and 5 layers for daily), the number of attention heads is 8, and the output dimension of the feedforward neural network is adjusted according to the time scale (64 for hourly and 128 for daily); the encoder input dimension corresponds to the T value, the decoder output dimension is 1, and the masking mechanism uses the future mask.
[0083] 3.3.2 Adaptive Feature Attention Mechanism: The attention weight calculation logic is optimized, and a channel adaptive adjustment module is added. Attention resources are automatically allocated according to the carbon flux fluctuation characteristics of different soil types. The attention dropout probability is adjusted to 0.15 to further enhance the model's adaptability to different soil type features.
[0084] 3.3.3 Dish Misalignment Correction Module: The misalignment correction coefficient is adaptively adjusted according to the time scale, with 0.15 for hourly predictions and 0.25 for daily predictions. A nonlinear correction algorithm is used to compensate for the misalignment difference between the lookback window and the prediction window at different time scales, improving the long-term capture accuracy. The Dish misalignment correction module of this invention uses a linear correction algorithm by default, which is clear in principle and computationally efficient. To address the distribution shift problem of soil carbon flux sequences between the lookback window and the prediction window, a Dish misalignment correction paradigm is introduced. This module models the distribution of the input historical window and the output prediction window using BACKCONET and HORICONET, respectively, and implements adaptive normalization and denormalization during model training and prediction to improve the model's robustness to distribution changes.
[0085] 3.3.4 Output layer: Adjust the dimensions of the fully connected layer. For hourly prediction, the first layer output dimension is 32 and the second layer output dimension is 1. For daily prediction, the parameters of Example 1 are used. The activation function is still Sigmoid to ensure that the predicted value is mapped to the [0,1] interval.
[0086] 3.4 Model Training and Validation The time-series samples were stratified and divided into a training set of 720 samples, a validation set of 206 samples, and a test set of 102 samples using a 7:2:1 ratio to ensure uniform distribution of samples across different soil types and time scales. The model was trained using the Adam optimizer with an initial learning rate of 1e-4. A cosine annealing strategy was employed, decreasing the learning rate by 0.9 every 8 epochs. The loss function used was MSE combined with L2 regularization of 1e-5. An early stopping strategy was implemented, stopping training if the validation set loss did not decrease for 12 consecutive epochs. Training terminated after 32 epochs, at which point the validation set loss was minimized, with an MSE of 0.0018. LSTM, Transformer, and the original Autoformer were selected as comparison models, and model performance was validated on the test set. The results are shown in the table below. Table 1. Performance Comparison of Models with Multiple Soil Types and Time Scales As shown in Table 1, the Autoformer model of this invention has significantly lower RMSE and MAE than the comparative model in prediction tasks of two time scales and three soil types, and CC is closer to 1. This indicates that the model can not only adapt to a single soil type and a single time scale, but also efficiently adapt to the prediction needs of multiple soil types and multiple time scales. Its generalization ability and prediction accuracy are both excellent.
[0087] 3.5 Soil carbon flux prediction and application of results Real-time carbon flux data for three soil types and four land use types were collected from December 1st to December 7th, 2024. After preprocessing, the data were input into the Autoformer models trained at the hourly and daily levels to predict carbon flux values for the next 1-7 time steps. After inverse normalization, the predicted carbon flux values were obtained, and a 95% confidence interval was output to ensure the reliability of the prediction results.
[0088] Application of prediction results: Compare the predicted values with the actual monitored values, with the deviation controlled within ±0.09. Within this scope, it can be used for scenarios such as dynamic monitoring of soil carbon flux, adjustment of agricultural fertilization, and protection of forest ecosystems, providing accurate data support for soil resource management; at the same time, the prediction process and results are recorded through the log saving module, providing a basis for subsequent model optimization and data traceability.
[0089] Table 2 Comparison Experiments Between Different Models According to the comparative experimental results in Table 2, the proposed model significantly outperforms existing classic models in terms of accuracy, recall, and F1 score. Specifically, the proposed model achieves an accuracy of 93.5%, significantly higher than all other models, especially compared to ResNet (88.2%) and VGG (85.6%), representing an improvement of at least 5%. In terms of recall, the proposed model achieves 92.1%, also surpassing all classic models, indicating higher sensitivity in identifying outliers and small sample classes. Furthermore, the proposed model's F1 score of 92.8% also exceeds other models, particularly demonstrating superior performance in balancing accuracy and recall. Figure 5 For visual representation.
[0090] Table 3 Experimental results of different models The experimental results demonstrate the significance of this model as an optimized solution for predicting carbon dioxide flux in soil respiration. It improves the predictive performance of the baseline model with a relatively low parameter increase cost, reduces the high computational cost of the original model, and its strong overall performance makes it an ideal choice for predicting soil respiration.
[0091] Example 4: Abnormal Situation Handling and System Fault Tolerance Verification This embodiment verifies the fault tolerance of the method and system of the present invention in the context of possible abnormal situations in practical applications (excessive data loss, sensor failure, network interruption).
[0092] 4.1 Setting up abnormal scenarios (1) Scenario 1: Too much data is missing. 100 time series samples from Example 3 are selected and 30% of the data is artificially set to be missing (far exceeding the normal missing ratio) to simulate the scenario of interruption of sensor data acquisition. (2) Scenario 2: Sensor failure, the simulated data is always a fixed value (such as 0 or 10). A total of 50 fault samples were set up; (3) Scenario 3: Network interruption, simulate offline mode, rely only on local cached data for prediction, and set the cached data to the time series data of the most recent 30 time steps.
[0093] 4.2 Fault Tolerance Handling Strategy (1) For scenarios with too much missing data: optimize the interpolation method, use cubic spline interpolation combined with mean imputation, first use mean imputation to initially fill in the missing data, and then use cubic spline interpolation to fit the trend to improve the imputation accuracy; (2) For sensor failure scenarios: A fault identification unit is added in the data preprocessing stage. When the data is detected to be a fixed value and exceeds the reasonable fluctuation range, it is automatically marked as fault data and replaced with the historical average of the same type of soil and the same time scale. At the same time, a fault reminder is issued. (3) For network interruption scenarios: Relying on the system's offline operation mode, the standardized dataset and trained model cached locally are called to carry out prediction operations normally. After the network is restored, the data and logs are automatically synchronized.
[0094] 4.3 Fault Tolerance Verification Results In the three abnormal scenarios mentioned above, although the prediction performance of the Autoformer model decreased slightly, it still maintained high accuracy: the RMSE of scenario 1 was 0.156 and the CC was 0.971; the RMSE of scenario 2 was 0.162 and the CC was 0.968; and the RMSE of scenario 3 was 0.134 and the CC was 0.978, all of which met the actual monitoring requirements.
[0095] Comparative analysis: Compared with existing models, the performance degradation of the model of this invention in abnormal scenarios is controlled within 10%, while the performance degradation of LSTM and the original Autoformer model both exceed 15%, indicating that the method and system of this invention have strong fault tolerance and are suitable for complex real-world application scenarios.
[0096] Summary table of core data for each embodiment and comparative example Based on the experimental results of the above embodiments, it can be seen that the present invention, through precise data acquisition, scientific preprocessing procedures, and an optimized Autoformer model, successfully achieves high-precision prediction of soil carbon flux. Furthermore, the system built possesses good practicality and fault tolerance. Embodiment 1 verifies the effectiveness of the basic prediction method, Embodiment 2 realizes the engineering implementation of the method, Embodiment 3 expands the applicability of the method, and Embodiment 4 verifies the stability of the system under complex scenarios. Compared with existing models, the model of the present invention has significant advantages in prediction accuracy, generalization ability, and fault tolerance, and can effectively provide intelligent technical support for soil carbon flux monitoring and soil resource management in Huzhou City.
[0097] refer to Figure 6 As shown, the present invention also provides a soil carbon flux prediction device. This device includes a data acquisition module 601 for acquiring soil carbon flux monitoring data of a target area, wherein the soil carbon flux monitoring data constitutes a continuous time series. A preprocessing module 602 is used to preprocess the soil carbon flux monitoring data to obtain a standardized time series dataset. A prediction processing module 603 is used to process the standardized time series dataset using a time series prediction model to output predicted carbon flux values for future time steps. The time series prediction model, in its encoding / decoding architecture, performs feature enhancement processing and distribution offset correction processing on the input sequence.
[0098] Furthermore, the prediction processing module includes an encoding unit for encoding the input sequence to obtain a temporal feature representation, and performing the feature enhancement processing during the encoding process. An offset correction unit is used to perform the distribution offset correction processing on the temporal feature representation to obtain a corrected temporal feature representation. A decoding unit is used to decode the corrected temporal feature representation and output the predicted carbon flux value.
[0099] Figure 7 A schematic diagram of the structure of a computer device provided in one embodiment of this application is shown, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the functions of a computer system for predicting soil carbon flux in any of the above embodiments.
[0100] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a computer, causes the computer to perform the functions of a computer system for a soil carbon flux prediction method according to any of the above embodiments.
[0101] It is understood that the specific examples in this application are only intended to help those skilled in the art better understand the implementation methods of this application, and are not intended to limit the scope of the invention.
[0102] It is understood that in the various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not limit the implementation process of the embodiments of this application in any way.
[0103] It is understood that the various implementation methods described in this application can be implemented individually or in combination, and the implementation methods in this application are not limited in this respect.
[0104] Unless otherwise stated, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The term "and / or" as used in this application includes any and all combinations of one or more of the associated listed items. The singular forms "a," "the," and "the" as used in the embodiments of this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0105] It is understood that the processor in the embodiments of this application can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method embodiments can be completed by the integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory; the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0106] It is understood that the memory in the embodiments of this application may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Specifically, non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may be random access memory (RAM). It should be noted that the memory in the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0107] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0108] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the aforementioned method implementations, and will not be repeated here.
[0109] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0110] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0111] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0112] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0113] The above are merely specific embodiments of this application, but the scope of protection of this invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this invention should be determined by the scope of the claims.
Claims
1. A method of predicting soil carbon flux, characterized by, include: Acquire soil carbon flux monitoring data for the target area, wherein the soil carbon flux monitoring data constitutes a continuous time series; The soil carbon flux monitoring data were preprocessed to obtain a standardized time-series dataset; The standardized time-series dataset is processed using a time-series prediction model to output carbon flux predictions for future time steps; wherein, in the encoding-decoding architecture, the time-series prediction model performs feature enhancement processing and distribution offset correction processing on the input sequence.
2. The method according to claim 1, characterized in that, The preprocessing includes at least one of outlier removal, missing value imputation, noise suppression, and normalization.
3. The method according to claim 2, characterized in that, The outlier removal is based on a criterion of statistical distribution, and the missing value imputation is based on an interpolation method of temporal continuity.
4. The method according to claim 1, characterized in that, The temporal prediction model is an autoregressive prediction model that includes an encoder and a decoder; the feature enhancement processing is applied within the encoder and / or decoder to enhance the model's ability to extract multi-dimensional temporal features; the distribution offset correction processing is applied between the encoder and the decoder to correct the feature distribution offset between the lookback window and the prediction window.
5. The method according to claim 4, characterized in that, The feature enhancement process includes: performing temporal decomposition on the input sequence to obtain trend components and seasonal components; generating adaptive parameters based on the interaction between the trend components and the seasonal components; and adaptively fusing the temporal feature representation of the input sequence using the adaptive parameters.
6. The method according to claim 5, characterized in that, The temporal decomposition of the input sequence employs Fourier decomposition; the adaptive fusion of the temporal feature representation of the input sequence using the adaptive parameters includes channel-dimensional aggregation of the fused temporal feature representation through one-dimensional convolution.
7. The method according to claim 4, characterized in that, The distribution offset correction process includes: calculating the distribution offset based on the temporal feature representation of the lookback window and the temporal feature representation of the prediction window; and correcting the temporal feature representation of the temporal prediction model in the decoding stage according to the distribution offset.
8. The method according to claim 7, characterized in that, The calculation of the distribution offset based on the temporal feature representation of the retrospective window and the temporal feature representation of the prediction window includes: learning a first distribution parameter of the temporal feature representation of the retrospective window through a first neural network; learning a second distribution parameter of the temporal feature representation of the prediction window through a second neural network; and determining the distribution offset based on the first distribution parameter and the second distribution parameter.
9. The method according to claim 1, characterized in that, It also includes the step of training the time series prediction model, which includes: adopting a phased training strategy and introducing regularization terms and early stopping strategies during the training process; Alternatively, after outputting the carbon flux prediction value for future time steps, the method further includes: performing inverse normalization on the carbon flux prediction value to obtain the prediction result in true dimensions; and / or generating a visualization chart of the prediction result. Alternatively, the method can be applied to fields such as agricultural soil management, ecosystem carbon cycle assessment, or climate change research.
10. A soil carbon flux prediction device, characterized in that, include: The data acquisition module is used to acquire soil carbon flux monitoring data of the target area, wherein the soil carbon flux monitoring data constitutes a continuous time series. The preprocessing module is used to preprocess the soil carbon flux monitoring data to obtain a standardized time-series dataset; The prediction processing module is used to process the standardized time series dataset using a time series prediction model to output carbon flux prediction values for future time steps; wherein, the time series prediction model performs feature enhancement processing and distribution offset correction processing on the input sequence in the encoding and decoding architecture.