A method and system for online detection of river water quality
By calculating the degree to which the suspended matter content data in the river is affected by rainfall and iteratively adjusting the abnormal upper and lower limits of the box plot, the problem of inaccuracy in online detection of river water quality during heavy rain periods is solved, and the accuracy and speed of water quality analysis are improved.
Patent Information
- Application Number
- CN202411132441.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-08-19
AI Technical Summary
Existing online river water quality detection methods are affected by a variety of interference factors during heavy rain or rainstorm weather, resulting in inaccurate water quality analysis and difficulty in effectively identifying water quality anomalies and predicting trends.
By obtaining the suspended solids content data in the river, the number of rainfall areas, the amount of rainfall, and the distance between the rainfall area and the detection location, calculate the degree to which the suspended solids content data is affected by rainfall, adjust the abnormal upper and lower limits of the box plot, and iteratively calculate the final abnormal data, reducing the impact of unstable data and improving the accuracy of water quality detection.
It effectively improves the analysis accuracy of river water quality data, avoids misjudgment of short-term fluctuations as abnormal data, and improves the speed and accuracy of water quality abnormality analysis.
Smart Images

Figure CN118655286B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to an online detection method and system for river water quality. Background Art
[0002] Rivers are not only an important part of the ecosystem, but also play an important role in maintaining natural balance and protecting biodiversity. In addition, many cities rely on rivers for drinking water resources and agricultural and industrial water. The health of river water quality is related to the stability of the ecosystem, human health and socio-economic development. By regularly testing river water quality, water pollution can be discovered and controlled in a timely manner, and it is helpful to evaluate the effectiveness of environmental protection measures and governance programs, so as to maximize the protection and utilization of this precious natural resource. At present, the online detection method of river water quality mainly collects water quality data through relevant sensors, analyzes changes in water quality data, identifies abnormal conditions and predicts water quality change trends. However, water quality monitoring data in actual environments are often affected by a variety of interference factors. For example, heavy rain or rainstorms can cause the river flow rate to increase, which may cause the water quality of the river to change, affecting the analysis of the health of water quality. Summary of the invention
[0003] The present invention provides a river water quality online detection method and system to solve the existing problems.
[0004] The present invention provides a method and system for online detection of river water quality using the following technical solutions:
[0005] An embodiment of the present invention provides a method for online detection of river water quality, the method comprising the following steps:
[0006] Within a preset time period, obtain the suspended matter content data at each moment in the river at the detection location, the number of rainfall areas on the river, the distance between the center of each rainfall area and the detection location, and the rainfall in each rainfall area;
[0007] According to the number of rainfall areas on the river at the time corresponding to each suspended matter content data, the rainfall in each rainfall area, and the distance between the center of each rainfall area and the detection position, the degree of influence of each suspended matter content data on rainfall is obtained; according to the degree of influence of each suspended matter content data on rainfall, the upper quartile, the lower quartile and the length of the box of the box plot corresponding to all suspended matter content data are obtained; according to the upper quartile, the lower quartile and the length of the box of the box plot corresponding to all suspended matter content data, the abnormal upper limit and the abnormal lower limit of the box plot are obtained; according to the abnormal upper limit and the abnormal lower limit of the box plot, the abnormal suspended matter content data in the box plot corresponding to all suspended matter content data are obtained;
[0008] According to the degree of influence of rainfall on each abnormal suspended matter content data, the upper quartile and lower quartile of the box plot corresponding to all suspended matter content data, the abnormal upper and lower limits of the box plot after the first adjustment are obtained; the abnormal upper and lower limits of the box plot after the first adjustment are iteratively adjusted to obtain the abnormal upper and lower limits of the box plot after the final adjustment;
[0009] The river water quality test results are obtained based on the abnormal upper and lower limits of the final adjusted box plot.
[0010] Furthermore, the method of obtaining the degree to which each suspended matter content data is affected by rainfall according to the number of rainfall areas on the river at the corresponding moment of each suspended matter content data, the rainfall in each rainfall area, and the distance between the center of each rainfall area and the detection position includes the following specific steps:
[0011] In the The normalized value of the sum of the ratios of the rainfall in all rainfall areas with the same ordinal value to the distance between the center of the rainfall area and the detection location at the corresponding moment of the suspended matter content data is recorded as The degree to which the suspended matter content data are affected by rainfall.
[0012] Furthermore, the method of obtaining the upper quartile, the lower quartile and the length of the box plot corresponding to all suspended matter content data according to the degree to which each suspended matter content data is affected by rainfall includes the following specific steps:
[0013] The first The inverse of the degree to which the suspended matter content data is affected by rainfall is recorded as The weight of each suspended matter content data in the box plot;
[0014] The sum of the weights of all suspended matter content data in the box plot is The product of the weights of the suspended solids content data contained in the upper quartile and ,in, is a preset first quantity threshold;
[0015] According to the method of obtaining the weight sum of suspended matter content data corresponding to the upper quartile of the box plot, the weight sum of suspended matter content data corresponding to the lower quartile is obtained. ;
[0016] Arrange all suspended matter content data from small to large, and add up the weights of each suspended matter content data in the box plot. When the accumulated sum is greater than When the last accumulated weight is used, the suspended matter content data corresponding to the last accumulated weight is recorded as the lower quartile of the box plot corresponding to all suspended matter content data. ; When the accumulated sum is greater than When the last accumulated weight corresponds to the suspended matter content data, record it as the upper quartile of the box plot corresponding to all suspended matter content data. ;
[0017] The value of the upper quartile minus the lower quartile of the box plot corresponding to all suspended matter content data is recorded as the length of the box corresponding to all suspended matter content data.
[0018] Furthermore, the above method obtains the abnormal upper limit and the abnormal lower limit of the box plot according to the upper quartile, the lower quartile and the length of the box of the box plot corresponding to all the suspended matter content data, and includes the following specific steps:
[0019] Calculate the product of the preset initial box plot abnormal upper and lower limit coefficients and the length of the box corresponding to all suspended matter content data, and record the sum of the upper quartile of the box plot corresponding to all suspended matter content data and the product as the abnormal upper limit of the box plot corresponding to all suspended matter content data;
[0020] The value of the product is subtracted from the lower quartile of the box plot corresponding to all suspended matter content data, and recorded as the abnormal lower limit of the box plot corresponding to all suspended matter content data.
[0021] Furthermore, the above method obtains the abnormal upper and lower limits of the box plot after the first adjustment according to the degree of influence of each abnormal suspended matter content data by rainfall, the upper quartile and the lower quartile of the box plot corresponding to all the suspended matter content data, and includes the following specific steps:
[0022] According to the degree to which each abnormal suspended matter content data is affected by rainfall and the upper and lower limits of the abnormality of the box plot, the possibility that each abnormal suspended matter content data should be normal data is obtained;
[0023] Record the abnormal suspended matter content data whose probability of being normal data is greater than or equal to a preset first judgment threshold as normal data;
[0024] The ratio of the number of normal data to the number of abnormal suspended matter content data is recorded as the degree to which the upper and lower limits of the abnormal box plot need to be expanded for the first adjustment;
[0025] Calculate the product of the preset initial box plot abnormal upper and lower limit adjustment coefficient and the degree to which the box plot abnormal upper and lower limits need to be expanded for the first adjustment, and record the sum of the product and the preset initial box plot abnormal upper and lower limit coefficients as the box plot abnormal upper and lower limit coefficients after the first adjustment;
[0026] According to the upper and lower limit coefficients of the box plot after the first adjustment, the upper quartile and lower quartile of the box plot corresponding to all suspended matter content data, and the length of the box, the upper and lower limits of the box plot after the first adjustment are obtained.
[0027] Furthermore, the method of obtaining the possibility that each abnormal suspended matter content data should be normal data according to the degree of influence of rainfall on each abnormal suspended matter content data and the abnormal upper and lower limits of the box plot includes the following specific steps:
[0028] Calculate the The minimum absolute value of the difference between the abnormal suspended matter content data and the abnormal upper and lower limits of the box plot, and the reciprocal of the minimum value is The normalized value of the product of the degree of influence of rainfall on the abnormal suspended matter content data is recorded as The possibility that abnormal suspended matter content data should be normal data.
[0029] Further, the abnormal upper and lower limits of the box plot after the first adjustment are obtained according to the abnormal upper and lower limit coefficients of the box plot after the first adjustment, the upper quartile, the lower quartile and the length of the box corresponding to all the suspended matter content data, and the specific steps included are as follows:
[0030] Calculate the product of the upper and lower limit coefficients of the box plot after the first adjustment and the length of the box corresponding to all suspended matter content data, and record the sum of the upper quartile of the box plot corresponding to all suspended matter content data and the product as the upper limit of the box plot after the first adjustment;
[0031] The lower quartile of the box plot corresponding to all suspended matter content data minus the value of the product is recorded as the abnormal lower limit of the box plot after the first adjustment.
[0032] Furthermore, the above-mentioned iterative adjustment of the abnormal upper and lower limits of the box plot after the first adjustment to obtain the abnormal upper limit and abnormal lower limit of the box plot after the final adjustment includes the following specific steps:
[0033] According to the abnormal upper limit and the abnormal lower limit of the box plot after the first adjustment, the updated abnormal suspended matter content data in the box plot corresponding to all the suspended matter content data are obtained;
[0034] According to the acquisition method of normal data in abnormal suspended matter content data, updated normal data in updated abnormal suspended matter content data are obtained, and the ratio of the number of updated normal data to the number of updated abnormal suspended matter content data is recorded as the degree to which the upper and lower limits of the abnormal box plot need to be expanded for the second adjustment;
[0035] The sum of the product of the second adjustment coefficient of the upper and lower limits of the abnormal box-whisker plot and the degree to which the upper and lower limits of the abnormal box-whisker plot need to be expanded and the coefficient of the upper and lower limits of the abnormal box-whisker plot after the first adjustment is recorded as the coefficient of the upper and lower limits of the abnormal box-whisker plot after the second adjustment;
[0036] According to the method of obtaining the abnormal upper and lower limits of the box plot after the first adjustment, the abnormal upper and lower limits of the box plot after the second adjustment are obtained by using the abnormal upper and lower limit coefficients of the box plot after the second adjustment;
[0037] By analogy, when the degree of expansion required for adjusting the abnormal upper and lower limits of the box plot at any time is less than or equal to the preset second judgment threshold, the iteration is stopped to obtain the abnormal upper and lower limits of the final adjusted box plot.
[0038] Furthermore, the river water quality test result is obtained according to the abnormal upper limit and abnormal lower limit of the box plot after the final adjustment, and the specific steps include the following:
[0039] According to the abnormal upper limit and the abnormal lower limit of the box plot after final adjustment, the final abnormal suspended matter content data in the box plot corresponding to all suspended matter content data are obtained;
[0040] The minimum absolute value of the difference between each final abnormal suspended matter content data and the abnormal upper limit and the abnormal lower limit of the final adjusted box plot is obtained, and the normalized value of the minimum and the absolute value of the difference between all the final abnormal suspended matter content data and the abnormal upper limit and the abnormal lower limit of the final adjusted box plot is recorded as the abnormal degree of suspended matter content in the river;
[0041] When the abnormal degree of the suspended matter content in the river is greater than or equal to a preset third judgment threshold, it is considered that the abnormal degree of the suspended matter content in the river is relatively large.
[0042] The present invention also proposes a river water quality online detection system, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program stored in the memory to implement the steps of the aforementioned river water quality online detection method.
[0043] The beneficial effects of the technical solution of the present invention are:
[0044] In an embodiment of the present invention, within a preset time period, the suspended matter content data at each moment in the river at the detection position, the number of rainfall areas on the river, the distance between the center of each rainfall area and the detection position, and the rainfall in each rainfall area are obtained; the degree of influence of each suspended matter content data on the rainfall is obtained according to the number of rainfall areas on the river at the corresponding moment of each suspended matter content data, the rainfall in each rainfall area, and the distance between the center of each rainfall area and the detection position; the upper quartile, the lower quartile, and the length of the box of the box plot corresponding to all suspended matter content data are obtained according to the degree of influence of each suspended matter content data on the rainfall; the upper and lower quartiles of the abnormal upper and lower limits of the box plot corresponding to all suspended matter content data are obtained; the abnormal suspended matter content data in the box plot corresponding to all suspended matter content data are obtained according to the abnormal upper and lower limits of the box plot; according to the analysis of the degree of influence of the water quality data on the rainfall, the real river water quality data can have a greater influence on the establishment of the box plot, while the influence of the affected unstable data on it is reduced, which can effectively improve the performance of the box plot on the abnormal water quality data. According to the degree of influence of rainfall on each abnormal suspended matter content data, the upper quartile and lower quartile of the box plot corresponding to all suspended matter content data, the abnormal upper and lower limits of the box plot after the first adjustment are obtained; the abnormal upper and lower limits of the box plot after the first adjustment are iteratively adjusted to obtain the abnormal upper and lower limits of the box plot after the final adjustment; according to the abnormal upper and lower limits of the expanded box plot, it can effectively avoid misjudging some data points that have certain abnormalities in numerical values but do not indicate continuous abnormalities in the river, that is, data points that are affected by rainfall and cause short-term fluctuations in water quality data, as abnormal data, and can effectively improve the accuracy of data abnormality degree analysis. According to the abnormal upper and lower limits of the box plot after the final adjustment, the river water quality detection results are obtained. So far, the present invention analyzes the influence relationship between the expansion degree of the upper and lower limits of the box plot in the historical data and the proportion of water quality data affected by rainfall in the box plot. For the newly monitored data, according to the influence relationship, the degree to which the upper and lower limits of the box plot need to be expanded is directly calculated, which can effectively improve the speed of abnormal analysis of river water quality data. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0046] Figure 1 A flow chart of the steps of an online river water quality detection method of the present invention;
[0047] Figure 2 It is the box plot in this embodiment. DETAILED DESCRIPTION
[0048] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of a river water quality online detection method and system proposed by the present invention, its specific implementation method, structure, characteristics and effects, in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0049] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0050] The specific scheme of a river water quality online detection method and system provided by the present invention is described in detail below with reference to the accompanying drawings.
[0051] See also Figure 1 , which shows a flow chart of the steps of a method for online detection of river water quality provided by an embodiment of the present invention, the method comprising the following steps:
[0052] Step S001: within a preset time period, obtain the suspended matter content data at each moment in the river at the detection location, the number of rainfall areas on the river, the distance between the center of each rainfall area and the detection location, and the rainfall in each rainfall area.
[0053] During a preset time period, sensors are used to obtain the suspended matter content data in the river at each moment, the number of rainfall areas on the river, and the rainfall in each rainfall area, and then obtain the distance from the center of each rainfall area on the river to the detection location at each moment.
[0054] The river water quality detection indicators mainly include the river's pH value, oxygen content, suspended solids concentration, heavy metal concentration, etc., so relevant sensors are set in the river to collect river water quality data, such as pH value monitoring with pH sensor, water oxygen content with dissolved oxygen sensor, heavy metal concentration with heavy metal sensor, etc. Among them, the precipitation data of the detection area is obtained through the Meteorological Bureau, and the collection interval is 1 hour. In this embodiment, the preset time period is 1 week, which is described as an example.
[0055] Step S002: According to the number of rainfall areas on the river at the time corresponding to each suspended matter content data, the rainfall in each rainfall area, and the distance between the center of each rainfall area and the detection position, the degree of influence of each suspended matter content data on the influence of rainfall is obtained; according to the degree of influence of each suspended matter content data on the influence of rainfall, the upper quartile, the lower quartile and the length of the box body of the box plot corresponding to all suspended matter content data are obtained; according to the upper quartile, the lower quartile and the length of the box body of the box plot corresponding to all suspended matter content data, the abnormal upper limit and the abnormal lower limit of the box plot are obtained; according to the abnormal upper limit and the abnormal lower limit of the box plot, the abnormal suspended matter content data in the box plot corresponding to all suspended matter content data are obtained.
[0056] When rainfall occurs upstream of the river water quality detection location, the flow rate of the upstream river will increase, affecting the water quality of the detection location. For example, suspended matter in the upstream of the river may be carried to the detection location by the river, thereby increasing the suspended matter content at the monitoring location. When rainfall occurs near the river water quality detection location, it may also cause changes in river water quality. For example, rainfall brings dissolved organic matter and inorganic nutrients (such as nitrogen and phosphorus) in the soil into the river, increasing the content of organic and inorganic matter in the water. However, the changes in water quality caused by these factors are not stable. The river may also increase the flow rate caused by rainfall, bringing substances from the detection location to other places. Therefore, the greater the degree to which the collected river water quality data is affected by rainfall, the less credible the corresponding water quality data, that is, the smaller its weight is when calculating the box plot parameters.
[0057] Therefore, we first need to calculate the degree to which each river water quality data is affected by rainfall. If the rainfall location is far away from the detection location, the river will be buffered when passing through an area without rainfall, causing the river flow rate to gradually decrease, and part of the material brought from the upstream will be deposited in an area without rainfall. Then, when the river reaches the detection location, the impact on the detection location will be greatly reduced. Therefore, the closer the rainfall location is to the detection location, the greater the impact on the detection location. In addition, the amount of rainfall has different effects on the river flow rate. The greater the rainfall, the faster the river flow rate will be, making it easier for materials in the upstream water to be washed to the detection location. Therefore, the greater the rainfall, the greater the impact on the river water quality data.
[0058] First For example, the first The calculation formula for the degree to which the suspended matter content data is affected by rainfall is:
[0059]
[0060] in, Indicates The degree to which the suspended matter content data is affected by rainfall. Indicates The number of rainfall areas on the river at the time corresponding to each suspended matter content data. Indicates The suspended matter content data corresponds to the first The rainfall in the rainfall area, Indicates The suspended matter content data corresponds to the first The distance between the center of a rainfall area and the detection location. represents the linear normalization function.
[0061] What needs to be explained is: Indicates The suspended matter content data corresponds to the first The distance between the center of the rainfall area and the detection location, It means that the farther the rainfall area is from the detection location, the smaller the impact on the water quality at the detection location. Indicates The number of areas where rainfall occurs on the river at the time corresponding to the suspended matter content data. , it is considered that there is no rainfall at the corresponding time of the data, so the impact degree .
[0062] The greater the impact of rainfall on the suspended matter content data of each river, the more unstable the suspended matter content in the river at the corresponding moment, so the abnormal performance of its data is less credible. Therefore, the greater the impact of rainfall, the smaller its weight in the box plot should be.
[0063] The first The inverse of the degree to which the suspended matter content data is affected by rainfall is recorded as The weight of each suspended matter content data in the box plot.
[0064] The sum of the weights of all suspended matter content data in the box plot is The product of the weights of the suspended solids content data contained in the upper quartile and .
[0065] It should be noted that: the first quantity threshold value preset in this embodiment for , taking this as an example for description.
[0066] According to the method of obtaining the weight sum of the suspended matter content data corresponding to the upper quartile of the box plot, the weight sum of the suspended matter content data corresponding to the median and the lower quartile is obtained respectively. and .
[0067] It should be noted that: the second quantity threshold value preset in this embodiment for , the preset third quantity threshold for . Use and replace , and obtain the weighted sum of the suspended matter content data corresponding to the median and the lower quartile.
[0068] Arrange all suspended matter content data from small to large, and add up the weights of each suspended matter content data in the box plot. When the accumulated sum is greater than When the last accumulated weight is used, the suspended matter content data corresponding to the last accumulated weight is recorded as the lower quartile of the box plot corresponding to all suspended matter content data. ; When the accumulated sum is greater than When the last accumulated weight is used, the suspended matter content data corresponding to the last weight is recorded as the quartile in the box plot corresponding to all suspended matter content data. ; When the accumulated sum is greater than When the last accumulated weight corresponds to the suspended matter content data, record it as the upper quartile of the box plot corresponding to all suspended matter content data. .
[0069] It should be noted that the acquisition of the upper quartile, median and lower quartile of the box plot of the data series arranged from small to large is a well-known technique. Figure 2 As shown, Figure 2 This is a schematic diagram of a box plot. A box plot is a statistical chart used to display data distribution. It consists of five numerical points: minimum value (lower limit), lower quartile, , median , upper quartile and the maximum value (upper limit), and the outliers are the data points in the box plot that exceed the upper and lower limits, which is a well-known technology.
[0070] The value of the upper quartile minus the lower quartile of the box plot corresponding to all suspended matter content data is recorded as the length of the box corresponding to all suspended matter content data.
[0071] The calculation formula for the abnormal upper and lower limits of the box plot is:
[0072]
[0073]
[0074] in, represents the abnormal upper limit of the box plot, represents the abnormal lower limit of the box plot, Indicates the upper quartile of the box plot corresponding to all suspended matter content data. Indicates the length of the box corresponding to all suspended matter content data. Represents the lower quartile of the box plot corresponding to all suspended matter content data. To preset the upper and lower abnormal limit coefficients of the initial box plot.
[0075] What needs to be explained is: The initial box plot abnormal upper and lower limit coefficients are preset to calculate the range of normal data. In this embodiment, the initial box plot abnormal upper and lower limit coefficients are preset The value is 1.5, and this example is used for description.
[0076] According to the abnormal upper limit and the abnormal lower limit of the box plot, the abnormal suspended matter content data and the normal data in the box plot corresponding to all the suspended matter content data are obtained.
[0077] Step S003: According to the degree of influence of rainfall on each abnormal suspended matter content data, the upper quartile and the lower quartile of the box plot corresponding to all the suspended matter content data, the abnormal upper and lower limits of the box plot after the first adjustment are obtained; the abnormal upper and lower limits of the box plot after the first adjustment are iteratively adjusted to obtain the abnormal upper and lower limits of the box plot after the final adjustment.
[0078] Since the weight of data affected by rainfall is reduced, a large amount of data affected by rainfall may be considered abnormal data. However, it is possible that the suspended matter upstream is washed to the detection location at the detection time, causing some suspended matter content data to rise briefly, and then these suspended matter is washed away. The data abnormality at this time does not indicate that the water quality in the river area is abnormal, so it is necessary to adjust the upper and lower limits of the box plot so that the upper and lower limits can more accurately reflect the water quality abnormalities.
[0079] The greater the impact of rainfall on the data, the greater the river flow rate at the detection location, so the more likely the above data will change temporarily. In addition, due to the uneven height of the riverbed and the original position of the suspended matter, the suspended matter in the upstream will not rush to the detection location at the same time, so the suspended matter content data at the detection location will not suddenly change significantly, that is, the suspended matter content data in the box plot is less abnormal.
[0080] Therefore, according to the degree to which the suspended matter content data is affected by rainfall and the degree of abnormality in the box plot, the possibility that the abnormal suspended matter content data in the box plot corresponding to all suspended matter content data is normal data is calculated.
[0081] First For example, the abnormal suspended matter content data The calculation formula for the probability that an abnormal suspended matter content data should be normal data is:
[0082]
[0083] in, Indicates The possibility that the abnormal suspended matter content data should be normal data, Indicates The degree to which the abnormal suspended matter content data is affected by rainfall, Indicates The minimum absolute value of the difference between the abnormal suspended matter content data and the abnormal upper and lower limits of the box plot, represents the linear normalization function.
[0084] What needs to be explained is: Indicates The minimum absolute value of the difference between the abnormal suspended matter content data and the abnormal upper and lower limits of the box plot, It means that the smaller the difference is, that is, the closer the data is to the upper and lower limits, the more likely it is normal data.
[0085] A first judgment threshold is preset, and abnormal suspended matter content data whose probability of being normal data is greater than or equal to the preset first judgment threshold is recorded as normal data.
[0086] It should be noted that: the first judgment threshold preset in this embodiment is 0.5, which is used as an example for description. When there is no normal data, the abnormal upper limit and abnormal lower limit of the box plot at this time are set to the abnormal upper limit and abnormal lower limit of the box plot after the final adjustment.
[0087] In order to include the suspended matter content data that is relatively abnormal in value but should be normal data into the upper and lower limits of the box plot, it is necessary to adjust the upper and lower limits of the box plot according to the proportion of the number of data that should be normal in the abnormal data of the current box plot. The larger the proportion, the greater the degree to which the upper and lower limits need to be expanded.
[0088] The ratio of the number of normal data to the number of abnormal suspended matter content data (the number of abnormal suspended matter content data before removing the normal data from the abnormal suspended matter content data) is recorded as the degree to which the upper and lower limits of the abnormal box plot need to be expanded for the first adjustment.
[0089] The calculation formula for the coefficients of the adjusted upper and lower limits of the box plot is:
[0090]
[0091] in, It represents the upper and lower limit coefficients of the abnormal box plot after the first adjustment. Indicates the preset initial box plot abnormal upper and lower limit coefficients, Indicates the preset initial box plot abnormal upper and lower limit adjustment coefficients, Indicates the extent to which the upper and lower limits of the box plot need to be expanded for the first adjustment.
[0092] It should be noted that: in this embodiment , taking this as an example for description.
[0093] The calculation formula for the abnormal upper and lower limits of the box plot after the first adjustment is:
[0094]
[0095]
[0096] in, represents the upper limit of the abnormal box plot after the first adjustment, Indicates the upper quartile of the box plot corresponding to all suspended matter content data. Indicates the upper and lower limit coefficients of the box plot after the first adjustment. Indicates the length of the box corresponding to all suspended matter content data. It represents the lower limit of the abnormal box plot after the first adjustment. Represents the lower quartile of the box plot corresponding to all suspended matter content data.
[0097] According to the abnormal upper limit and the abnormal lower limit of the box plot after the first adjustment, the updated abnormal suspended matter content data in the box plot corresponding to all suspended matter content data are obtained.
[0098] According to the method of obtaining normal data in the abnormal suspended matter content data, the updated normal data in the updated abnormal suspended matter content data are obtained, and the ratio of the number of updated normal data to the number of updated abnormal suspended matter content data (the number of updated abnormal suspended matter content data before excluding the updated normal data in the updated abnormal suspended matter content data) is recorded as the degree of expansion required for the second adjustment of the upper and lower limits of the box plot abnormality.
[0099] The product of the degree to which the upper and lower limits of the second adjustment of the box plot abnormality need to be expanded and the preset initial box plot abnormality upper and lower limit adjustment coefficient is recorded as the second box plot abnormality upper and lower limit adjustment coefficient.
[0100] The calculation formula for the upper and lower limit coefficients of the box plot after the second adjustment is:
[0101]
[0102] in, It represents the upper and lower limit coefficients of the abnormal box plot after the second adjustment. Indicates the upper and lower limit adjustment coefficients of the second box plot abnormality. Indicates the extent to which the upper and lower limits of the box plot need to be expanded for the second adjustment.
[0103] Then the calculation formula for the abnormal upper and lower limits of the second adjusted box plot is:
[0104]
[0105]
[0106] in, represents the upper abnormal limit of the second adjusted box plot, Indicates the upper quartile of the box plot corresponding to all suspended matter content data. It represents the upper and lower limit coefficients of the abnormal box plot after the second adjustment. Indicates the length of the box corresponding to all suspended matter content data. It represents the lower limit of the abnormal box plot after the second adjustment. Represents the lower quartile of the box plot corresponding to all suspended matter content data.
[0107] And so on, until the degree of expansion required for any adjustment of the abnormal upper and lower limits of the box plot is less than or equal to the preset second judgment threshold, the iteration is stopped to obtain the abnormal upper and lower limits of the final adjusted box plot, and the final abnormal suspended matter content data in the box plot corresponding to all suspended matter content data are obtained.
[0108] What needs to be explained is: the ratio of the final adjusted box plot anomaly upper and lower limit coefficients to the preset initial box plot anomaly upper and lower limit coefficients is recorded as the adjustment degree of the box plot anomaly upper and lower limits. The number of suspended matter content data affected by rainfall whose degree of influence is greater than or equal to the preset third threshold is recorded as the proportion of data affected by rainfall. Thus, according to the above method, within several weeks, the adjustment degree of the box plot anomaly upper and lower limits and the proportion of data affected by rainfall corresponding to each week are obtained, and a scatter plot is constructed in chronological order, wherein the horizontal and vertical directions are the adjustment degree of the box plot anomaly upper and lower limits and the proportion of data affected by rainfall corresponding to each week, and the least squares method is used to fit it into a curve, and the adjustment degree of the subsequent box plot anomaly upper and lower limits is predicted, thereby obtaining the box plot anomaly upper and lower limit coefficients after the last adjustment each week, so that there is no need to repeat the above analysis for the weekly data.
[0109] Step S004: Obtain the river water quality detection result according to the abnormal upper limit and abnormal lower limit of the box plot after final adjustment.
[0110] The calculation formula for the abnormal degree of suspended matter content in the river is:
[0111]
[0112] in, Indicates the abnormal degree of suspended matter content in the river. Indicates the number of final abnormal suspended matter content data. Indicates The minimum absolute value of the difference between the final abnormal suspended matter content data and the abnormal upper and lower limits of the final adjusted box plot, represents the linear normalization function.
[0113] A third judgment threshold is preset. When the abnormal degree of suspended matter content in a river is greater than or equal to the preset third judgment threshold, it is considered that the abnormal degree of suspended matter content in the river is large and timely control measures need to be taken.
[0114] It should be noted that: according to the method for obtaining the abnormal degree of the suspended matter content in the river, the abnormal degree of other indicators of the river water quality detection is obtained. In this embodiment, the third judgment threshold is preset to 0.5, and this is used as an example for description.
[0115] So far, the present invention is completed.
[0116] In summary, in an embodiment of the present invention, within a preset time period, the suspended matter content data at each moment in the river at the detection position, the number of rainfall areas on the river, the distance between the center of each rainfall area and the detection position, and the rainfall in each rainfall area are obtained; according to the number of rainfall areas on the river at the corresponding moment of each suspended matter content data, the rainfall in each rainfall area, and the distance between the center of each rainfall area and the detection position, the degree to which each suspended matter content data is affected by rainfall is obtained; according to the degree to which each suspended matter content data is affected by rainfall, the upper quartile, the lower quartile, and the length of the box corresponding to all suspended matter content data are obtained; according to all suspended matter content data The upper quartile, lower quartile and box length of the corresponding box plot are used to obtain the abnormal upper limit and abnormal lower limit of the box plot; according to the abnormal upper limit and abnormal lower limit of the box plot, the abnormal suspended matter content data in the box plot corresponding to all suspended matter content data are obtained; according to the degree of influence of each abnormal suspended matter content data on rainfall, the upper quartile and lower quartile of the box plot corresponding to all suspended matter content data, the abnormal upper and lower limits of the box plot after the first adjustment are obtained; the abnormal upper and lower limits of the box plot after the first adjustment are iteratively adjusted to obtain the abnormal upper limit and abnormal lower limit of the box plot after the final adjustment; according to the abnormal upper and lower limits of the box plot after the final adjustment, the river water quality detection result is obtained. So far, the present invention analyzes the influence relationship between the expansion degree of the upper and lower limits of the box plot in the historical data and the proportion of the water quality data affected by rainfall in the box plot. For the newly monitored data, according to the influence relationship, the degree to which the upper and lower limits of the box plot need to be expanded is directly calculated, which can effectively improve the speed of abnormal analysis of river water quality data.
[0117] The present invention also provides a river water quality online detection system, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program stored in the memory to implement the steps of the aforementioned river water quality online detection method.
[0118] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for online detection of river water quality, It is characterized in that The method comprises the following steps: Within a preset time period, obtain the suspended matter content data at each moment in the river at the detection location, the number of rainfall areas on the river, the distance between the center of each rainfall area and the detection location, and the rainfall in each rainfall area; According to the number of rainfall areas on the river at the time corresponding to each suspended matter content data, the rainfall in each rainfall area, and the distance between the center of each rainfall area and the detection position, the degree of influence of each suspended matter content data on rainfall is obtained; according to the degree of influence of each suspended matter content data on rainfall, the upper quartile, the lower quartile and the length of the box of the box plot corresponding to all suspended matter content data are obtained; according to the upper quartile, the lower quartile and the length of the box of the box plot corresponding to all suspended matter content data, the abnormal upper limit and the abnormal lower limit of the box plot are obtained; according to the abnormal upper limit and the abnormal lower limit of the box plot, the abnormal suspended matter content data in the box plot corresponding to all suspended matter content data are obtained; According to the degree of influence of rainfall on each abnormal suspended matter content data, the upper quartile and lower quartile of the box plot corresponding to all suspended matter content data, the abnormal upper and lower limits of the box plot after the first adjustment are obtained; the abnormal upper and lower limits of the box plot after the first adjustment are iteratively adjusted to obtain the abnormal upper and lower limits of the box plot after the final adjustment; According to the abnormal upper limit and abnormal lower limit of the final adjusted box plot, the river water quality test results are obtained; The method of obtaining the degree of influence of rainfall on each suspended matter content data according to the number of rainfall areas on the river at the corresponding moment of each suspended matter content data, the rainfall in each rainfall area, and the distance between the center of each rainfall area and the detection position includes the following specific steps: In the The normalized value of the sum of the ratios of the rainfall in all rainfall areas with the same ordinal value to the distance between the center of the rainfall area and the detection location at the corresponding moment of the suspended matter content data is recorded as The degree to which the suspended matter content data are affected by rainfall; The above steps of obtaining the upper quartile, the lower quartile and the length of the box of the box plot corresponding to all suspended matter content data according to the degree to which each suspended matter content data is affected by rainfall include the following: The first The inverse of the degree to which the suspended matter content data is affected by rainfall is recorded as The weight of each suspended matter content data in the box plot; The sum of the weights of all suspended matter content data in the box plot is The product of the weights of the suspended solids content data contained in the upper quartile and ,in, is a preset first quantity threshold; According to the method of obtaining the weight sum of the suspended matter content data corresponding to the upper quartile of the box plot, the weight sum of the suspended matter content data corresponding to the lower quartile is obtained. ; Arrange all suspended matter content data from small to large, and add up the weights of each suspended matter content data in the box plot. When the accumulated sum is greater than When the last accumulated weight is used, the suspended matter content data corresponding to the last accumulated weight is recorded as the lower quartile of the box plot corresponding to all suspended matter content data. ; When the accumulated sum is greater than When the last accumulated weight is used, the suspended matter content data corresponding to the last accumulated weight is recorded as the upper quartile of the box plot corresponding to all suspended matter content data. ; The value of the upper quartile minus the lower quartile of the box plot corresponding to all suspended matter content data is recorded as the length of the box corresponding to all suspended matter content data; The specific steps of obtaining the river water quality test result according to the abnormal upper limit and abnormal lower limit of the box plot after the final adjustment are as follows: According to the abnormal upper limit and the abnormal lower limit of the box plot after final adjustment, the final abnormal suspended matter content data in the box plot corresponding to all suspended matter content data are obtained; The minimum absolute value of the difference between each final abnormal suspended matter content data and the abnormal upper limit and the abnormal lower limit of the final adjusted box plot is obtained, and the normalized value of the minimum and the absolute value of the difference between all the final abnormal suspended matter content data and the abnormal upper limit and the abnormal lower limit of the final adjusted box plot is recorded as the abnormal degree of suspended matter content in the river; When the abnormal degree of the suspended matter content in the river is greater than or equal to a preset third judgment threshold, it is considered that the abnormal degree of the suspended matter content in the river is relatively large.
2. According to the method for online detection of river water quality as claimed in claim 1, It is characterized in that The above method obtains the abnormal upper limit and abnormal lower limit of the box plot according to the upper quartile, lower quartile and box length of the box plot corresponding to all suspended matter content data, and the specific steps include the following: Calculate the product of the preset initial box plot abnormal upper and lower limit coefficients and the length of the box corresponding to all suspended matter content data, and record the sum of the upper quartile of the box plot corresponding to all suspended matter content data and the product as the abnormal upper limit of the box plot corresponding to all suspended matter content data; The value of the product is subtracted from the lower quartile of the box plot corresponding to all suspended matter content data, and recorded as the abnormal lower limit of the box plot corresponding to all suspended matter content data.
3. According to the method for online detection of river water quality as claimed in claim 1, It is characterized in that The above method obtains the abnormal upper and lower limits of the box plot after the first adjustment according to the degree of influence of each abnormal suspended matter content data by rainfall, the upper quartile and the lower quartile of the box plot corresponding to all the suspended matter content data, and includes the following specific steps: According to the degree of influence of rainfall on each abnormal suspended matter content data and the upper and lower limits of the abnormality of the box plot, the possibility that each abnormal suspended matter content data should be normal data is obtained; Record the abnormal suspended matter content data whose probability of being normal data is greater than or equal to a preset first judgment threshold as normal data; The ratio of the number of normal data to the number of abnormal suspended matter content data is recorded as the degree to which the upper and lower limits of the abnormal box plot need to be expanded for the first adjustment; Calculate the product of the preset initial box plot abnormal upper and lower limit adjustment coefficient and the degree to which the box plot abnormal upper and lower limits need to be expanded for the first adjustment, and record the sum of the product and the preset initial box plot abnormal upper and lower limit coefficients as the box plot abnormal upper and lower limit coefficients after the first adjustment; According to the upper and lower limit coefficients of the box plot after the first adjustment, the upper quartile and lower quartile of the box plot corresponding to all suspended matter content data, and the length of the box, the upper and lower limits of the box plot after the first adjustment are obtained.
4. According to the method for online detection of river water quality as claimed in claim 3, It is characterized in that The possibility that each abnormal suspended matter content data should be normal data is obtained according to the degree of influence of each abnormal suspended matter content data by rainfall and the abnormal upper and lower limits of the box plot, including the following specific steps: Calculate the The minimum absolute value of the difference between the abnormal suspended matter content data and the abnormal upper and lower limits of the box plot, and the reciprocal of the minimum value is calculated. The normalized value of the product of the degree of influence of rainfall on the abnormal suspended matter content data is recorded as The possibility that abnormal suspended matter content data should be normal data.
5. According to the method for online detection of river water quality as claimed in claim 3, It is characterized in that The above method obtains the abnormal upper and lower limits of the box plot after the first adjustment according to the abnormal upper and lower limit coefficients of the box plot after the first adjustment, the upper quartile, the lower quartile and the length of the box corresponding to all suspended matter content data, and the abnormal upper and lower limits of the box plot after the first adjustment, including the following specific steps: Calculate the product of the upper and lower limit coefficients of the box plot after the first adjustment and the length of the box corresponding to all suspended matter content data, and record the sum of the upper quartile of the box plot corresponding to all suspended matter content data and the product as the upper limit of the box plot after the first adjustment; The lower quartile of the box plot corresponding to all suspended matter content data minus the value of the product is recorded as the abnormal lower limit of the box plot after the first adjustment.
6. According to the method for online detection of river water quality as claimed in claim 3, It is characterized in that The iterative adjustment of the abnormal upper and lower limits of the box plot after the first adjustment to obtain the abnormal upper limit and abnormal lower limit of the box plot after the final adjustment includes the following specific steps: According to the abnormal upper limit and the abnormal lower limit of the box plot after the first adjustment, the updated abnormal suspended matter content data in the box plot corresponding to all the suspended matter content data are obtained; According to the acquisition method of normal data in abnormal suspended matter content data, updated normal data in updated abnormal suspended matter content data are obtained, and the ratio of the number of updated normal data to the number of updated abnormal suspended matter content data is recorded as the degree to which the upper and lower limits of the abnormal box plot need to be expanded for the second adjustment; The sum of the product of the second adjustment coefficient of the upper and lower limits of the abnormal box-whisker plot and the degree to which the upper and lower limits of the abnormal box-whisker plot need to be expanded and the coefficient of the upper and lower limits of the abnormal box-whisker plot after the first adjustment is recorded as the coefficient of the upper and lower limits of the abnormal box-whisker plot after the second adjustment; According to the method of obtaining the abnormal upper and lower limits of the box plot after the first adjustment, the abnormal upper and lower limits of the box plot after the second adjustment are obtained by using the abnormal upper and lower limit coefficients of the box plot after the second adjustment; By analogy, when the degree of expansion required for adjusting the upper and lower limits of the box plot at any time is less than or equal to the preset second judgment threshold, the iteration is stopped to obtain the abnormal upper and lower limits of the box plot after the final adjustment.
7. A river water quality online detection system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the computer program is executed by a processor, the steps of an online river water quality detection method as described in any one of claims 1 to 6 are implemented.
