A Spatial Intelligent Watershed Hydrological and Water Quality Multivariate Prediction Method Based on Quaternions Time-Frequency Multiscale

By using a quaternion-based time-frequency multi-scale method, the problem of fusion and feature extraction of hydrological and water quality data from multi-source heterogeneous watersheds was solved, achieving high-precision multivariate hydrological and water quality prediction, improving the model's spatiotemporal coupling perception and generalization capabilities, and supporting intelligent decision-making in watershed management.

CN120822194BActive Publication Date: 2025-12-02HOHAI UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511334431.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-18
Publication Date
2025-12-02
Estimated Expiration
2045-09-18

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively integrate multi-source heterogeneous watershed hydrological and water quality data, resulting in severe missing values ​​and high noise levels. This makes it difficult to measure cross-variable and cross-site correlations, and the predictive models lack sufficient spatiotemporal coupling perception and generalization capabilities, making it difficult to meet the accurate prediction needs of complex watershed multivariable hydrological and water quality elements.

Method used

A spatial intelligent watershed hydrological and water quality multivariate prediction method based on quaternions at multiple time and frequency scales is adopted. By acquiring spatiotemporally heterogeneous watershed hydrological and water quality data, missing value repair and feature extraction are performed. Attention weights are calculated using quaternion domain mapping and Hamiltonian product, and multivariate prediction is performed in combination with quaternion Transformer decoder.

Benefits of technology

It enables multi-source data fusion and correlation calculation in a unified four-dimensional space, improves the ability to capture short- and long-term dynamics and spatial generalization performance, enhances the accuracy and stability of multivariate hydrological and water quality prediction, and supports intelligent decision-making for water resource scheduling and watershed management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120822194B_ABST
    Figure CN120822194B_ABST
Patent Text Reader

Abstract

This invention discloses a spatial intelligent watershed hydrological and water quality multivariate prediction method based on quaternions at multiple time and frequency scales. The method includes: acquiring spatiotemporally heterogeneous watershed hydrological and water quality data to characterize the spatiotemporal coupling features within the watershed and across monitoring stations; repairing missing values ​​in the hydrological and water quality data; constructing a time-domain-frequency-domain composite feature tensor; mapping the constructed time-domain-frequency-domain composite feature tensor sequentially to the real and three imaginary parts of a quaternion to generate a coupled quaternion feature representation; aggregating the multi-head outputs through a quaternion fusion layer to obtain a high-dimensional coupled feature representation; inputting the high-dimensional coupled features into a quaternion Transformer decoder, and after nonlinear mapping and channel-by-channel regression processing, outputting the predicted hydrological and water quality multivariate values ​​for future time periods. This method can be quickly migrated to new watersheds or monitoring stations while maintaining high-precision output, providing a reliable and scalable intelligent decision-making basis for real-time water resource scheduling, pollution load control, and ecological flow assurance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of watershed modeling technology, specifically relating to a spatial intelligent watershed hydrological and water quality multivariate prediction method based on quaternions at multiple time and frequency scales. Background Technology

[0002] With the continued intensification of climate change and the escalating intensity of human activities, the coupled hydrological and water quality processes in watersheds exhibit highly nonlinear, strong stochastic, and significant spatiotemporal heterogeneity. Accurate prediction of multiple key factors such as dissolved oxygen, ammonia nitrogen, pH, flow rate, and rainfall is fundamental for flood risk prevention and control, optimal water resource allocation, ecological restoration, and pollution control decisions, and is also a crucial technical link in achieving smart watershed management. Existing prediction methods are mainly divided into two categories: physical mechanism models and statistical models. Physical mechanism models offer interpretability in describing water cycle and pollution transport mechanisms, but rely on a large number of difficult-to-obtain and time-limited parameters, making model calibration difficult and extrapolation stability insufficient. Statistical models, while computationally efficient, are based on the assumption of linear stationarity, making it difficult to capture complex nonlinear dynamics, thus hindering the accuracy of predictions to meet the needs of refined management.

[0003] In recent years, deep learning has been widely applied to hydrological and water quality prediction due to its superior data fitting and feature representation capabilities. Recurrent neural networks, long short-term memory networks, and one-dimensional convolutional networks can extract short-term dependency information from time series, but they are still insufficient in processing long-period signals such as seasonal and interannual signals, modeling cross-site spatial correlations, and dealing with missing data and noise. The emergence of self-attention mechanisms has provided a new approach to long-distance dependency modeling. However, traditional real-space Transformers require separate weighting for each feature when dealing with multi-source, multi-variable, and different resolution data, resulting in a sharp increase in parameter size. Furthermore, the attention distribution is easily affected by variable scaling and rotation transformations, leading to a decrease in model robustness.

[0004] To address the unified representation and correlation measurement of multi-source heterogeneous data, researchers have attempted to introduce techniques such as meta-learning, graph neural networks, and multi-task learning to improve the spatial generalization and rapid adaptation capabilities of models. However, the coupling of multiple techniques often increases system complexity and computational cost. Quaternion representation can compactly encode vector groups in four-dimensional space, naturally possessing rotation invariance and scale consistency, and can maintain the integrity of cross-variable and cross-site information while reducing the number of parameters. However, quaternions have not yet been deeply integrated with Transformers for application in the field of multivariate prediction of hydrology and water quality.

[0005] Therefore, there is an urgent need for a prediction framework that can perform multi-source data fusion, missing data repair, and correlation calculation in a unified four-dimensional space, and has both long-term and short-term dynamic capture capabilities and high spatial generalization performance, so as to improve the accuracy and stability of prediction of multivariate hydrological and water quality elements in complex watersheds and provide reliable intelligent decision support for water resource scheduling and watershed management. Summary of the Invention

[0006] To address the shortcomings of the existing technologies, the present invention aims to provide a spatial intelligent watershed hydrological and water quality multivariate prediction method based on quaternions at multiple time and frequency scales. This method solves the problems in the existing technologies, such as heterogeneous, missing, and noisy watershed hydrological and water quality data, which makes it difficult to effectively integrate and extract features, difficulties in measuring cross-variable and cross-site correlations, and insufficient spatiotemporal coupling perception and generalization capabilities of the prediction model.

[0007] To achieve the above objectives, the technical solution adopted by the present invention is as follows:

[0008] The present invention discloses a spatial intelligent watershed hydrological and water quality multivariate prediction method based on quaternions at multiple time and frequency scales, comprising the following steps:

[0009] S1: Acquire spatiotemporally heterogeneous watershed hydrological and water quality data, including hydrological and water quality observation data, meteorological driving data, and watershed attribute data, to characterize the spatiotemporal coupling characteristics within the watershed and across stations;

[0010] S2: Missing values ​​are repaired in the acquired spatiotemporally heterogeneous watershed hydrological and water quality data; statistical features, temporal patterns, and spatial correlation information are extracted from the original sequence and the repaired sequence to obtain fusion features; and the fusion features are divided into training set, validation set, and test set according to the proportion.

[0011] S3: The seasonal trend decomposition method based on local weighted regression is used to decompose the seasonal term, trend term, and residuals of the spatiotemporally heterogeneous watershed hydrological and water quality data. The seasonal and trend components are reconstructed and the high-frequency residuals are retained. A time-domain-frequency domain composite feature tensor is constructed to integrate multi-scale dynamic information.

[0012] S4: Perform quaternion domain mapping on the time-frequency domain composite feature tensor, mapping the time-frequency domain composite feature tensor constructed in step S3 to the real part and three imaginary parts of the quaternion in turn to generate coupled quaternion feature representations.

[0013] S5: The attention weights are computed in parallel using Hamiltonian product, and the multi-head outputs are aggregated through a quaternion fusion layer to obtain a high-dimensional coupled feature representation;

[0014] S6: Input the high-dimensional coupled features obtained in step S5 into the quaternion Transformer decoder. After nonlinear mapping and channel-by-channel regression processing, output the multivariate predicted values ​​of hydrology and water quality for future periods.

[0015] Furthermore, the data obtained in step S1 includes:

[0016] Hydrological and water quality observation data includes latitude and longitude information of observation stations in multiple different watersheds and time series data with specific time intervals. The hydrological and water quality observation data includes dissolved oxygen, pH, total phosphorus, total nitrogen, chemical oxygen demand and permanganate index.

[0017] Meteorological driving data, including precipitation, temperature and snow water equivalent;

[0018] Watershed attribute data, including slope, soil texture, and land cover type.

[0019] Further, step S2 specifically includes:

[0020] S21: Based on the Grubbs test, analyze the sequence of each variable in the acquired spatiotemporally heterogeneous watershed hydrological and water quality data. The detection and removal of outliers are performed as follows:

[0021] Calculate the mean of a series of variables. and standard deviation ,as follows:

[0022] ;

[0023] ;

[0024] in, The length of the time series. For the first The variable values ​​at each point in time;

[0025] Detect variable values Determine if it is an outlier and define the statistic. ,as follows:

[0026] ;

[0027] Calculation based on time series length With a given significance level Grubbs test critical value ,as follows:

[0028] ;

[0029] in, For degrees of freedom, The probability of being on the upper side is Students's Distribution quantiles; if Then determine This is an outlier;

[0030] S22: A Kalman filter-based mean shift and data interpolation method is used to repair outliers in the hydrological and water quality data of each spatiotemporally heterogeneous watershed. Statistical features, temporal patterns, and spatial correlation information are obtained by fusing the sequences before and after repair, thus yielding the fused features. The original time series is set as follows: The repaired time series is Both are related to the system state vector. Observations; define the state transition matrix of the system model parameters. as follows:

[0031] ;

[0032] in, The sequence sampling time interval, and the process noise covariance matrix. as follows:

[0033] ;

[0034] in, , These represent the variances of the increments of the original sequence and the repaired sequence at adjacent time points, respectively. The covariance of the incremental sequence; the observation noise covariance matrix. as follows:

[0035] ;

[0036] in, The variance of the difference between observations at adjacent time points in the sequence; the dynamic model of the system state at the next time step. and observation model for:

[0037] ;

[0038] ;

[0039] in, This is a dynamic model of the system state at the current moment. This indicates that the mean is zero and the covariance is... Process noise; This indicates that the mean is zero and the covariance is... Observation noise, This indicates that the mean is zero and the covariance is... Observation noise; , Given the observation matrix, apply Kalman filtering to each time series to obtain local state estimates. , and the corresponding error covariance matrix , The global state estimate is obtained by fusing local state estimates. and its error covariance matrix The expression is as follows:

[0040] ;

[0041] ;

[0042] in, , Let be the weighting coefficient, satisfying The weights for each time step are calculated by summing the diagonal elements of the error covariance matrix of the original hydrological and water quality observation data and the reconstructed hydrological and water quality observation data. The time series of hydrological and water quality observation data after restoration was obtained. The expression is as follows:

[0043] ;

[0044] in, The system's observation matrix;

[0045] Time series of hydrological and water quality observation data after restoration The training set, validation set, and test set are divided into three groups in a certain proportion.

[0046] Furthermore, in step S22, the repaired hydrological and water quality observation data time series is... Meteorological driving data and watershed attribute data are aligned by time nodes and divided into training set, validation set and test set in a ratio of 7:2:1.

[0047] Furthermore, step S3 specifically includes:

[0048] A seasonal trend decomposition algorithm based on local weighted regression is used to analyze time series data. The seasonal-trend decomposition is expressed as follows:

[0049] ;

[0050] Among them, seasonal components Trend components and remainder The weighted moving averages are calculated separately, and the calculation expressions are as follows:

[0051] ;

[0052] ;

[0053] in, For hydrological and water quality observation data series at time The observed values, and These are the moving average window lengths for the seasonal and trend components, respectively. The length of the seasonal cycle, The offset of the trend window relative to the seasonal series, weighted by the coefficient. , Acting on the One window point;

[0054] Seasonal Quantities Perform a Fast Fourier Transform and retain only the Top-valued data with a cumulative contribution rate ≥ 90%. frequency and its phase This yields a composite feature tensor composed of time and frequency domains, which integrates multi-scale dynamic information.

[0055] Furthermore, step S4 specifically includes:

[0056] S41: Combine the amplitude-frequency-phase triplet The encoding is a real quaternion, as follows:

[0057] ;

[0058] in, This represents the amplitude (real part) of the signal. This represents the retained frequency component (the first imaginary part). = This represents the phase of the frequency component (the second imaginary part). Used to complete the four-dimensional structure of quaternions; Let the imaginary part of the quaternion be a unit that satisfies ;

[0059] S42: Define quaternion conjugation norm The unit quaternion satisfies ;

[0060] S43: Directing the observed frequency direction using quaternion exponentiation. With phase rotation angle Mapping to a 4-dimensional hypercomplex space enables a unified representation of 3D rotation and amplitude information; the quaternion exponential form expression is as follows:

[0061] .

[0062] Further, step S5 specifically includes:

[0063] S51: For any query-key quaternion and The Hamiltonian product is used to calculate its quaternion product, as shown in the following formula:

[0064] ;

[0065] in, To query quaternions The real part of the vector is used to query the scalar features of the vector; Key Quaternion The real part of the key vector is used to carry the scalar features of the key vector. , With their respective imaginary vectors and This constitutes a complete quaternion. Used for rotation-invariant similarity scoring;

[0066] S52: at each significant frequency The mapping is constructed above, and the expression is as follows:

[0067] ;

[0068] ;

[0069] in, and This is the normalized position index. This refers to the position information of the corresponding sequence. and These respectively represent the queries. s and keys Frequency via unit quaternion rotation encoding The representation in the subspace is used to capture cross-frequency similarity with rotation invariance;

[0070] Calculate single-head attention weights The expression is as follows:

[0071] ;

[0072] in, Quaternion embedding matrices for query, key, and value, respectively. For the set of significant frequencies to be retained, For each attention head dimension, * denotes complex conjugation. The rotation-invariant real part similarity between the query and key at each frequency is calculated using a quaternion exponential mapping, and then normalized by Softmax before being compared with... Multiplying them together yields a single-headed attention output;

[0073] S53: Settings Each of the four subspace attention heads outputs... Each attention head By concatenating along the feature dimension, we obtain:

[0074] ;

[0075] The final output is generated through a linear mapping:

[0076] ;

[0077] in, Each attention point outputs its own... Concatenate the columns to form a dimension. The matrix, and then the linear mapping matrix Projection back Dimension, that is, to obtain the final output. This allows us to obtain high-dimensional coupled feature representations.

[0078] Further, step S6 includes:

[0079] The high-dimensional coupling features obtained in step S5 The input is a quaternion Transformer decoder, processed by a nonlinear mapping function. and channel-wise regression function After processing, output the hydrological and water quality observation data. Future period to The multivariate predicted values ​​for hydrological and water quality are expressed as follows:

[0080] ;

[0081] in, Represents hydrological and water quality observation data The coupled feature tensor, Represents a non-linear activation function. This represents a channel-wise linear regression layer; Hydrological and water quality observation data Output At each time step Prediction matrix of hydrological and water quality variables.

[0082] The beneficial effects of this invention are:

[0083] (1) This invention encodes the amplitude, frequency and phase in the quaternion domain as a whole, and maps the information that was originally scattered in the three types of features of time domain, frequency domain and space to a unified four-dimensional space in a unified manner, which fundamentally avoids the information loss caused by splitting and splicing the traditional model first; the quaternion domain mapping of time and frequency domain features can simultaneously focus on long-term changes such as seasonal-interannual changes and short-term abrupt changes such as rainfall-runoff, providing the network with a complete cross-scale context; rotation invariance also enables the same physical process to have a consistent representation under different stations and different dimensions, thereby achieving stable modeling of long sequence dependencies without adding extra parameters.

[0084] (2) In this invention, Hamilton product similarity score can be calculated by taking only the real part of the quaternion, and is not affected by scale drift caused by the topographic elevation difference of each observation station or sensor calibration convention. At the same time, the three imaginary parts of the quaternion naturally encode the phase angle coupling relationship between multiple variables, which can capture complex physical mechanisms such as hydrological and water quality-meteorological linkage, upstream-downstream transmission and surface-ground recharge, accurately capture complex hydrological and water quality-water quantity coupling relationship within the basin, promote the improvement of multivariate collaborative prediction accuracy, and effectively support flood warning and hydrological and water quality compliance assessment.

[0085] (3) The multi-model missing data repair based on spatiotemporal interpolation and statistical learning in this invention performs adaptive weighting on the original-repaired dual sequences, which can make full use of cross-variable redundant information to suppress noise and fill missing data, significantly reducing the adverse effects of data anomalies on prediction results.

[0086] (4) In this invention, quaternion encoding compresses four channels of information into a single supercomplex vector. Combined with a multi-head parallel mechanism, it is easy to deploy at the field end of a watershed with limited resources. The method of this invention can be quickly migrated to a new watershed or monitoring station and maintain high-precision output, providing a reliable and scalable intelligent decision-making basis for real-time water resource scheduling, pollution load control and ecological flow guarantee. Attached Figure Description

[0087] Figure 1 This is a flowchart of the method of the present invention;

[0088] Figure 2 This is a scatter plot showing the simulated and observed dissolved oxygen values ​​for the watershed in this invention.

[0089] Figure 3 This is a time series diagram showing the simulation effect of dissolved oxygen in the watershed and the comparison model of the present invention. Detailed Implementation

[0090] To facilitate understanding by those skilled in the art, the present invention will be further described below with reference to embodiments and accompanying drawings. The content mentioned in the embodiments is not intended to limit the present invention.

[0091] Reference Figure 1 As shown, the present invention provides a spatial intelligent watershed hydrological and water quality multivariate prediction method based on quaternions at multiple time and frequency scales, comprising the following steps:

[0092] S1: Acquire spatiotemporally heterogeneous watershed hydrological and water quality data, including hydrological and water quality observation data, meteorological driving data, and watershed attribute data, to characterize the spatiotemporal coupling characteristics within the watershed and across stations;

[0093] The data obtained in step S1 includes:

[0094] Hydrological and water quality observation data includes latitude and longitude information of observation stations in multiple different watersheds and time series data with specific time intervals. The hydrological and water quality observation data includes dissolved oxygen (DO), pH, total phosphorus, total nitrogen, chemical oxygen demand and permanganate index.

[0095] Meteorological driving data, including precipitation, temperature and snow water equivalent;

[0096] Watershed attribute data, including slope, soil texture, and land cover type.

[0097] S2: Missing values ​​are repaired in the acquired spatiotemporally heterogeneous watershed hydrological and water quality data; statistical features, temporal patterns, and spatial correlation information are extracted from the original sequence and the repaired sequence to obtain fusion features; and the fusion features are divided into training set, validation set, and test set according to the proportion.

[0098] Specifically, step S2 includes:

[0099] S21: Based on the Grubbs test, analyze the sequence of each variable in the acquired spatiotemporally heterogeneous watershed hydrological and water quality data. The detection and removal of outliers are performed as follows:

[0100] Calculate the mean of a series of variables. and standard deviation ,as follows:

[0101] ;

[0102] ;

[0103] in, The length of the time series. For the first The variable values ​​at each point in time;

[0104] Detect variable values Determine if it is an outlier and define the statistic. ,as follows:

[0105] ;

[0106] Calculation based on time series length With a given significance level Grubbs test critical value ,as follows:

[0107] ;

[0108] in, For degrees of freedom, The probability of being on the upper side is Students's Distribution quantiles; if Then determine This is an outlier;

[0109] S22: A Kalman filter-based mean shift and data interpolation method is used to repair outliers in the hydrological and water quality data of each spatiotemporally heterogeneous watershed. Statistical features, temporal patterns, and spatial correlation information are obtained by fusing the sequences before and after repair, thus yielding the fused features. The original time series is set as follows: The repaired time series is Both are related to the system state vector. Observations; define the state transition matrix of the system model parameters. as follows:

[0110] ;

[0111] in, The sequence sampling time interval, and the process noise covariance matrix. as follows:

[0112] ;

[0113] in, , These represent the variances of the increments of the original sequence and the repaired sequence at adjacent time points, respectively. The covariance of the incremental sequence; the observation noise covariance matrix. as follows:

[0114] ;

[0115] in, The variance of the difference between observations at adjacent time points in the sequence; the dynamic model of the system state at the next time step. and observation model for:

[0116] ;

[0117] ;

[0118] in, This is a dynamic model of the system state at the current moment. This indicates that the mean is zero and the covariance is... Process noise; This indicates that the mean is zero and the covariance is... Observation noise, This indicates that the mean is zero and the covariance is... Observation noise; , Given the observation matrix, apply Kalman filtering to each time series to obtain local state estimates. , and the corresponding error covariance matrix , The global state estimate is obtained by fusing local state estimates. and its error covariance matrix The expression is as follows:

[0119] ;

[0120] ;

[0121] in, , Let be the weighting coefficient, satisfying The weights for each time step are calculated by summing the diagonal elements of the error covariance matrix of the original hydrological and water quality observation data and the reconstructed hydrological and water quality observation data. The time series of hydrological and water quality observation data after restoration was obtained. The expression is as follows:

[0122] ;

[0123] in, This is the system's observation matrix.

[0124] Time series of hydrological and water quality observation data after restoration The training set, validation set, and test set are divided into three groups in a certain proportion.

[0125] Specifically, in step S22, the time series of the repaired hydrological and water quality observation data is... Meteorological driving data and watershed attribute data are aligned by time nodes and divided into training set, validation set and test set in a ratio of 7:2:1.

[0126] S3: The seasonal trend decomposition method based on local weighted regression is used to decompose the seasonal term, trend term, and residuals of the spatiotemporally heterogeneous watershed hydrological and water quality data. The seasonal and trend components are reconstructed and the high-frequency residuals are retained. A time-domain-frequency domain composite feature tensor is constructed to integrate multi-scale dynamic information.

[0127] Specifically, step S3 includes:

[0128] A seasonal trend decomposition algorithm based on local weighted regression is used to analyze time series data. The seasonal-trend decomposition is expressed as follows:

[0129] ;

[0130] Among them, seasonal components Trend components and remainder The weighted moving averages are calculated separately, and the calculation expressions are as follows:

[0131] ;

[0132] ;

[0133] in, For hydrological and water quality observation data series at time The observed values, and These are the moving average window lengths for the seasonal and trend components, respectively. The length of the seasonal cycle, The offset of the trend window relative to the seasonal series, weighted by the coefficient. , Acting on the One window point;

[0134] Seasonal Quantities Perform a Fast Fourier Transform and retain only the Top-valued data with a cumulative contribution rate ≥ 90%. frequency and its phase This yields a composite feature tensor composed of time and frequency domains, which integrates multi-scale dynamic information.

[0135] S4: Perform quaternion domain mapping on the time-frequency domain composite feature tensor, mapping the time-frequency domain composite feature tensor constructed in step S3 to the real part and three imaginary parts of the quaternion in turn to generate coupled quaternion feature representations.

[0136] Specifically, step S4 includes:

[0137] S41: Combine the amplitude-frequency-phase tripartite group The encoding is a real quaternion, as follows:

[0138] ;

[0139] in, This represents the amplitude (real part) of the signal. This represents the retained frequency component (the first imaginary part). = This represents the phase of the frequency component (the second imaginary part). Used to complete the four-dimensional structure of quaternions; Let the imaginary part of the quaternion be a unit that satisfies ;

[0140] S42: Define quaternion conjugation norm The unit quaternion satisfies ;

[0141] S43: Directing the observed frequency direction using quaternion exponentiation. With phase rotation angle Mapping to a 4-dimensional hypercomplex space enables a unified representation of 3D rotation and amplitude information; the quaternion exponential form expression is as follows:

[0142] .

[0143] S5: The attention weights are computed in parallel using Hamiltonian product, and the multi-head outputs are aggregated through a quaternion fusion layer to obtain a high-dimensional coupled feature representation;

[0144] Specifically, step S5 includes:

[0145] S51: For any query-key quaternion and The Hamiltonian product is used to calculate its quaternion product, as shown in the following formula:

[0146] ;

[0147] in, To query quaternions The real part of the vector is used to query the scalar features of the vector; Key Quaternion The real part of the key vector is used to carry the scalar features of the key vector. , With their respective imaginary vectors and This constitutes a complete quaternion. Used for rotation-invariant similarity scoring;

[0148] S52: at each significant frequency The mapping is constructed above, and the expression is as follows:

[0149] ;

[0150] ;

[0151] in, and This is the normalized position index. This refers to the position information of the corresponding sequence. and These respectively represent the queries. s and keys Frequency via unit quaternion rotation encoding The representation in the subspace is used to capture cross-frequency similarity with rotation invariance;

[0152] Calculate single-head attention weights The expression is as follows:

[0153] ;

[0154] in, Quaternion embedding matrices for query, key, and value, respectively. For the set of significant frequencies to be retained, For each attention head dimension, * denotes complex conjugation. The rotation-invariant real part similarity between the query and key at each frequency is calculated using a quaternion exponential mapping, and then normalized by Softmax before being compared with... Multiplying them together yields a single-headed attention output;

[0155] S53: Settings Each of the four subspace attention heads outputs... Each attention head By concatenating along the feature dimension, we obtain:

[0156] ;

[0157] The final output is generated through a linear mapping:

[0158] ;

[0159] in, Each attention point outputs its own... Concatenate the columns to form a dimension. The matrix, and then the linear mapping matrix Projection back Dimension, that is, to obtain the final output. This allows us to obtain high-dimensional coupled feature representations.

[0160] S6: Input the high-dimensional coupled features obtained in step S5 into the quaternion Transformer decoder. After nonlinear mapping and channel-by-channel regression processing, output the multivariate predicted values ​​of hydrology and water quality for future periods.

[0161] Step S6 includes:

[0162] The high-dimensional coupling features obtained in step S5 The input is a quaternion Transformer decoder, processed by a nonlinear mapping function. and channel-wise regression function After processing, output the hydrological and water quality observation data. Future period to The multivariate predicted values ​​for hydrological and water quality are expressed as follows:

[0163] ;

[0164] in, Represents hydrological and water quality observation data The coupled feature tensor, Represents a non-linear activation function. This represents a channel-wise linear regression layer; Hydrological and water quality observation data Output At each time step Prediction matrix of hydrological and water quality variables;

[0165] The channel-wise regression layer applies a linear mapping to each quaternion channel, losslessly converting the coupled features in the quaternion space into a scalar output while maintaining consistency in predictions across channels; finally, the decoder outputs... The set constitutes the multivariate hydrological and water quality prediction results for future time periods of each monitoring station, which can be directly used for water resource management, early warning, or scheduling decisions.

[0166] Figure 2 This plot shows the comparison of the true and predicted values ​​of the method of the present invention on the test set, as well as the regression fitting results; the horizontal axis represents the true value of the sample, and the vertical axis represents the predicted value of the model; the red hollow circles in the figure represent the true-predicted pairing of each sample point. Figure 2 The solid black line represents the ideal reference line y=x, which is the diagonal position when the predicted value is exactly equal to the true value. If all points fall on this line, the model's prediction is perfect. In contrast, the dashed blue line is the regression line obtained based on the least squares method, which generally reflects the trend of the linear relationship between the prediction and the true value.

[0167] The regression equation in Figure 2 It has been marked as:

[0168] ;

[0169] The coefficient of determination is given. =0.95, a slope of 0.93 indicates that the predicted value changes slightly less than the ideal slope of 1 compared to the actual value. A slope as high as 0.95... The regression line explains approximately 95% of the data variance, indicating a very high overall model fit. The scatter plot shows that most points are distributed near the regression line and symmetrically along both sides of the standard line, suggesting that the model maintains small bias across different true value ranges. However, in areas with low true values ​​(e.g., samples with small true values), predicted values ​​tend to be slightly higher than the true values; in areas with high true values, there is a slight underestimation. Overall, the model effectively captures the overall trend and fluctuation characteristics of the data, meeting the accuracy requirements for predicting most watershed hydrological and water quality variables.

[0170] Figure 3 The graph represents the time-series prediction results of different models on the test set for the monthly changes in dissolved oxygen; the horizontal axis represents time (month), and the vertical axis represents the predicted DO concentration (mg / L).

[0171] Overall, all models were able to capture the seasonal fluctuations of dissolved oxygen (DO) relatively well: DO levels gradually increased at the beginning of the year (January–March), reached a high in late spring and early summer (April–June), then declined significantly from late summer to early autumn (July–September), and recovered somewhat from late autumn to winter (October–December). The predicted curves of different models were basically synchronized with the fluctuations of the observed curves, but there were slight differences in the height of the peaks and the depth of the troughs.

[0172] To more intuitively compare the local fitting errors of each model, Figure 3 The bottom left corner shows a magnified view of a specific interval (approximately the previous 25 days). It can be seen that the proposed method (orange line) almost perfectly matches the observed values ​​in tracking short-term fluctuations. Whether it's a slight upward movement or a brief decline, its phase and amplitude errors are significantly better than the other models. While Autoformer, Pyraformer, FEDformer, and TimeMixer can also follow the general trend, they often exhibit underestimation or lag at multiple inflection points.

[0173] This invention has many specific applications. The above description is only a preferred embodiment of this invention. It should be noted that for those skilled in the art, several improvements can be made without departing from the principle of this invention, and these improvements should also be considered within the scope of protection of this invention.

Claims

1. A spatial intelligent watershed hydrological and water quality multivariate prediction method based on quaternions at multiple time and frequency scales, characterized in that, The steps are as follows: S1: Acquire spatiotemporally heterogeneous watershed hydrological and water quality data, including hydrological and water quality observation data, meteorological driving data, and watershed attribute data, to characterize the spatiotemporal coupling characteristics within the watershed and across stations; S2: Missing values ​​are repaired in the acquired spatiotemporally heterogeneous watershed hydrological and water quality data; statistical features, temporal patterns, and spatial correlation information are extracted from the original sequence and the repaired sequence to obtain fusion features; and the fusion features are divided into training set, validation set, and test set according to the proportion. S3: The seasonal trend decomposition method based on local weighted regression is used to decompose the seasonal term, trend term, and residuals of the spatiotemporally heterogeneous watershed hydrological and water quality data. The seasonal and trend components are reconstructed and the high-frequency residuals are retained. A time-domain-frequency domain composite feature tensor is constructed to integrate multi-scale dynamic information. S4: Perform quaternion domain mapping on the time-frequency domain composite feature tensor, mapping the time-frequency domain composite feature tensor constructed in step S3 to the real part and three imaginary parts of the quaternion in turn to generate coupled quaternion feature representations. S5: The attention weights are computed in parallel using Hamiltonian product, and the multi-head outputs are aggregated through a quaternion fusion layer to obtain a high-dimensional coupled feature representation; S6: Input the high-dimensional coupled features obtained in step S5 into the quaternion Transformer decoder. After nonlinear mapping and channel-by-channel regression processing, output the multivariate predicted values ​​of hydrology and water quality for future periods. Step S3 specifically includes: A seasonal trend decomposition algorithm based on local weighted regression is used to analyze time series data. The seasonal-trend decomposition is expressed as follows: ; Among them, seasonal components Trend components and remainder The weighted moving averages are calculated separately, and the calculation expressions are as follows: ; ; in, For hydrological and water quality observation data series at time The observed values, and These are the moving average window lengths for the seasonal and trend components, respectively. The length of the seasonal cycle, The offset of the trend window relative to the seasonal series, weighted by the coefficient. , Acting on the One window point; Seasonal Quantities Perform a Fast Fourier Transform and retain only the Top-valued data with a cumulative contribution rate ≥ 90%. frequency and its phase This yields a composite feature tensor composed of time and frequency domains, which integrates multi-scale dynamic information. Step S5 specifically includes: S51: For any query-key quaternion and The Hamiltonian product is used to calculate its quaternion product, as shown in the following formula: ; in, To query quaternions The real part of the vector is used to query the scalar features of the vector; Key Quaternion The real part of the key vector is used to carry the scalar features of the key vector. , With their respective imaginary vectors and This constitutes a complete quaternion. Used for rotation-invariant similarity scoring; S52: at each significant frequency The mapping is constructed above, and the expression is as follows: ; ; in, and This is the normalized position index. This refers to the position information of the corresponding sequence. and These respectively represent the queries. s and keys Frequency via unit quaternion rotation encoding The representation in the subspace is used to capture cross-frequency similarity with rotation invariance; Calculate single-head attention weights The expression is as follows: ; in, Quaternion embedding matrices for query, key, and value, respectively. For the set of significant frequencies to be retained, For each dimension of attention head, Representing complex conjugation, the similarity between the query and key at each frequency is calculated using a quaternion exponential mapping, performing rotation-invariant real part similarity calculations, and then normalized by Softmax before being compared with... Multiplying them together yields a single-headed attention output; S53: Settings Each of the four subspace attention heads outputs... Each attention head By concatenating along the feature dimension, we obtain: ; The final output is generated through a linear mapping: ; in, Each attention point outputs its own... Concatenate the columns to form a dimension. The matrix, and then the linear mapping matrix Projection back Dimension, that is, to obtain the final output. This allows us to obtain high-dimensional coupled feature representations.

2. The spatial intelligent watershed hydrological and water quality multivariate prediction method based on quaternions at multiple time and frequency scales as described in claim 1, characterized in that, The data obtained in step S1 includes: Hydrological and water quality observation data includes latitude and longitude information of observation stations in multiple different watersheds and time series data with specific time intervals. The hydrological and water quality observation data includes dissolved oxygen, pH, total phosphorus, total nitrogen, chemical oxygen demand and permanganate index. Meteorological driving data, including precipitation, temperature and snow water equivalent; Watershed attribute data, including slope, soil texture, and land cover type.

3. The spatial intelligent watershed hydrological and water quality multivariate prediction method based on quaternions at multiple time and frequency scales according to claim 1, characterized in that, Step S2 specifically includes: S21: Based on the Grubbs test, analyze the sequence of each variable in the acquired spatiotemporally heterogeneous watershed hydrological and water quality data. The detection and removal of outliers are performed as follows: Calculate the mean of a series of variables. and standard deviation ,as follows: ; ; in, The length of the time series. For the first The variable values ​​at each point in time; Detect variable values Determine if it is an outlier and define the statistic. ,as follows: ; Calculation based on time series length With a given significance level Grubbs test critical value ,as follows: ; in, For degrees of freedom, The probability of being on the upper side is Students's Distribution quantiles; if Then determine This is an outlier; S22: A Kalman filter-based mean shift and data interpolation method is used to repair outliers in the hydrological and water quality data of each spatiotemporally heterogeneous watershed. Statistical features, temporal patterns, and spatial correlation information are obtained by fusing the sequences before and after repair, thus yielding the fused features. The original time series is set as follows: The repaired time series is Both are related to the system state vector. Observations; define the state transition matrix of the system model parameters. as follows: ; in, The sequence sampling time interval, and the process noise covariance matrix. as follows: ; in, , These represent the variances of the increments of the original sequence and the repaired sequence at adjacent time points, respectively. The covariance of the incremental sequence; the observation noise covariance matrix. as follows: ; in, The variance of the difference between observations at adjacent time points in the sequence; the dynamic model of the system state at the next time step. and observation model for: ; ; in, This is a dynamic model of the system state at the current moment. This indicates that the mean is zero and the covariance is... Process noise; This indicates that the mean is zero and the covariance is... Observation noise, This indicates that the mean is zero and the covariance is... Observation noise; , Given the observation matrix, apply Kalman filtering to each time series to obtain local state estimates. , and the corresponding error covariance matrix , The global state estimate is obtained by fusing local state estimates. and its error covariance matrix The expression is as follows: ; ; in, , For the weighting coefficients, satisfying The weights for each time step are calculated by summing the diagonal elements of the error covariance matrix of the original hydrological and water quality observation data and the reconstructed hydrological and water quality observation data. The time series of hydrological and water quality observation data after restoration was obtained. The expression is as follows: ; in, The system's observation matrix; Time series of hydrological and water quality observation data after restoration The training set, validation set, and test set are divided into three groups in a certain proportion.

4. The spatial intelligent watershed hydrological and water quality multivariate prediction method based on quaternions at multiple time and frequency scales according to claim 3, characterized in that, In step S22, the time series of the repaired hydrological and water quality observation data will be... Meteorological driving data and watershed attribute data are aligned by time nodes and divided into training set, validation set and test set in a ratio of 7:2:

1.

5. The spatial intelligent watershed hydrological and water quality multivariate prediction method based on quaternions at multiple time and frequency scales according to claim 1, characterized in that, Step S4 specifically includes: S41: Combine the amplitude-frequency-phase triplet The encoding is a real quaternion, as follows: ; in, Indicates the amplitude of the signal. Indicates the frequency components that are retained. = This indicates the phase of the frequency component. Used to complete the four-dimensional structure of quaternions; Let the imaginary unit of the quaternion satisfy... ; S42: Define quaternion conjugation norm The unit quaternion satisfies ; S43: Directing the observed frequency direction using quaternion exponentiation. With phase rotation angle Mapping to a 4-dimensional hypercomplex space enables a unified representation of 3D rotation and amplitude information; the quaternion exponential form expression is as follows: 。 6. The spatial intelligent watershed hydrological and water quality multivariate prediction method based on quaternions at multiple time and frequency scales according to claim 1, characterized in that, Step S6 includes: The high-dimensional coupling features obtained in step S5 The input is a quaternion Transformer decoder, processed by a nonlinear mapping function. and channel-wise regression function After processing, output the hydrological and water quality observation data. Future period to The multivariate predicted values ​​for hydrological and water quality are expressed as follows: ; in, Represents hydrological and water quality observation data The coupled feature tensor, Represents a non-linear activation function. This represents a channel-wise linear regression layer; Hydrological and water quality observation data Output At each time step Prediction matrix of hydrological and water quality variables.