Intelligent on-line monitoring method and system for COD of municipal sewage based on ultraviolet spectrum

By constructing a time axis alignment method for extrema and slope vectors and an adaptive weighted summation method, the accuracy and robustness issues of the municipal wastewater COD online monitoring system under dynamic environments were solved, achieving high-precision water quality monitoring.

CN122314140BActive Publication Date: 2026-07-28SICHUAN JIETU ENVIRONMENTAL PROTECTION SERVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SICHUAN JIETU ENVIRONMENTAL PROTECTION SERVICE CO LTD
Filing Date
2026-05-21
Publication Date
2026-07-28

AI Technical Summary

Technical Problem

Existing online COD monitoring systems for municipal wastewater based on ultraviolet spectroscopy suffer from low accuracy and poor robustness in complex and dynamically changing wastewater environments, making it difficult to accurately capture dynamic trends in water quality changes.

Method used

By acquiring the COD sequence and absorbance vector of the target detection point, discrete difference and least squares fitting are performed to construct the extreme value and slope vector. The cumulative distance matrix is ​​used for time axis alignment. Combined with Mahalanobis distance and Gaussian kernel density function, adaptive weighted summation of historical data is achieved to obtain the current COD concentration value.

Benefits of technology

It eliminates the time dimension mismatch problem, improves the accuracy and robustness of monitoring results, enables accurate extrapolation of COD concentration at the moment of water quality change, and enhances the reliability of monitoring results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122314140B_ABST
    Figure CN122314140B_ABST
Patent Text Reader

Abstract

The application provides a municipal sewage COD intelligent online monitoring method and system based on ultraviolet spectrum, relates to the technical field of water quality monitoring, and the application obtains a COD sequence of a target detection point in a preset target time window and an absorbance vector of a current detection water body in an ultraviolet band; performs discrete difference calculation on the absorbance vector to obtain a slope vector; calculates the Euclidean distance between each local extreme value in an extreme value vector and each local slope in the slope vector to obtain a joint state vector; based on a plurality of historical joint state vectors in a preset data update buffer pool, the Mahalanobis distance between the joint state vector and each historical joint state vector is calculated; the Mahalanobis distance is substituted into a preset Gaussian kernel density function to obtain a current COD concentration value. Realize adaptive high-precision real-time monitoring of complex component sewage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of water quality monitoring technology, and in particular to a method and system for intelligent online monitoring of COD in municipal wastewater based on ultraviolet spectroscopy. Background Technology

[0002] Online COD monitoring of municipal wastewater is a crucial foundation for environmental protection supervision and the intelligent operation of wastewater treatment plants. High-frequency, high-precision real-time monitoring data plays an irreplaceable supporting role in optimizing process parameters and ensuring that wastewater meets discharge standards.

[0003] In existing technologies, online monitoring systems based on ultraviolet spectroscopy have been widely used, which utilize the absorption characteristics of organic pollutants in the ultraviolet band to achieve rapid detection. These systems typically establish a static mapping model between absorbance and COD concentration, directly converting optical signals into corresponding concentration indicators, thus achieving a faster response speed than traditional chemical analysis methods.

[0004] However, municipal wastewater has a complex matrix background and tidal periodic load characteristics, leading to significant monitoring biases in existing static modeling methods when water quality experiences nonlinear abrupt changes or compositional fluctuations. Furthermore, a temporal mismatch exists between the immediacy of optical detection and the lag in the true value output of traditional chemical methods, making it difficult for existing systems to accurately capture dynamic trends in water quality and perform adaptive compensation. Therefore, existing technologies suffer from low accuracy and poor robustness in online COD monitoring under complex and dynamically changing wastewater environments. Summary of the Invention

[0005] The purpose of this application is to provide a method and system for intelligent online monitoring of COD in municipal wastewater based on ultraviolet spectroscopy, in order to solve the technical problems of low accuracy and poor robustness of online COD monitoring in complex and dynamically changing wastewater environments in existing technologies.

[0006] Firstly, this application provides a method for intelligent online monitoring of COD in municipal wastewater based on ultraviolet spectroscopy, including: Obtain the COD sequence of the target detection point within the preset target time window and the absorbance vector of the current detected water body in the ultraviolet band; Discrete difference calculation is performed on the absorbance vector to determine multiple local maxima and local minima to construct an extreme value vector. The COD sequence is then fitted with least squares method within multiple preset time windows to obtain the slope vector. Calculate the Euclidean distance between each local extremum in the extremum vector and each local slope in the slope vector to construct a cumulative distance matrix. Align the extremum vector and slope vector with the time axis according to the index relationship of the shortest path in the cumulative distance matrix to obtain the joint state vector. Based on multiple historical joint state vectors in the preset data update buffer pool, the total covariance matrix of the historical joint state vectors is calculated, and the Mahalanobis distance between the joint state vector and each historical joint state vector is calculated based on the inverse matrix of the total covariance matrix. Each historical joint state vector corresponds to a true COD value. Substituting the Mahalanobis distance into the preset Gaussian kernel density function, the probability distribution density corresponding to each historical joint state vector is calculated. All probability distribution densities are normalized to obtain multiple discrete weights. The COD true values ​​corresponding to the corresponding historical joint state vectors are weighted and summed using the discrete weights to obtain the current COD concentration value.

[0007] Optionally, discrete difference calculation is performed on the absorbance vector to determine multiple local maxima and local minima to construct an extremum vector. The COD sequence is then fitted using least squares within multiple preset time windows to obtain a slope vector, including: A difference sequence is constructed based on the numerical difference between the previous and subsequent absorbance values ​​in the absorbance vector. Determine the sign of each difference in the difference sequence, and when the sign changes from positive to negative or from positive to zero and then back to negative, take the position of the positive or zero value as the first position, and when the sign changes from negative to positive or from negative to zero and then back to positive, take the position of the negative or zero value as the second position. The values ​​corresponding to each first position in the absorbance vector are taken as local maxima and the values ​​corresponding to each second position are taken as local minima. After arranging all local maxima and all local minima in chronological order, they are normalized to obtain the extreme value vector. Based on a preset time window, the COD sequence is divided into multiple local sequences. The covariance of each local sequence with the set of time points within the corresponding time window and the variance of the set of time points are calculated. The covariance is divided by the corresponding variance to obtain the local slope of each local sequence. All local slopes are arranged in chronological order and then normalized to obtain the slope vector.

[0008] Optionally, the Euclidean distance between each local extremum in the extremum vector and each local slope in the slope vector is calculated to construct a cumulative distance matrix, including: The absolute value of the difference between each local extremum in the extremum vector and each local slope in the slope vector is taken as the Euclidean distance. An initial matrix is ​​constructed with the number of local extrema as the number of rows and the number of local slopes as the number of columns. All Euclidean distances are then filled into the corresponding nodes of the initial matrix. Traverse each node in the initial matrix from top left to bottom right, and take the minimum value among the value of the left node, the value of the top node, and the value of the top left node as the target value of the current node. Based on the target value corresponding to the current node, the Euclidean distance of the current node is updated to obtain the updated Euclidean distance. This process is repeated until all nodes have been traversed and their updated Euclidean distances are obtained, resulting in the cumulative distance matrix.

[0009] Optionally, the extreme value vector and slope vector are aligned along the time axis according to the index relationship of the shortest path in the cumulative distance matrix to obtain the joint state vector, including: The bottom right node of the cumulative distance matrix is ​​determined as the endpoint; Starting from the endpoint, compare the values ​​of the left, top, and top-left nodes of the current node. The node with the smallest value is taken as the backtracking node. Then, using the backtracking node as the current node, repeat the comparison of the values ​​of the left, top, and top-left nodes of the current node until the top-left node of the cumulative distance matrix is ​​reached. Based on the endpoint and the backtracking node, determine the shortest path. Based on the row index of each node on the shortest path, determine the corresponding local extremum in the extremum vector; based on the column index of each node on the shortest path, determine the corresponding local slope in the slope vector. Pair the local extrema and local slopes corresponding to the same node into a joint feature group. Arrange the joint feature groups corresponding to all nodes on the shortest path according to the path order of the shortest path to obtain the joint state vector.

[0010] Optionally, based on multiple historical joint state vectors in a preset data update buffer pool, the total covariance matrix of the historical joint state vectors is calculated, including: The mean vector is obtained by summing all historical joint state vectors in the preset data update buffer pool and dividing by the total number of all historical joint state vectors. The historical measured values ​​stored in the preset data update buffer pool associated with each historical joint state vector are used as the true COD value corresponding to each historical joint state vector. Based on the difference between each historical joint state vector and the mean vector, the deviation vector corresponding to each historical joint state vector is obtained; Perform matrix multiplication on each deviation vector and its corresponding transpose vector to obtain the deviation matrix corresponding to each historical joint state vector. Perform matrix addition on all deviation matrices to obtain a sum matrix. Calculate the quotient of each value in the sum matrix with the target quantity, and construct the total covariance matrix. The target quantity is the difference between the total number of vectors and one.

[0011] Secondly, this application provides an intelligent online monitoring system for COD in municipal wastewater based on ultraviolet spectroscopy, including: The acquisition module is used to acquire the COD sequence of the target detection point within a preset target time window and the absorbance vector of the current detection water body in the ultraviolet band. The determination module is used to perform discrete difference calculation on the absorbance vector, determine multiple local maxima and local minima to construct an extreme value vector, and perform least squares fitting on the COD sequence within multiple preset time windows to obtain the slope vector. The calculation module is used to calculate the Euclidean distance between each local extremum in the extremum vector and each local slope in the slope vector to construct a cumulative distance matrix. According to the index relationship of the shortest path in the cumulative distance matrix, the extremum vector and the slope vector are aligned on the time axis to obtain a joint state vector. The calculation module is also used to update multiple historical joint state vectors in the preset data update buffer pool, calculate the total covariance matrix of the historical joint state vectors, and calculate the Mahalanobis distance between the joint state vector and each historical joint state vector based on the inverse matrix of the total covariance matrix. Each historical joint state vector corresponds to a true COD value. The calculation module is also used to substitute the Mahalanobis distance into the preset Gaussian kernel density function to calculate the probability distribution density corresponding to each historical joint state vector, normalize all probability distribution densities to obtain multiple discrete weights, and use the discrete weights to perform a weighted summation of the COD true values ​​corresponding to the corresponding historical joint state vectors to obtain the current COD concentration value.

[0012] Thirdly, this application provides an electronic device, comprising: Memory, used to store computer programs; A processor is used to execute a computer program to implement the steps of the intelligent online monitoring method for COD of municipal wastewater based on ultraviolet spectroscopy as described in the first aspect above.

[0013] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the steps of the intelligent online monitoring method for municipal wastewater COD based on ultraviolet spectroscopy as described in the first aspect above.

[0014] The intelligent online COD monitoring method for municipal wastewater based on ultraviolet spectroscopy provided in this application acquires the COD sequence of the target detection point within a preset target time window and the absorbance vector of the current water body in the ultraviolet band, providing raw data support for subsequently addressing the mismatch between the immediacy of optical detection and the lag of chemical detection. It eliminates the physical transmission delay generated during the transportation of municipal wastewater through the pipeline network, solving the problem of inaccurate feature matching caused by time dimension mismatch in existing technologies. It eliminates the dimensional differences and correlation interference between the extreme value dimension and the slope dimension, improving the accuracy of the system in identifying water quality states against complex matrix backgrounds. It enables accurate extrapolation of COD concentration at moments of abrupt changes in water quality, enhancing the robustness of the monitoring results.

[0015] Furthermore, this application fills the initial matrix by calculating the absolute differences between each element in the extreme value vector and each element in the slope vector, and recursively selects the minimum values ​​of the left, top, and upper-left nodes in the neighborhood of the current node as the target values ​​according to a specific spatial traversal order. This integrates the Euclidean distance of the current node with the historical cumulative cost, ultimately constructing a cumulative distance matrix representing the globally optimal matching path. This solves the problem of insufficient robustness of existing solutions in dealing with dynamically changing wastewater environments. 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 some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 A schematic flowchart of the intelligent online monitoring method for COD of municipal wastewater based on ultraviolet spectroscopy provided in the embodiments of this application; Figure 2 A flowchart illustrating the method for constructing a cumulative distance matrix provided in an embodiment of this application; Figure 3 A flowchart illustrating the method for obtaining the current COD concentration value provided in this application embodiment; Figure 4 A schematic diagram of the structure of the intelligent online monitoring system for municipal wastewater COD based on ultraviolet spectroscopy provided in this application embodiment; Figure 5 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0018] To address the tidal and periodic load characteristics and nonlinear abrupt changes in water quality composition of municipal wastewater, this application tackles the problems of existing static mapping models being unable to cope with matrix background fluctuations and the time dimension mismatch between the immediacy of optical detection and the lag of chemical detection, leading to large monitoring deviations. This application captures the microscopic extreme value characteristics of the absorbance vector and the macroscopic evolution trend of the COD sequence through discrete difference and least squares fitting, respectively. Furthermore, it utilizes the shortest path search mechanism of the cumulative distance matrix to flexibly align the optical extreme values ​​and chemical slopes, which have phase delays, to construct a joint state vector that can characterize the true fluctuations in water quality, thereby eliminating the correlation error caused by the time dimension mismatch. Based on this, it abandons the fixed mapping formula that is susceptible to background interference, uses Mahalanobis distance to retrieve data in the statistical space to update historical similar states in the buffer pool, and achieves adaptive allocation and weighted extrapolation of empirical weights through the Gaussian kernel density function. Finally, it achieves high accuracy and robustness of online COD monitoring in complex and dynamically changing wastewater environments.

[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0020] The core of this application is to provide an intelligent online monitoring method for COD in municipal wastewater based on ultraviolet spectroscopy. A flowchart of one specific implementation method is shown below. Figure 1 As shown, the method includes: Step 101: Obtain the COD sequence of the target detection point within the preset target time window and the absorbance vector of the current detection water body in the ultraviolet band.

[0021] In this step, the target detection point refers to the pre-set spectral sensing device and sampling analysis location within the wastewater treatment network or treatment plant. The pre-set target time window can be a sliding backtracking period determined by a set duration. The COD sequence refers to multiple consecutive chemical oxygen demand values ​​measured and recorded by chemical methods for the target detection point over a past period. The currently detected water body refers to the real-time wastewater flow within the detection optical path of the ultraviolet spectral sensor. The ultraviolet band can include a specific spectral coverage range from 200 nanometers to 400 nanometers. The absorbance vector is a time-series multidimensional set of values ​​reflecting the degree of light energy absorption of the currently detected water body at a specific ultraviolet characteristic wavelength, according to continuous sampling times within the target time window.

[0022] In this embodiment, the historical records of the target detection point within a preset target time window are first retrieved, and pre-stored laboratory analysis data are read to obtain a COD sequence composed of concentration values ​​corresponding to multiple time points. Specifically, COD sequence Represented as a set of elements arranged in chronological order of sampling time. .

[0023] For example, at monitoring station B of wastewater treatment plant A, the preset target time window is set to the most recent operating shift. Discrete data points sampled at fixed intervals within that time period are retrieved to form a COD sequence. It can be represented as a set of sequences consisting of low-concentration state data L, medium-concentration state data M, and high-concentration state data H arranged in chronological order. .

[0024] Simultaneously, the on-site spectral sensing equipment performs real-time scanning of the water body under test. By emitting ultraviolet pulsed light and receiving the residual light signal after penetrating the water, a specific characteristic wavelength with the highest absorption sensitivity to the target organic matter is selected. The absorbance values ​​of this characteristic wavelength at various discrete time points within the target time window are continuously collected, and then combined in chronological order to obtain the absorbance vector. Specifically, the absorbance vector Represented as a set of values ​​arranged in ascending order of wavelength. .

[0025] For example, at monitoring point C, for the current real-time wastewater sample, the sensor continuously sweeps the frequency of a specific ultraviolet characteristic wavelength to obtain the absorbance component x at the first sampling time, the absorbance component y at the second sampling time, and the absorbance component z at the third sampling time. Combining these components in chronological order, the absorbance vector a can be represented as a vector matrix. .

[0026] Step 102: Perform discrete difference calculation on the absorbance vector to determine multiple local maxima and local minima to construct an extreme value vector. Perform least squares fitting on the COD sequence within multiple preset time windows to obtain the slope vector.

[0027] In this step, a local maximum refers to a turning point in the differenced numerical sequence where the value changes from increasing to decreasing. A local minimum refers to a turning point in the differenced numerical sequence where the value changes from decreasing to increasing. The extreme value vector is a feature set composed of multiple extracted local maxima and local minima in chronological order. The preset time window here refers to the sliding interval used for local linear fitting of the COD sequence. The slope vector is a set of values ​​reflecting the rate of evolution of the COD sequence within different local intervals.

[0028] Step 201: Construct a difference sequence based on the numerical difference between the previous and subsequent times in the absorbance vector.

[0029] In this step, the difference sequence refers to the set of values ​​that reflects the gradient of changes in absorbance over time.

[0030] In this embodiment, the values ​​of each sampling node in the absorbance vector arranged in chronological order are extracted. The difference between the values ​​at different times is calculated by subtracting the values ​​at the previous time from the values ​​at the next time step. The subtraction operation is performed on all adjacent nodes in the absorbance vector, and all the calculated differences are combined according to the original time evolution order to construct a difference sequence.

[0031] For example, the absorbance vector of the currently monitored water body obtained at monitoring station B in wastewater treatment plant A. Assuming The first difference is obtained by calculating the numerical difference between the second and first terms. up to the fourth difference The final constructed difference sequence Represented as .

[0032] Step 202: Determine the sign of each difference in the difference sequence, and when the sign changes from positive to negative or from positive to zero and then back to negative, take the position of the positive or zero value as the first position, and when the sign changes from negative to positive or from negative to zero and then back to positive, take the position of the negative or zero value as the second position.

[0033] In this step, the sign refers to the positive or negative state of each value in the difference sequence. The first position is the index coordinate representing the end of the absorbance's upward trend and the beginning of its decline, or the point where it plateaus and then declines. The second position is the index coordinate representing the end of the absorbance's downward trend and the beginning of its rise, or the point where it plateaus and then rises.

[0034] In this embodiment of the application, the numerical values ​​in the difference sequence are read one by one and the sign state is determined. When the sign of the difference value changes directly from a positive value to a negative value, the index of the positive value in the difference sequence is extracted as the first position. When the sign of the difference value changes from a positive value to a zero value and then to a negative value, the index of the zero value is extracted as the first position. When the sign of the difference value changes directly from a negative value to a positive value, the index of the negative value is extracted as the second position. When the sign of the difference value changes from a negative value to a zero value and then to a positive value, the index of the zero value is extracted as the second position.

[0035] For example, for difference sequences The set represented ,like Positive value and zero value and When the value is negative, the sign changes from positive to zero and then back to negative; the zero value is extracted. The corresponding original data coordinates are used as the first position. ,like Negative values ​​and If the value is positive, the sign changes directly from negative to positive; the negative value is then extracted. The corresponding original data coordinates are used as the second position. .

[0036] Step 203: Take the value corresponding to each first position in the absorbance vector as the local maximum and the value corresponding to each second position as the local minimum. Arrange all local maxima and local minima in chronological order and normalize them to obtain the extreme value vector.

[0037] In this embodiment, the corresponding values ​​of all recorded first positions are extracted from the original absorbance vector as local maxima, and the corresponding values ​​of all recorded second positions are extracted from the absorbance vector as local minima. All extracted local maxima and minima are rearranged and combined in strict chronological order to form a preliminary feature set. A scaling algorithm is then used to compress or stretch all values ​​in the preliminary feature set, uniformly mapping them to a dimensionless interval of zero to one, thus obtaining an extremum vector that eliminates the original dimensional differences.

[0038] For example, based on the first position determined above. In absorbance vector Extract the corresponding node values As a local maximum, according to the second position Extract the corresponding node values As local minima, arranged in chronological order, they form a feature set. After normalization of the maximum and minimum values, the final extreme value vector is obtained. Represented as .

[0039] Step 204: Based on a preset time window, divide the COD sequence into multiple local sequences, calculate the covariance of each local sequence with the set of time points within the corresponding time window and the variance of the set of time points, divide the covariance by the corresponding variance to obtain the local slope of each local sequence, arrange all local slopes in chronological order and normalize them to obtain the slope vector.

[0040] In this step, a local sequence refers to a set of subsequences obtained by truncating complete historical concentration data over a specific time period. A time point set refers to the specific combination of time scales corresponding to each sampled data point within each local sequence. Covariance is a statistical indicator that measures the co-variance trend between the local sequence and the time point set. Variance is a statistical indicator that measures the degree of deviation of each time scale within the time point set from the average time.

[0041] In this embodiment, the overall COD sequence is truncated and segmented through a preset time window according to a set sliding step size, generating multiple local sequences with temporal overlap. For each local sequence, the sampling time corresponding to each data point is extracted to form a time point set. The covariance between each concentration value within each local sequence and each time scale within the time point set is calculated based on statistical principles. The variance of the time point set itself is calculated. The calculated covariance is divided by the corresponding variance, and the local slope of each local sequence is obtained using the least squares method. The specific calculation formula is expressed as follows: ,in Indicates the first The original local slope of a preset time window, Indicates the first The covariance of a local sequence with respect to the set of corresponding time points Indicates the first The variance of a set of time points is calculated. After obtaining the original local slopes corresponding to all preset time windows, all values ​​are arranged in chronological order and normalized to obtain the slope vector.

[0042] For example, regarding the obtained COD sequence The set represented The first local sequence is obtained by capturing the first preset time window. and the corresponding time point set The first covariance was calculated. With first variance Divide the two to obtain the first original local slope The second local sequence was obtained by capturing the second preset time window. The second original local slope is obtained by analogy calculation. The set of slopes arranged in order. After normalization, the final slope vector is obtained. Represented as .

[0043] Step 103: Calculate the Euclidean distance between each local extremum in the extremum vector and each local slope in the slope vector to construct a cumulative distance matrix. Align the extremum vector and slope vector with the time axis according to the index relationship of the shortest path in the cumulative distance matrix to obtain the joint state vector.

[0044] In this step, a local extremum refers to a single feature element in the extremum vector. A local slope refers to a single trend element in the slope vector. The cumulative distance matrix is ​​a cost matrix used to record the minimum cost path between two vectors across all possible matching states. The shortest path is the connection path with the minimum cumulative cost from the start point to the end point of the matrix. The index relationship refers to the row and column mapping positions of the nodes traversed by the shortest path in the extremum and slope vectors. The joint state vector is a composite feature set generated by matching absorbance features and concentration evolution features after time axis alignment.

[0045] like Figure 2 As shown, Figure 2 This is a flowchart illustrating the method for constructing a cumulative distance matrix provided in an embodiment of this application.

[0046] Step 301: Take the absolute value of the difference between each local extremum in the extremum vector and each local slope in the slope vector as the Euclidean distance. Construct an initial matrix with the number of local extrema as the number of rows and the number of local slopes as the number of columns, and fill all the Euclidean distances into the corresponding nodes of the initial matrix.

[0047] In this step, the initial matrix refers to a two-dimensional grid data structure used to record the initial differences between each pair of elements in the extreme value vector and the slope vector. A node refers to a specific data storage unit in the initial matrix that is located at the intersection of a specific row dimension and a specific column dimension.

[0048] In this embodiment, each local extremum in the extremum vector constructed in the preceding steps and each local slope in the slope vector are extracted. Each local slope is subtracted from each local extremum, and the absolute value of the result is taken to calculate the Euclidean distance between paired elements. The total number of local extrema in the extremum vector is used as the number of rows in the two-dimensional matrix, and the total number of local slopes in the slope vector is used as the number of columns in the two-dimensional matrix, thus constructing a blank initial matrix in memory. Then, each calculated Euclidean distance is sequentially filled into the corresponding node in the initial matrix according to the row position corresponding to the local extremum and the column position corresponding to the local slope.

[0049] For example, the extreme value vector obtained from monitoring station B at wastewater treatment plant A. Represented as and slope vector Represented as ,calculate and The absolute value of the difference is used as the first Euclidean distance. ,calculate and The absolute value of the difference is used as the second Euclidean distance. Calculate the sixth Euclidean distance in this manner. , with extreme value vector The number of elements, 2, is used as the row number and slope vector. The initial matrix is ​​constructed using the number of elements 3 as the column number, and the first Euclidean distance is used. To the sixth Euclidean distance After filling in the rows sequentially, the resulting initial matrix is ​​constructed. Represented as .

[0050] Step 302: Traverse each node in the initial matrix from top left to bottom right, and take the minimum value among the values ​​of the left node, the top node, and the top left node of the current node as the target value of the current node.

[0051] In this step, the current node refers to the specific data storage unit being processed during the traversal of the initial matrix. The left node is the data unit in the initial matrix that is in the same row as the current node and in the adjacent column preceding it. The top node is the data unit in the initial matrix that is in the same column as the current node and in the adjacent row preceding it. The upper-left node is the diagonally adjacent data unit in the initial matrix that is in the row and column preceding the current node. The target value is the minimum cost value selected from the historical cumulative costs of the aforementioned three adjacent nodes.

[0052] In this embodiment, a dynamic programming algorithm is used for pathfinding preprocessing. Starting from the upper left position of the initial matrix, the nodes in the initial matrix are traversed in a specific order, progressing row by row from top to bottom and from left to right within each row. When a specific current node is reached, the values ​​of its left-hand node, its upper-hand node, and its upper-left-hand node are read. The minimum value among these three values ​​is selected through a value comparison operation and assigned to the current node as the corresponding target value.

[0053] For example, for the aforementioned initial matrix When traversing to the current node in the second row and second column, extract the cumulative value corresponding to its left node. and the cumulative values ​​corresponding to the nodes above. The cumulative value corresponding to the top left node The smallest of these three values ​​is selected as the target value for the current node. .

[0054] Step 303: Based on the target value corresponding to the current node, update the Euclidean distance of the current node to obtain the updated Euclidean distance. Continue until the traversal is completed and the updated Euclidean distances of all nodes are obtained, thus obtaining the cumulative distance matrix.

[0055] In this step, the updated Euclidean distance refers to the global cumulative cost value generated by arithmetically adding the original basic difference cost of the current node to the minimum cumulative cost of the previous pass.

[0056] In this embodiment, the Euclidean distance originally filled in the current node is read, the target value corresponding to the current node is extracted, the read Euclidean distance and the target value are added together to calculate the updated Euclidean distance, and the result is written into the current node. This update operation is continuously executed through a loop control logic until the last node in the lower right corner of the matrix is ​​reached. Finally, all nodes complete the numerical update iteration process, resulting in a cumulative distance matrix that fully records the alignment costs of all possible paths. Specifically, the node numerical update formula is expressed as follows: ,in This represents the updated Euclidean distance of the current node. This represents the original Euclidean distance of the current node. This represents the target value corresponding to the current node.

[0057] For example, for the current node in the second row and second column mentioned above, its original fifth Euclidean distance is... With the determined target value Add them together to get the updated Euclidean distance. The cumulative distance matrix is ​​output after all nodes have been traversed. Represented as .

[0058] Step 311: Determine the bottom right node of the cumulative distance matrix as the endpoint.

[0059] In this step, the bottom-right node refers to the limit boundary data cell located in the last row and last column of the cumulative distance matrix. The endpoint refers to the final coordinate position representing the complete alignment and matching of the two feature sequences during the reverse dynamic pathfinding process.

[0060] In this embodiment, the maximum boundary index values ​​of the row dimension and the maximum boundary index values ​​of the column dimension of the constructed cumulative distance matrix are read. The maximum boundary index values ​​of the row dimension and the maximum boundary index values ​​of the column dimension are combined to form a coordinate index. The unique node at the bottom right of the cumulative distance matrix is ​​accurately located through the coordinate index. The bottom right node is marked as the starting backtracking anchor point of the pathfinding algorithm and determined as the endpoint of the time axis alignment and matching process.

[0061] For example, consider the aforementioned two-row, three-column cumulative distance matrix. Extract nodes with a maximum of two rows and a maximum of three columns, and determine the bottom right corner node with coordinates in the second row and third column as the endpoint.

[0062] Step 312: Starting from the endpoint, compare the values ​​of the left, top, and top-left nodes of the current node. Take the node with the smallest value as the backtracking node, and use the backtracking node as the current node to repeatedly compare the values ​​of the left, top, and top-left nodes of the current node until the top-left node of the cumulative distance matrix is ​​reached. Based on the endpoint and the backtracking node, determine the shortest path.

[0063] In this step, the backtracking node refers to the lowest-cost adjacent node selected by the comparison and decision logic as part of the globally optimal path during the reverse pathfinding process. The top-left node refers to the data unit in the first row and first column of the cumulative distance matrix, representing the alignment with the origin.

[0064] In this embodiment, a reverse pathfinding mechanism is initiated. The determined endpoint is used as the initial current node for cost evaluation. The cumulative cost values ​​stored in the adjacent left, upper, and upper left nodes of the current node are compared, and the node with the smallest value is selected and marked as the backtracking node. Then, the determined backtracking node is used as the new current node, and the comparison of adjacent three node values ​​and the selection of the minimum cost node are repeated. This cyclic backtracking process continues until the node finally backtracks to the upper left corner of the cumulative distance matrix. Based on the endpoint and all backtracking nodes recorded along the way, the coordinates are concatenated to determine a globally minimum route that completely runs from the upper left corner node to the endpoint, which is then used as the matching shortest path.

[0065] For example, from the cumulative distance matrix Starting from the endpoint in the second row and third column, a reverse search is performed. By comparison, the updated Euclidean distance corresponding to the node to the upper left of the endpoint, which is the node in the first row and second column, is found. The node with the smallest value is selected as the first backtracking node, located at the first row and second column. The node at the first row and second column is then used as the new current node to continue comparing the nodes to the left. Finally, the process backtracks to the top-left node at the first row and first column, thus obtaining the shortest path composed of coordinate pairs. Represented as a set .

[0066] Step 313: Determine the corresponding local extremum in the extremum vector based on the row index of each node on the shortest path, and determine the corresponding local slope in the slope vector based on the column index of each node on the shortest path.

[0067] In this step, the row index refers to the horizontal numerical index of the node on the shortest path within the cumulative distance matrix. The column index refers to the vertical numerical index of the node on the shortest path within the cumulative distance matrix.

[0068] In this embodiment, the data attributes of each constituent node are read sequentially according to the determined shortest path, and the row index and column index of the node in the matrix structure are parsed out. The parsed row index is used as the basis for a one-dimensional addressing operation in the extreme value vector to determine the corresponding unique local extreme value, and the parsed column index is used as the basis for a one-dimensional addressing operation in the slope vector to determine the corresponding unique local slope.

[0069] For example, regarding the aforementioned shortest path coordinate pairs in Extract its row index value one and column index value two, and then extract them from the extreme value vector. The local extremum is determined based on row index 1. In the slope vector The local slope is determined based on column index two. .

[0070] Step 314: Pair the local extrema and local slopes corresponding to the same node into a joint feature group. Arrange the joint feature groups corresponding to all nodes on the shortest path according to the path order of the shortest path to obtain the joint state vector.

[0071] In this step, the joint feature set refers to a feature pair formed by binding together a local extremum and a local slope that have physical lag on the time axis but are determined by the shortest path algorithm to belong to the same water quality evolution stage.

[0072] In this embodiment, for each specific node on the shortest path, its mapped local extrema and local slope are merged and bidirectionally paired to generate a joint feature group. After completing the data pairing operation for all constituent nodes, all generated joint feature groups are extracted sequentially according to the forward evolution order of the shortest path. These joint feature groups are then arranged and combined in chronological order to finally obtain a multidimensional joint state vector that fully represents the dynamic change law of comprehensive water quality at the monitoring point within that time period.

[0073] For example, the aforementioned extracted local extrema and local slope Pairing and combining to form the second joint feature group Similarly, based on the nodes Generate the first joint feature set And based on nodes Generate the third joint feature set According to the shortest path The path order arranges the above joint feature groups sequentially, resulting in the final joint state vector. Represented as a matrix .

[0074] Step 104: Based on multiple historical joint state vectors in the preset data update buffer pool, calculate the total covariance matrix of the historical joint state vectors, and calculate the Mahalanobis distance between the joint state vector and each historical joint state vector based on the inverse matrix of the total covariance matrix. Each historical joint state vector corresponds to a true COD value.

[0075] In this step, the pre-defined data update buffer refers to a database storing labeled historical sample data. The historical joint state vector refers to the sample characteristics stored in the buffer with known concentration labels. The total covariance matrix is ​​a statistical matrix describing the distribution divergence of all historical samples in the buffer across various dimensions and the correlation between dimensions. The Mahalanobis distance is a standardized distance that considers the data distribution characteristics. The true COD value refers to the accurate concentration value obtained through chemical experimental analysis.

[0076] Step 401: Add all historical joint state vectors in the preset data update buffer pool together and divide by the total number of all historical joint state vectors to obtain the mean vector. Then, use the historical measured values ​​stored in the preset data update buffer pool that are associated with each historical joint state vector as the true COD value corresponding to each historical joint state vector.

[0077] In this step, the total number of vectors refers to the sum of the number of historical samples stored in the preset data update buffer. The mean vector refers to the set of arithmetic mean values ​​of all historical joint state vectors across each feature dimension. Historical measured values ​​refer to pollution concentration indicators obtained from past actual tests corresponding to the optical characteristics at that time.

[0078] In this embodiment, all historical joint state vectors are extracted from a preset data update buffer pool. These vectors are then added dimension by dimension to obtain a sum vector. The total number of historical joint state vectors involved in the addition is counted. The mean vector reflecting the overall distribution center of the historical data is calculated by dividing the value of each dimension of the sum vector by the total number of vectors. Simultaneously, historical measured values ​​bound to each historical joint state vector are read from the preset data update buffer pool and directly assigned to the corresponding historical joint state vector as its corresponding COD true value.

[0079] For example, at monitoring station B in wastewater treatment plant A, the first historical joint state vector stored in the preset data update buffer is retrieved. and the fifth historical joint state vector The mean vector is calculated by summing the five historical joint state vectors and dividing by the total number of vectors, which is five. Represented as Extract the joint state vector with the first history. First historical measured value of associated storage As its exclusive COD true value, extract the joint state vector with the second history. Second historical measured value of associated storage As its exclusive COD real value.

[0080] Step 402: Based on the difference between each historical joint state vector and the mean vector, obtain the deviation vector corresponding to each historical joint state vector.

[0081] In this step, the bias vector refers to the set of features that represent the direction and distance of a specific historical sample's offset relative to the overall mean level in a multidimensional space.

[0082] In this embodiment, for each historical joint state vector in the preset data update buffer pool, a vector-level subtraction operation is performed by subtracting the calculated mean vector from the historical joint state vector to calculate the difference between the historical joint state vector and the mean vector in each dimension. These differences are then combined according to the original dimensional order to generate a deviation vector specific to that historical joint state vector.

[0083] For example, regarding the aforementioned first historical joint state vector Subtract the calculated mean vector from it. The first deviation vector is obtained by performing subtraction calculations in the corresponding dimension. Represented as Similarly, by subtracting the mean vector from the joint state vectors of the second to fifth historical periods... The second deviation vector is calculated respectively. To the fifth deviation vector .

[0084] Step 403: Perform matrix multiplication on each deviation vector and its corresponding transpose vector to obtain the deviation matrix corresponding to each historical joint state vector.

[0085] In this step, the transpose vector refers to the new vector obtained by transposing and inverting the rows and columns of the original deviation vector. The deviation matrix is ​​a data matrix that reflects the structural characteristics of a single deviation vector in its various dimensions, generated by multiplying each deviation vector with its corresponding transpose vector.

[0086] In this embodiment, each generated deviation vector undergoes a matrix transpose operation in linear algebra, transforming it from a column vector to a row vector or vice versa, to generate a corresponding transpose vector. Each deviation vector is then multiplied by its own transpose, performing matrix multiplication to obtain the deviation matrix specific to each historical joint state vector. The specific calculation formula is expressed as follows: ,in Indicates the first The deviation matrix corresponding to each historical joint state vector Indicates the first A deviation vector, Indicates the first The transpose of the bias vectors.

[0087] For example, regarding the first deviation vector generated above... Transpose it to obtain the first transpose vector. Represented as Similarly, by subtracting the mean vector from the joint state vector of the second to fifth historical periods... The second deviation vector is calculated respectively. To the fifth deviation vector The first deviation vector With the first transpose vector Multiplication yields the first deviation matrix. Represented as a square matrix of 3 rows and 3 columns Regarding the second deviation vector To the fifth deviation vector Similarly, multiplying them together yields the second deviation matrix. To the fifth deviation matrix .

[0088] Step 404: Perform matrix addition on all deviation matrices to obtain a sum matrix. Calculate the quotient of each value in the sum matrix with the target quantity, and construct the total covariance matrix. The target quantity is the difference between the total number of vectors and one.

[0089] In this step, the sum matrix refers to the comprehensive divergence matrix generated by numerically summing the bias matrices of all individual samples along their corresponding dimensions. The target number refers to a specific constant obtained by adjusting the total number of samples for degrees of freedom in order to achieve unbiased estimation.

[0090] In this embodiment, all deviation matrices are summed item by item to obtain a sum matrix that aggregates all sample variation information. The total number of vectors counted in the preceding steps is obtained, and the difference between this total number of vectors and the natural number one is calculated as the target quantity. Each specific value in the sum matrix is ​​extracted, divided by the calculated target quantity to obtain the quotient, and all quotients are used to reconstruct a matrix to obtain the total covariance matrix.

[0091] For example, the first deviation matrix With the fifth deviation matrix Adding them together yields the sum matrix. Represented as Given that the total number of vectors is 5, and the target number is 4, calculate the sum matrix. Divide each value in the matrix by the target quantity to obtain the quotient, and finally construct a full-rank invertible total covariance matrix. Represented as .

[0092] Step 411: Subtract each historical joint state vector from the joint state vector to obtain the difference vector corresponding to each historical joint state vector.

[0093] In this step, the difference vector refers to the set of features that represent the multidimensional spatial location difference between the currently acquired joint state vector and a specific historical joint state vector in the buffer pool.

[0094] In this embodiment, the joint state vector corresponding to the currently detected water body is extracted. Each historical joint state vector in a preset data update buffer is read sequentially, and the current joint state vector is subtracted from each historical joint state vector. Multi-dimensional vector subtraction is performed to calculate the absolute deviation of the current state relative to each historical state. The deviations in each dimension are combined to obtain the difference vector corresponding to each historical joint state vector.

[0095] For example, extract the computed current joint state vector. Represented as Using the joint state vector Subtract the first historical joint state vector The first difference vector is obtained after subtracting each term. Represented as Similarly, using the joint state vector... Subtract the second historical joint state vector Up to the fifth historical joint state vector The second difference vectors are obtained respectively. to the fifth difference vector .

[0096] Step 412: Perform matrix multiplication on the transpose of each difference vector and the inverse of the total covariance matrix to obtain the intermediate vector corresponding to each historical joint state vector.

[0097] In this step, the intermediate vector refers to the set of transitional features obtained after a matrix space transformation during the process of solving the quadratic distance.

[0098] In this embodiment, a matrix inversion algorithm is performed on the calculated total covariance matrix to generate an inverse matrix that smooths out differences in dimensions and eliminates interference from feature correlations. For each generated difference vector, a matrix transpose operation is performed to generate a corresponding transpose vector. The transpose of each difference vector is then multiplied by the inverse of the total covariance matrix, performing matrix multiplication. A spatial transformation is achieved by introducing a weighting mechanism for the inverse matrix, resulting in the intermediate vector corresponding to each historical joint state vector. For example, the total covariance matrix... The inverse matrix is ​​obtained by performing inversion calculation. Represented as a square matrix of 3 rows and 3 columns The first difference vector Transpose to obtain the first transpose difference vector Represented as Using the first transpose difference vector Multiply by the inverse matrix The first intermediate vector is calculated. Represented as Similarly, using the second difference vector... Up to the fifth difference vector Transposed vector multiplied by its inverse matrix The second intermediate vector is calculated. to the fifth intermediate vector .

[0099] Step 413: Perform matrix multiplication on each intermediate vector and its corresponding difference vector to obtain a scalar value. Use the square root of each scalar value as the Mahalanobis distance between the joint state vector and the corresponding historical joint state vector.

[0100] In this step, a scalar value refers to a real number result that has only numerical magnitude and no directional attribute.

[0101] In this embodiment, each intermediate vector and its corresponding original difference vector are extracted. Each intermediate vector is multiplied by its corresponding difference vector, and the multidimensional vectors are reduced in dimensionality and aggregated into a scalar value representing the square of the quadratic distance through the inner product operation logic in matrix multiplication. The square root operation is performed on each calculated scalar value, and the result after taking the square root is finally used as the Mahalanobis distance between the current joint state vector and the corresponding historical joint state vector. The specific calculation formula is shown in formula (1): (1); in, Indicates the first The distance to Maharanobis That is, the first one obtained from the aforementioned calculation. intermediate vectors Indicates the first A difference vector.

[0102] For example, the first intermediate vector With the first difference vector Multiplying yields the first scalar value. For the first scalar value Taking the square root yields the current joint state vector. Joint state vector with the first history The distance between the first Maharanobis Similarly, for the second intermediate vector... With the second difference vector The second Mahalanobis distance is calculated by taking the square root of the product. .

[0103] Step 105: Substitute the Mahalanobis distance into the preset Gaussian kernel density function to calculate the probability distribution density corresponding to each historical joint state vector. Normalize all probability distribution densities to obtain multiple discrete weights. Use the discrete weights to perform a weighted summation of the COD true values ​​corresponding to the corresponding historical joint state vectors to obtain the current COD concentration value.

[0104] In this step, the preset Gaussian kernel density function refers to an exponential decay function with a base of the natural constant. The probability distribution density is a numerical value used to measure the likelihood that the current state belongs to a certain historical scenario. The discrete weights refer to the percentage distribution of the influence of all samples after normalization. The current COD concentration value refers to the final output intelligent prediction data result.

[0105] like Figure 3 As shown, Figure 3 This is a flowchart illustrating the method for obtaining the current COD concentration value provided in an embodiment of this application.

[0106] Step 501: Substitute the Mahalanobis distance into the preset Gaussian kernel density function to calculate the exponential term corresponding to each historical joint state vector. The Gaussian kernel density function indicates that there is a negatively correlated exponential mapping relationship between the Mahalanobis distance and the probability distribution density corresponding to each historical joint state vector.

[0107] In this step, the pre-defined Gaussian kernel density function is a mathematical model characterized by a bell-shaped curve, used to nonlinearly map statistical distance to similarity probabilities. The exponential term refers to the combination of negative features within the Gaussian function that determines the decay rate. The negative correlation exponential mapping relationship is a mathematical rule that the larger the distance value, the smaller the probability value generated by the mapping exponentially.

[0108] In this embodiment, the Mahalanobis distance between the current joint state vector calculated in the preceding steps and each historical joint state vector is extracted to obtain the smoothing parameter configured within the preset Gaussian kernel density function. The square of each Mahalanobis distance is divided by twice the negative value of the square of the smoothing parameter to calculate the exponential term corresponding to each historical joint state vector. By introducing the smoothing parameter and the negative sign to calculate the exponential feature, the core logic of Gaussian mapping is constructed, in which the exponential term becomes smaller the greater the distance.

[0109] For example, at monitoring station B of wastewater treatment plant A, the first Mahalanobis distance calculated previously is extracted. And the distance to the second Maharanobis Obtain the pre-set smoothing parameters from the preset Gaussian kernel density function. The distance from the first Maharanobis The square of the value divided by the smoothing parameter The negative two times the square yields the first exponent term. Similarly, the distance to the second Maharanobis... The square of the value divided by the smoothing parameter The negative two times the square yields the second exponent. .

[0110] Step 502: Calculate the power function value with the natural constant as the base and each exponent as the exponent to obtain the probability distribution density corresponding to each historical joint state vector.

[0111] In this step, the natural constant refers to the base of an irrational constant in mathematics that represents the limit of continuous growth. The power function value is the result obtained by exponentially multiplying a specific base. The probability distribution density is an absolute quantitative indicator representing the statistical similarity between the current state of the water body and a historical state.

[0112] In this embodiment of the application, irrational numbers are... The natural constant is determined as the base, and each exponent term calculated in the previous step is extracted as the operational exponent. By calculating the power function value with the natural constant as the base and the corresponding exponent term as the exponent, the nonlinear space transformation from statistical distance to probability is completed, and the probability distribution density corresponding to each historical joint state vector is obtained. The specific calculation formula is expressed as follows: ,in Indicates the first A probability distribution density, Represents the natural constant. Indicates the first Each index item.

[0113] For example, regarding the first exponential term obtained from the aforementioned calculation... and the second exponential term , with natural constant Using the first exponential term as the base, the calculation is performed. The first probability distribution density is obtained by taking the power function value of the exponent. Calculate using the second exponent term The second probability distribution density is obtained by taking the power function value of the exponent. .

[0114] Step 503: Sum all probability distribution densities to obtain a total density, calculate the quotient of each probability distribution density with the total density, and obtain the discrete weights corresponding to each historical joint state vector.

[0115] In this step, the total density refers to the sum of the absolute similarity indices of all historical samples to the current state. The discrete weight refers to the relative percentage value of the influence of each historical sample on the current concentration projection result after normalization.

[0116] In this embodiment, the probability distribution density corresponding to all calculated historical joint state vectors is extracted. All probability distribution densities are summed using addition to obtain a density sum reflecting the overall matching degree of the data buffer pool. To eliminate scale differences in absolute values, each probability distribution density is used as the dividend, and the density sum is used as the divisor; the quotients are calculated by dividing the two. Each quotient is then used as a discrete weight corresponding to each historical joint state vector.

[0117] For example, extract the first probability distribution density obtained from the aforementioned calculation. With the second probability distribution density The sum of densities is obtained by adding the two together using addition. The first probability distribution density Divide by the total density Solving for the quotient yields the first discrete weight. The second probability distribution density Divide by the total density Solving for the quotient yields the second discrete weight. .

[0118] Step 504: Obtain the current COD concentration value by accumulating the product of each discrete weight and the corresponding historical joint state vector associated with the true COD value.

[0119] In this embodiment, each calculated discrete weight is extracted, and the actual COD value associated with each historical joint state vector is read from a preset data update buffer. Each discrete weight is multiplied by the corresponding historical joint state vector's actual COD value to obtain a product reflecting the contribution of a single historical experience to the current concentration prediction result. All calculated products are then summed and combined using addition. By integrating the empirical knowledge from all relevant historical samples in the buffer, the current COD concentration value of the currently detected water body is finally calculated.

[0120] For example, extract the first discrete weights obtained from the aforementioned calculation. and the second discrete weight Extract the first COD true value associated with the first historical joint state vector from the preset data update buffer pool. Extract the true value of the second COD associated with the second historical joint state vector. The first discrete weight Multiply by the first true value of COD Obtain the first product, then apply the second discrete weights. Multiply by the second COD true value The second product is obtained. The first and second products are then added together to obtain the final COD concentration value that can adapt to nonlinear fluctuations in water quality. .

[0121] This application provides raw data support for addressing the mismatch between the immediacy of optical detection and the lag in chemical detection by acquiring the COD sequence of the target detection point within a preset target time window and the absorbance vector of the currently detected water body in the ultraviolet band. It eliminates the physical transmission delay caused by municipal sewage during pipeline transport, resolving the problem of inaccurate feature matching due to time dimension mismatch in existing technologies. It eliminates the dimensional differences and correlation interference between extreme value dimensions and slope dimensions, improving the accuracy of the system in identifying water quality states against complex matrix backgrounds. It enables accurate extrapolation of COD concentration at moments of sudden water quality changes, enhancing the robustness of the monitoring results.

[0122] Figure 4This is a schematic diagram of a specific embodiment of the intelligent online monitoring system for municipal wastewater COD based on ultraviolet spectroscopy provided in this application, with reference to... Figure 4 The system may include: The acquisition module 21 is used to acquire the COD sequence of the target detection point within a preset target time window and the absorbance vector of the current detection water body in the ultraviolet band. Module 22 is used to perform discrete difference calculation on the absorbance vector, determine multiple local maxima and local minima to construct an extreme value vector, and perform least squares fitting on the COD sequence within multiple preset time windows to obtain the slope vector. Calculation module 23 is used to calculate the Euclidean distance between each local extremum in the extremum vector and each local slope in the slope vector to construct a cumulative distance matrix. According to the index relationship of the shortest path in the cumulative distance matrix, the extremum vector and the slope vector are aligned on the time axis to obtain a joint state vector. The calculation module 23 is also used to update multiple historical joint state vectors in the preset data update buffer pool, calculate the total covariance matrix of the historical joint state vectors, and calculate the Mahalanobis distance between the joint state vector and each historical joint state vector based on the inverse matrix of the total covariance matrix, with each historical joint state vector corresponding to a true COD value. The calculation module 23 is also used to substitute the Mahalanobis distance into the preset Gaussian kernel density function, calculate the probability distribution density corresponding to each historical joint state vector, normalize all probability distribution densities to obtain multiple discrete weights, and use the discrete weights to perform a weighted summation of the COD true values ​​corresponding to the corresponding historical joint state vectors to obtain the current COD concentration value.

[0123] The intelligent online monitoring system for COD of municipal wastewater based on ultraviolet spectroscopy in this application is used to implement the aforementioned intelligent online monitoring method for COD of municipal wastewater based on ultraviolet spectroscopy. Therefore, the specific implementation of the intelligent online monitoring system for COD of municipal wastewater based on ultraviolet spectroscopy can be found in the embodiment section of the intelligent online monitoring method for COD of municipal wastewater based on ultraviolet spectroscopy above. The specific implementation can be referred to the description of the corresponding embodiment, and will not be repeated here.

[0124] Figure 5 A schematic diagram of the hardware structure of the electronic device provided in an embodiment of this application is shown.

[0125] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of the above-described intelligent online monitoring method for municipal wastewater COD based on ultraviolet spectroscopy.

[0126] The electronic device may include a processor 510 and a memory 520 storing computer program instructions.

[0127] Specifically, the processor 510 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.

[0128] Memory 520 may include mass storage for data or instructions. For example, and not limitingly, memory 520 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 520 may include removable or non-removable (or fixed) media. Where appropriate, memory 520 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 520 is non-volatile solid-state memory.

[0129] Memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Therefore, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to the first aspect of this disclosure.

[0130] The processor 510 reads and executes computer program instructions stored in the memory 520 to implement any of the intelligent online monitoring methods for municipal wastewater COD based on ultraviolet spectroscopy in the above embodiments.

[0131] In one example, the electronic device may also include a communication interface 530 and a bus 540. Wherein, such as Figure 5 As shown, the processor 510, memory 520, and communication interface 530 are connected through bus 540 and complete communication with each other.

[0132] The communication interface 530 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.

[0133] Bus 540 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 540 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.

[0134] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above-described intelligent online monitoring methods for municipal wastewater COD based on ultraviolet spectroscopy.

[0135] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory, random access memory, portable hard drives, magnetic disks, or optical disks.

[0136] Embodiments of the present invention also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the embodiments of the intelligent online monitoring method for municipal wastewater COD based on ultraviolet spectroscopy.

[0137] Those skilled in the art will further 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, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. 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 implementations should not be considered beyond the scope of this invention.

[0138] The above provides a detailed description of the intelligent online monitoring method and system for municipal wastewater COD based on ultraviolet spectroscopy provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of this application.

Claims

1. A method for intelligent online monitoring of COD in municipal wastewater based on ultraviolet spectroscopy, characterized in that, include: Obtain the COD sequence of the target detection point within the preset target time window and the absorbance vector of the current detected water body in the ultraviolet band; Discrete difference calculation is performed on the absorbance vector to determine multiple local maxima and local minima to construct an extreme value vector. The COD sequence is then fitted using the least squares method within multiple preset time windows to obtain the slope vector. Calculate the Euclidean distance between each local extremum in the extremum vector and each local slope in the slope vector to construct a cumulative distance matrix. Align the extremum vector and the slope vector with the time axis according to the index relationship of the shortest path in the cumulative distance matrix to obtain a joint state vector. Based on multiple historical joint state vectors in a preset data update buffer pool, the total covariance matrix of the historical joint state vectors is calculated, and the Mahalanobis distance between the joint state vector and each historical joint state vector is calculated based on the inverse matrix of the total covariance matrix. Each historical joint state vector corresponds to a true COD value. Substituting the Mahalanobis distance into a preset Gaussian kernel density function, the probability distribution density corresponding to each historical joint state vector is calculated. All probability distribution densities are normalized to obtain multiple discrete weights. The discrete weights are used to perform a weighted summation of the COD true values ​​corresponding to the corresponding historical joint state vectors to obtain the current COD concentration value.

2. The method of claim 1, wherein, Discrete difference calculation is performed on the absorbance vector to determine multiple local maxima and local minima to construct an extremum vector. The COD sequence is then fitted using least squares within multiple preset time windows to obtain a slope vector, including: Based on the difference between the values ​​of the absorbance vector at the next time step and the previous time step, a difference sequence is constructed; Determine the sign of each difference value in the difference sequence, and when the sign changes from positive to negative or from positive to zero and then back to negative, take the position of the positive or zero value as the first position, and when the sign changes from negative to positive or from negative to zero and then back to positive, take the position of the negative or zero value as the second position. The values ​​corresponding to each first position in the absorbance vector are taken as local maxima, and the values ​​corresponding to each second position are taken as local minima. After arranging all local maxima and all local minima in chronological order, they are normalized to obtain the extreme value vector. Based on a preset time window, the COD sequence is divided into multiple local sequences. The covariance of each local sequence and the set of time points within the corresponding time window, as well as the variance of the set of time points, are calculated. The covariance is divided by the corresponding variance to obtain the local slope of each local sequence. All local slopes are arranged in chronological order and then normalized to obtain a slope vector.

3. The method of claim 1, wherein, Calculating the Euclidean distance between each local extremum in the extremum vector and each local slope in the slope vector to construct a cumulative distance matrix includes: The absolute value of the difference between each local extremum in the extremum vector and each local slope in the slope vector is taken as the Euclidean distance. An initial matrix is ​​constructed with the number of local extrema as the number of rows and the number of local slopes as the number of columns. All Euclidean distances are then filled into the corresponding nodes of the initial matrix. Traverse each node in the initial matrix from top left to bottom right, and take the minimum value among the value of the left node, the value of the top node, and the value of the top left node of the current node as the target value of the current node. Based on the target value corresponding to the current node, the Euclidean distance of the current node is updated to obtain the updated Euclidean distance. This process is repeated until all nodes have been traversed and their updated Euclidean distances are obtained, resulting in the cumulative distance matrix.

4. The method of claim 1, wherein, Based on the index relationship of the shortest path in the cumulative distance matrix, the extreme value vector and the slope vector are aligned along the time axis to obtain a joint state vector, including: The bottom right node of the cumulative distance matrix is ​​determined as the endpoint; Starting from the endpoint, compare the values ​​of the left, top, and top-left nodes of the current node, and take the node with the smallest value as the backtracking node. Then, using the backtracking node as the current node, repeatedly compare the values ​​of the left, top, and top-left nodes of the current node until the top-left node of the cumulative distance matrix is ​​reached. Based on the endpoint and the backtracking node, determine the shortest path. Based on the row index of each node on the shortest path, the corresponding local extremum is determined in the extremum vector, and based on the column index of each node on the shortest path, the corresponding local slope is determined in the slope vector. Pair the local extrema and local slope corresponding to the same node into a joint feature group. Arrange the joint feature groups corresponding to all nodes on the shortest path according to the path order of the shortest path to obtain the joint state vector.

5. The method of claim 1, wherein, Based on multiple historical joint state vectors in a preset data update buffer pool, the total covariance matrix of the historical joint state vectors is calculated, including: The mean vector is obtained by summing all historical joint state vectors in the preset data update buffer pool and dividing by the total number of all historical joint state vectors. The historical measured values ​​stored in the preset data update buffer pool associated with each historical joint state vector are used as the true COD value corresponding to each historical joint state vector. Based on the difference between each historical joint state vector and the mean vector, the deviation vector corresponding to each historical joint state vector is obtained; Perform matrix multiplication on each deviation vector and its corresponding transpose vector to obtain the deviation matrix corresponding to each historical joint state vector. Perform matrix addition on all deviation matrices to obtain a sum matrix. Calculate the quotient of each value in the sum matrix with the target quantity to construct the total covariance matrix. The target quantity is the total number of vectors minus one.

6. The method of claim 5, wherein, The Mahalanobis distance between the joint state vector and each historical joint state vector is calculated based on the inverse of the total covariance matrix, including: The joint state vector is subtracted from each historical joint state vector to obtain the difference vector corresponding to each historical joint state vector. Multiply the transpose of each difference vector with the inverse of the total covariance matrix to obtain the intermediate vector corresponding to each historical joint state vector. Perform matrix multiplication on each intermediate vector and its corresponding difference vector to obtain a scalar value. Use the square root of each scalar value as the Mahalanobis distance between the joint state vector and the corresponding historical joint state vector.

7. The method of claim 1, wherein, Substituting the Mahalanobis distance into a preset Gaussian kernel density function, the probability distribution density corresponding to each historical joint state vector is calculated. All probability distribution densities are normalized to obtain multiple discrete weights. These discrete weights are then used to perform a weighted summation of the actual COD values ​​corresponding to the respective historical joint state vectors to obtain the current COD concentration value, including: Substituting the Mahalanobis distance into a preset Gaussian kernel density function, the exponential term corresponding to each historical joint state vector is calculated. The Gaussian kernel density function indicates that there is a negatively correlated exponential mapping relationship between the Mahalanobis distance and the probability distribution density corresponding to each historical joint state vector. Calculate the power function value with the natural constant as the base and each exponent as the exponent to obtain the probability distribution density corresponding to each historical joint state vector; The sum of all probability distribution densities is obtained by summing the densities. The quotient of each probability distribution density to the sum of densities is calculated to obtain the discrete weights corresponding to each historical joint state vector. The current COD concentration value is obtained by accumulating the product of each discrete weight and the corresponding historical joint state vector associated with the true COD value.

8. A municipal wastewater COD intelligent online monitoring system based on ultraviolet spectroscopy, characterized in that, include: The acquisition module is used to acquire the COD sequence of the target detection point within a preset target time window and the absorbance vector of the current detection water body in the ultraviolet band. The determination module is used to perform discrete difference calculation on the absorbance vector, determine multiple local maxima and local minima to construct an extreme value vector, and perform least squares fitting on the COD sequence within multiple preset time windows to obtain a slope vector. The calculation module is used to calculate the Euclidean distance between each local extremum in the extremum vector and each local slope in the slope vector to construct a cumulative distance matrix. According to the index relationship of the shortest path in the cumulative distance matrix, the extremum vector and the slope vector are aligned on the time axis to obtain a joint state vector. The calculation module is also used to update multiple historical joint state vectors in the preset data update buffer pool, calculate the total covariance matrix of the historical joint state vectors, and calculate the Mahalanobis distance between the joint state vector and each historical joint state vector based on the inverse matrix of the total covariance matrix, with each historical joint state vector corresponding to a true COD value. The calculation module is also used to substitute the Mahalanobis distance into a preset Gaussian kernel density function to calculate the probability distribution density corresponding to each historical joint state vector, normalize all probability distribution densities to obtain multiple discrete weights, and use the discrete weights to perform a weighted summation of the COD true values ​​corresponding to the corresponding historical joint state vectors to obtain the current COD concentration value.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the steps of the intelligent online monitoring method for municipal wastewater COD based on ultraviolet spectroscopy as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, enables the implementation of the intelligent online monitoring method for municipal wastewater COD based on ultraviolet spectroscopy as described in any one of claims 1 to 7.