Water quality testing method, equipment, product and medium

By establishing a standard sample database and dynamically adjusting decision parameters, the problem that a single standard curve is difficult to adapt to complex water samples was solved, achieving high precision and adaptive fitting in water quality measurement, and improving the accuracy and efficiency of detection.

CN121632995APending Publication Date: 2026-03-10SHANGHAI YOKE INSTR CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-06
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

In existing water quality testing technologies, a single, fixed standard curve is difficult to adapt to the complex and variable characteristics of water samples, resulting in poor accuracy of measurement results in different concentration ranges, especially with large deviations in concentration ranges.

Method used

By establishing a standard sample database, selecting multiple fitting curve types and choosing the initial curve type based on historical fitting accuracy, and dynamically adjusting decision parameters and curve types until the optimal fitting curve is found, an adaptive fitting strategy is achieved by combining wavelength selection coefficient and goodness-of-fit threshold.

Benefits of technology

It improves the accuracy of water quality measurements, ensures the precision of measurement results in different concentration ranges, reduces operational errors and costs, and enhances the adaptability and reliability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121632995A_ABST
    Figure CN121632995A_ABST
Patent Text Reader

Abstract

A water quality testing method, device, product and medium relate to the field of water quality detection, and the method comprises the following steps: obtaining a database containing absorbance data of standard samples with different concentrations, and establishing a type set comprising linear, index and logarithmic fitting curves; selecting an initial curve type based on historical fitting precision, and establishing decision parameters including a wavelength selection coefficient and a goodness-of-fit threshold; performing fitting operation according to the decision parameter to obtain a first fitting result and calculating a relative error; when the error exceeds a preset range, adjusting parameters and trying other curve types until the requirements are met, and obtaining a target fitting curve; and substituting absorbance data of a water sample to be detected into the target fitting curve to obtain a water quality parameter concentration value. By implementing the method, the measurement accuracy of water samples in different concentration ranges can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of water quality detection, and in particular to a water quality testing method, device, product and medium. BACKGROUND

[0002] With the continuous improvement of environmental protection requirements, water quality monitoring plays an increasingly important role in industrial production and environmental protection. The accurate determination of water quality parameters is directly related to the reliability of water quality monitoring. The use of spectrophotometry for water quality detection is widely used due to its simple operation and wide application range.

[0003] In existing water quality detection technology, a single fixed standard curve method is usually used for water quality parameter determination. This method first prepares a series of standard solutions with known concentrations, measures the absorbance values, establishes a standard curve between absorbance and concentration, and then substitutes the absorbance value of the sample to be measured into the standard curve to calculate the concentration value. Detection personnel often choose a certain way between linear fitting or exponential fitting to establish a standard curve based on experience.

[0004] However, due to the complexity of actual water samples, different water samples may exhibit different absorbance characteristics in different concentration ranges, and a single fixed standard curve is often difficult to adapt to such changes. Especially when measuring a large span of concentration range, the fixed fitting method is prone to large measurement deviation in certain concentration intervals, affecting the accuracy of the measurement results. SUMMARY

[0005] The present application provides a water quality testing method, device, product and medium for improving the measurement accuracy of water samples with different concentration ranges.

[0006] In a first aspect, the present application provides a water quality testing method applied to a water quality testing device, the method comprising: obtaining a standard sample database and establishing a curve type set, the standard sample database comprising absorbance data and corresponding actual concentration values of standard samples at different concentrations, and the curve type set comprising a linear fitting curve, an exponential fitting curve and a logarithmic fitting curve; selecting an initial curve type from the curve type set based on the historical fitting accuracy of the standard samples, and establishing a decision parameter according to the historical fitting accuracy, the decision parameter comprising a wavelength selection coefficient and a fitting goodness threshold; performing fitting operation on the absorbance data of the standard samples according to the decision parameter to obtain a first fitting result, and calculating the relative error value of the first fitting result; when the relative error value exceeds a preset error range, adjusting the decision parameter and sequentially trying other curve types in the curve type set for fitting operation until the relative error value meets the preset range requirement, to obtain a target fitting curve; collecting the absorbance data of the water sample to be measured, and substituting the absorbance data of the water sample to be measured into the target fitting curve to obtain the concentration value of the water quality parameter.

[0007] In the above embodiment, based on the historical fitting accuracy data accumulated in the standard sample database, the initial curve type is intelligently selected and the decision parameter is established, and the parameter and the curve type are dynamically adjusted according to the relative error in the fitting process until the optimal target fitting curve is found. The wavelength selection coefficient highlights the key wavelength contribution and suppresses the influence of interfering wavelengths, and the goodness-of-fit threshold ensures the model quality, so that the measurement result can maintain high accuracy in different concentration intervals, effectively solving the problem that a single fixed standard curve is difficult to adapt to the variable characteristics of complex water samples.

[0008] In combination with some embodiments of the first aspect, in some embodiments, the step of selecting the initial curve type from the curve type set based on the historical fitting accuracy of the standard sample and establishing the decision parameter according to the historical fitting accuracy specifically includes: obtaining a standard sample database, the standard sample database including absorbance data of standard water samples at different concentrations and corresponding actual concentration values; fitting the absorbance data into a linear fitting curve, an exponential fitting curve and a logarithmic fitting curve respectively to obtain the historical fitting accuracy of each curve type; determining the initial curve type according to the size order of the historical fitting accuracy; collecting absorbance data in a preset wavelength range, and dividing the preset wavelength range into a plurality of continuous wavelength intervals according to the numerical distribution of the absorbance data; calculating the trend of the absorbance data in the wavelength interval, and setting the wavelength selection coefficient for each wavelength interval according to the trend; and setting the goodness-of-fit threshold as the weighted average value of the historical fitting accuracy according to the distribution rule of the historical fitting accuracy.

[0009] In the above embodiment, the absorbance data in the standard sample database is analyzed by multi-curve fitting, and the optimal initial curve type is determined according to the size order of the historical fitting accuracy. The trend of the absorbance data in the preset wavelength range is analyzed, the wavelength intervals are scientifically divided and the selection coefficient is set, and the goodness-of-fit threshold is set according to the distribution rule of the historical fitting accuracy. This systematic parameter optimization process establishes a data-driven intelligent decision-making mechanism, so that the fitting strategy can adapt to the spectral characteristics of different types of water samples.

[0010] In combination with some embodiments of the first aspect, in some embodiments, the step of performing fitting operation on the absorbance data of the standard sample according to the decision parameter to obtain the first fitting result specifically includes: obtaining the absorbance data of the standard sample in the wavelength interval; performing weighted calculation on the absorbance data according to the wavelength selection coefficient to obtain the weighted absorbance data; performing fitting operation on the weighted absorbance data in the fitting equation corresponding to the initial curve type; calculating the goodness-of-fit of the fitting operation and comparing the goodness-of-fit with the goodness-of-fit threshold; when the goodness-of-fit is less than the goodness-of-fit threshold, adjusting the wavelength selection coefficient and performing the fitting operation again; repeatedly performing the fitting operation until the goodness-of-fit is greater than the goodness-of-fit threshold, and determining the current fitting result as the first fitting result.

[0011] In the above embodiment, the absorbance data is weighted and calculated according to the wavelength selection coefficient, the characteristic wavelength with large amount of information is highlighted, and the influence of the interference wavelength is suppressed. The weighted data is substituted into the initial curve type for fitting operation, and the quality evaluation standard is established by comparing the fitting goodness with the threshold value. When the fitting goodness does not meet the requirement, the wavelength selection coefficient is adjusted and re-fitted by using the iterative optimization strategy until the fitting result meeting the accuracy requirement is obtained, and the automation optimization of the fitting process is realized.

[0012] In combination with some embodiments of the first aspect, in some embodiments, when the relative error value exceeds the preset error range, the decision parameter is adjusted and other curve types in the curve type set are sequentially tried for fitting operation until the relative error value meets the preset range requirement, and the target fitting curve is obtained. Specifically, the steps include: substituting the absorbance data of the standard sample into the fitting equation corresponding to the first fitting result to calculate a predicted concentration value; calculating the relative error value between the predicted concentration value and the actual concentration value of the standard sample; judging whether the relative error value is within the preset error range; when the relative error value exceeds the preset error range, selecting the next curve type in the curve type set; adjusting the value range of the wavelength selection coefficient and correspondingly modifying the fitting goodness threshold value; repeating the fitting operation until the relative error value is within the preset error range, and determining the current fitting curve as the target fitting curve.

[0013] In the above embodiment, the absorbance data of the standard sample is substituted into the fitting equation to calculate the predicted concentration value, and the fitting effect is evaluated by the relative error. When the error exceeds the preset range, the system intelligently switches to the next candidate model in the curve type set, and adjusts the value range of the wavelength selection coefficient and modifies the fitting goodness threshold value. This multi-level optimization mechanism iterates continuously until the accuracy requirement is met, ensuring that the target fitting curve has reliable prediction ability in the full concentration range.

[0014] In combination with some embodiments of the first aspect, in some embodiments, after the step of collecting the absorbance data of the water sample to be tested, substituting the absorbance data of the water sample to be tested into the target fitting curve to obtain the concentration value of the water quality parameter, the method further includes: establishing a water quality parameter calculation formula library to record the corresponding relationship between the absorbance data of the water sample to be tested in different wavelength intervals and the water quality parameter; generating a calculation formula template according to the corresponding relationship, the calculation formula template including wavelength selection parameters, coefficient adjustment parameters and data processing parameters; using the calculation formula template to perform correction calculation on the concentration value of the water quality parameter; storing the corrected concentration value of the water quality parameter and the calculation formula template in the water quality parameter calculation formula library; and updating the parameters of the calculation formula template according to the historical data in the water quality parameter calculation formula library.

[0015] In the above embodiment, the water quality parameter calculation formula library record is established to record the spectral response law of the sample in different wavelength intervals, and a calculation formula template containing wavelength selection parameters, coefficient adjustment parameters and data processing parameters is generated. The template is used to correct and calculate the measurement results and update the parameters, forming a closed-loop data accumulation and knowledge updating mechanism. Through the parameter optimization driven by historical data, the measurement method can be continuously improved and evolved, and the adaptability of the system is improved.

[0016] In combination with some embodiments of the first aspect, in some embodiments, after the step of substituting the absorbance data of the water sample to be measured into the target fitting curve to obtain the water quality parameter concentration value, the method further comprises: receiving a water quality parameter calculation formula input by a user, applying the water quality parameter calculation formula to the absorbance data of the water sample to be measured to obtain a calculation result, the calculation formula including wavelength combination mode and calculation weight; comparing the difference between the calculation result and the water quality parameter concentration value to evaluate the accuracy result of the water quality parameter calculation formula, and saving the water quality parameter calculation formula to the formula library when the accuracy result meets the preset accuracy condition.

[0017] In the above embodiment, the water quality parameter calculation formula input by the user is applied to actual measurement, and the formula accuracy is evaluated by comparing the difference between the calculation result and the target fitting curve prediction value. When the accuracy result meets the preset condition, the verified formula is saved to the formula library. This open knowledge accumulation mechanism not only ensures the reliability of the new method, but also continuously enriches the measurement method library of the system, improving the expansibility and practical value of the system.

[0018] In combination with some embodiments of the first aspect, in some embodiments, the step of comparing the difference between the calculation result and the water quality parameter concentration value to evaluate the accuracy result of the water quality parameter calculation formula specifically comprises: obtaining a plurality of standard water samples with different concentrations, collecting absorbance data of the standard water samples, applying the water quality parameter calculation formula to the absorbance data of the standard water samples to obtain the calculation concentration value of the standard water samples; calculating the relative error between the calculation concentration value and the actual concentration value of the standard water samples to obtain a first error result; substituting the absorbance data of the standard water samples into the target fitting curve to obtain the fitting concentration value of the standard water samples, calculating the relative error between the fitting concentration value and the actual concentration value to obtain a second error result; comparing the size of the first error result and the second error result, and determining that the accuracy of the water quality parameter calculation formula is higher than that of the target fitting curve when the first error result is smaller than the second error result; and when the proportion of the sample number of the first error result being smaller than the second error result in the standard water samples exceeds a preset proportion, determining that the accuracy result of the water quality parameter calculation formula meets the preset accuracy condition.

[0019] In the above embodiment, a plurality of groups of standard water samples with different concentrations are obtained for comparison and verification, the water quality parameter calculation formula and the target fitting curve are respectively applied for concentration prediction, and the measurement accuracy of the two methods is obtained by calculating the relative error. By comparing the size of the first error result and the second error result, and counting the proportion of the advantage samples, a strict method evaluation mechanism is established. When the proportion exceeds the preset proportion, it is proved that the accuracy of the calculation formula is significantly better than the existing method. Through this quantitative evaluation system, the reliability and advancement of the new method into the library are ensured.

[0020] In a second aspect, the embodiments of the present application provide a water quality testing device, comprising: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors invoke the computer instructions to enable the water quality testing device to perform the method described in the first aspect and any possible implementation manner of the first aspect.

[0021] In a third aspect, the embodiments of the present application provide a computer program product comprising instructions, which, when executed on a water quality testing device, cause the water quality testing device to perform the method described in the first aspect and any possible implementation manner of the first aspect.

[0022] In a fourth aspect, the embodiments of the present application provide a computer readable storage medium comprising instructions, which, when executed on a water quality testing device, cause the water quality testing device to perform the method described in the first aspect and any possible implementation manner of the first aspect.

[0023] It can be understood that the water quality testing device provided in the second aspect, the computer program product provided in the third aspect and the computer storage medium provided in the fourth aspect are all used to execute the method provided in the embodiments of the present application. Therefore, the beneficial effects that can be achieved are referred to the beneficial effects in the corresponding method, which will not be described here.

[0024] The one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: 1. The present application intelligently selects the initial curve type and establishes the decision parameter based on the historical fitting accuracy data accumulated in the standard sample database, dynamically adjusts the parameter and the curve type according to the relative error in the fitting process, and finds the optimal target fitting curve. The wavelength selection coefficient highlights the key wavelength contribution and suppresses the influence of interference wavelengths, and the fitting goodness threshold ensures the model quality, so that the measurement result can maintain high accuracy in different concentration intervals, effectively solving the problem that a single fixed standard curve is difficult to adapt to the variable characteristics of complex water samples.

[0025] 2. This application utilizes multi-curve fitting analysis of absorbance data from a standard sample database to determine the optimal initial curve type based on the historical fitting accuracy ranking. It analyzes the trend of absorbance data changes within a preset wavelength range, scientifically divides wavelength intervals and sets selection coefficients, and statistically analyzes the distribution patterns of historical fitting accuracy to set a goodness threshold. This systematic parameter optimization process establishes a data-driven intelligent decision-making mechanism, enabling the fitting strategy to adapt to the spectral characteristics of different types of water samples.

[0026] 3. This application uses a wavelength selectivity coefficient to weight absorbance data, highlighting characteristic wavelengths with high information content and suppressing the influence of interfering wavelengths. The weighted data is then substituted into the initial curve type for fitting calculations. A quality evaluation standard is established by comparing the goodness of fit with a threshold. When the goodness of fit does not meet the requirements, an iterative optimization strategy is used to adjust the wavelength selectivity coefficient and refit until a fitting result that meets the accuracy requirements is obtained, thus achieving automated optimization of the fitting process. Attached Figure Description

[0027] Figure 1 This is a flowchart illustrating a water quality testing method in an embodiment of this application; Figure 2 This is another schematic diagram of the water quality testing method in the embodiments of this application; Figure 3 This is a schematic diagram of the physical structure of a water quality testing device in the embodiments of this application. Detailed Implementation

[0028] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification of this application, the singular expressions “a,” “an,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to any or all possible combinations including one or more of the listed items.

[0029] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

[0030] To facilitate understanding, the application scenarios of the embodiments of this application are described below.

[0031] A wastewater treatment plant in a large chemical industrial park requires real-time monitoring of both influent and effluent quality to ensure that discharge standards are met. The plant tests various water quality parameters daily, including COD (Chemical Oxygen Demand), ammonia nitrogen, total phosphorus, and total nitrogen. Due to the complex sources of the influent, including industrial wastewater from various processes such as pharmaceuticals, dyeing, and electroplating, the water composition varies greatly, with concentrations ranging from a few milligrams per liter to several thousand milligrams per liter.

[0032] During actual testing, technicians found that the absorbance characteristics of the same pollutant varied greatly across different concentration ranges. For example, when detecting COD, the absorbance of low-concentration samples (0-50 mg / L) showed a good linear relationship with concentration. However, when the concentration increased to 100-500 mg / L, this linear relationship began to deviate, exhibiting certain curvilinear characteristics. Furthermore, when the concentration further increased to above 1000 mg / L, the relationship between absorbance and concentration showed logarithmic characteristics.

[0033] This complex absorption characteristic presents a significant challenge to accurate measurement. Using a single standard curve covering the entire concentration range will inevitably introduce large measurement deviations in certain intervals. Conversely, establishing independent standard curves for each concentration interval is not only extremely labor-intensive, but also makes it difficult to accurately determine which concentration interval an unknown sample belongs to in practice, requiring repeated dilutions and tests, which is both time-consuming and increases sources of error. Furthermore, different batches of reagents, varying ambient temperatures, and instrument aging can all affect the accuracy of the standard curve, necessitating frequent re-creation of the standard curve, significantly increasing detection costs and time.

[0034] The wastewater treatment plant originally used traditional spectrophotometry for water quality testing. The specific procedure was as follows: First, a series of standard solutions with known concentrations (such as COD standard solutions of 0, 10, 25, 50, 100, and 200 mg / L) were prepared. The absorbance values ​​of each standard solution were measured using a spectrophotometer at a specific wavelength (such as 600 nm). Then, based on experience, the testing personnel selected a linear fitting method and used Excel or specialized software on a computer to plot an absorbance-concentration standard curve, obtaining the linear equation y = ax + b.

[0035] In actual testing, the water sample is processed using the same method, and its absorbance value is measured. This absorbance is then substituted into the standard curve equation to calculate the concentration. If the calculated result exceeds the linear range of the standard curve, the sample needs to be diluted and remeasured. For example, if the absorbance of the original water sample in a test was 1.8, far exceeding the linear range of the standard curve (0-1.2), the technician diluted the sample 10 times and remeasured it, obtaining an absorbance of 0.15. The calculated concentration after dilution was 45 mg / L, and the original water sample concentration was 450 mg / L.

[0036] However, this method has significant drawbacks. First, in the high concentration range, the actual absorbance-concentration relationship deviates from linearity, and forcibly using linear fitting will introduce systematic bias. Experimental data shows that when the COD concentration exceeds 200 mg / L, the measurement error using a linear standard curve can reach 15-20%. Second, dilution not only increases workload, but each dilution also introduces additional operational errors, and the cumulative error from multiple dilutions may reach over 10%. Third, for real water samples with complex compositions, single-wavelength measurements are easily affected by interference from other substances, leading to significant deviations in measurement results. Finally, the validity period of the standard curve is limited, requiring periodic re-creation, but when re-creation is needed often relies on the operator's experience and judgment, lacking scientific evaluation standards.

[0037] The water quality testing method of this invention has fundamentally improved the testing process of the wastewater treatment plant. The system first establishes a set of curves including linear, exponential, and logarithmic fitting curves, and then establishes an intelligent decision-making mechanism through historical data analysis.

[0038] In practice, the system automatically retrieved a database of standard samples accumulated over the past year, containing absorbance data for COD standard samples at 50 different concentrations within the 0-2000 mg / L range, measured in the 400-700 nm wavelength range. The system then fitted these data to three different curve types, finding that the R² value for linear fitting was 0.998 for the 0-100 mg / L range, 0.995 for exponential fitting in the 100-500 mg / L range, and 0.993 for logarithmic fitting above 500 mg / L. Based on this historical fitting accuracy data, the system automatically selected linear fitting as the initial curve type and set the wavelength selection coefficient and goodness-of-fit threshold.

[0039] When testing a batch of influent water samples, the system first collects absorbance data in the 400-700nm range. Based on the data distribution characteristics, the wavelength range is divided into three intervals: 400-500nm, 500-600nm, and 600-700nm. The system finds that the absorbance variation trend in the 500-600nm interval is the most stable, and automatically assigns a high wavelength selectivity coefficient (0.6) to this interval, while the coefficients for the other intervals are 0.3 and 0.1, respectively. After weighted calculation, the system uses linear fitting to obtain the first fitting result, but finds that the relative error reaches 12%, exceeding the preset error range of 5%.

[0040] The system then automatically switched to exponential fitting mode and adjusted the wavelength selection coefficient, increasing the weight of the 500-600nm range to 0.7. After refitting, the relative error decreased to 4.2%, meeting the preset requirements. The system determined this exponential fitting curve as the target fitting curve and used it for the detection of subsequent batches of samples. Practical application showed that the COD concentration of this sample was 385mg / L, with a deviation of only 1.8% compared to the detection result using the national standard method (392mg / L).

[0041] To facilitate understanding, the method provided in this implementation will be described in detail below, using the above scenario as an example. Please refer to [link / reference]. Figure 1 This is a flowchart illustrating a water quality testing method in an embodiment of this application.

[0042] S101. Obtain a standard sample database and establish a set of curve types. The standard sample database includes absorbance data of standard samples at different concentrations and the corresponding actual concentration values. The set of curve types includes linear fitting curves, exponential fitting curves and logarithmic fitting curves.

[0043] The standard sample database refers to a structured data set storing optical response data of standard substances of known concentrations under spectrophotometer detection. Absorbance data represents the quantitative value of the degree to which light is absorbed when passing through a solution, usually expressed as a dimensionless optical density value. Actual concentration values ​​are used to represent the true content of the target analyte in the standard sample, generally in mg / L or μg / L. The curve type set refers to a set of mathematical models used to describe the relationship between absorbance and concentration. A linear fitting curve represents a mathematical model in which absorbance and concentration have a linear function relationship (A=kC+b), an exponential fitting curve represents a mathematical model in which absorbance and concentration have an exponential function relationship (A=ae^(bC)+c), and a logarithmic fitting curve represents a mathematical model in which absorbance and concentration have a logarithmic function relationship (A=aln(C)+b). Different concentrations represent a complete concentration gradient range covering from the detection limit to the measurement limit.

[0044] This step is typically performed during the initialization phase of water quality testing equipment or when standard curves need to be updated, primarily in scenarios where measurement benchmarks are established. Specifically, the water quality testing equipment first reads historically accumulated standard sample test records from its built-in memory or external data source. These records contain spectral data of standard samples measured at different time points and under different environmental conditions. The system preprocesses this raw data, including outlier removal, data smoothing, and normalization. Then, the data is grouped and organized according to concentration gradients to form a structured database format. Simultaneously, the system initializes three basic mathematical fitting models, setting initial parameter ranges and constraints for each model. These models serve as the foundational framework for subsequent fitting calculations. By establishing a complete standard sample database and curve type set, the system provides data support and an algorithmic basis for subsequent intelligent curve selection and optimization.

[0045] In some embodiments, the acquisition of a standard sample database and the establishment of a set of curve types can be achieved in various ways: Optionally, the system can build the database through automated batch testing. First, a series of standard solutions with gradient concentrations (e.g., 0, 5, 10, 20, 50, 100, 200, 500, 1000 mg / L) are prepared. Then, an autosampler is used to sequentially feed each concentration of standard solution into the photometer's measurement cell. A full-band scan is performed within the wavelength range of 200-800 nm. Each sample is measured repeatedly 3-5 times, and the average value is taken to improve data reliability. Finally, the measured absorbance spectra are... The data is stored in association with the corresponding nominal concentration values ​​to form a complete database of standard samples. Optionally, the system can establish the database by importing external certified data. First, the system obtains the certification data files of the standard samples from the National Center for Standard Materials or certified laboratories. Then, it parses the concentration-absorbance correspondence table in the data files, converts and organizes the data according to a unified data format, and establishes corresponding curve model templates based on the characteristics of different water quality parameters. Linear and exponential models are established for COD, and logarithmic models are established for heavy metal ions. Finally, the converted data is imported into the system database and an index is created to improve query efficiency. It is understood that other methods, such as cloud data sharing and inter-laboratory data exchange, can also be used to establish and update the database; this is not limited here.

[0046] S102. Select an initial curve type from the set of curve types based on the historical fitting accuracy of standard samples, and establish decision parameters based on the historical fitting accuracy. These decision parameters include wavelength selection coefficient and goodness-of-fit threshold.

[0047] Among them, historical fitting accuracy refers to the quantitative index of the accuracy achieved when fitting standard samples using different curve types in the past. It is usually represented by the coefficient of determination R² or root mean square error RMSE. The initial curve type indicates the type of mathematical model that the system preferentially selects for fitting operations. The decision parameters represent the set of control variables that guide various operations in the fitting process. The wavelength selection coefficient refers to the weight value assigned to absorbance data at different wavelengths, which is used to highlight the contribution of sensitive wavelengths and suppress the influence of interfering wavelengths. The goodness-of-fit threshold represents the critical standard value for judging whether the fitting result is acceptable. It is usually set between 0.95 and 0.99. Selection based on historical fitting accuracy refers to determining the optimal starting strategy based on the statistical analysis results of past fitting effects.

[0048] This step is performed after the database is established and before the actual fitting calculation begins. It is mainly used to formulate an intelligent fitting strategy. Specifically, the system first performs a retrospective analysis of the historical data in the standard sample database. Each set of standard sample data is fitted using three models: linear, exponential, and logarithmic. The goodness-of-fit indices for each model are calculated, such as R² value, sum of squared residuals, and Akaike Information Criterion. Then, these indices are statistically analyzed to identify the curve type that performs best in different concentration ranges. For example, the average R² value of the linear model in the low concentration range is 0.997, and the average R² value of the exponential model in the medium concentration range is 0.995. The system will select the model with the best overall performance as the initial curve type. At the same time, a wavelength selection coefficient is set based on the wavelength sensitivity analysis results of historical data. Wavelengths with high signal-to-noise ratio and good linearity are given higher weights, while wavelengths that are susceptible to interference are given lower weights. The goodness-of-fit threshold is set according to the distribution characteristics of historical fitting accuracy, generally taking the 25th percentile of the historical R² value as the minimum acceptable standard.

[0049] In some embodiments, initial curve selection and decision parameter establishment based on historical accuracy can be achieved in various ways: Optionally, the system can use statistical analysis methods for selection. First, historical data is divided into three intervals—low, medium, and high—according to concentration range. Then, the average goodness of fit and standard deviation of the three curve types are calculated for each interval. The curve type with the highest average goodness of fit and the smallest standard deviation is selected as the preferred model for that interval. The corresponding initial curve type is selected based on the estimated concentration range of the sample to be tested. Simultaneously, the coefficient of variation of absorbance data at each wavelength is calculated, and the reciprocal of the coefficient of variation is normalized and used as the wavelength selection coefficient for fitting. The goodness threshold is set as the historical goodness mean minus one standard deviation. Optionally, the system can use machine learning methods for intelligent selection. First, feature vectors are extracted from historical fitting data, including concentration range, absorbance peak, spectral shape parameters, etc. Then, a classification decision tree model is trained. After inputting the feature vectors, the recommended curve type is output. Simultaneously, principal component analysis is used to identify the key wavelengths that contribute most to the fitting results, and these wavelengths are assigned higher selection coefficients. Other wavelengths are assigned weights decreasing based on their correlation with the key wavelengths. The goodness threshold is dynamically determined using cross-validation to ensure generalization performance on new data. Understandably, other methods such as expert systems and fuzzy logic can also be used to achieve intelligent curve selection and parameter setting; this is not limited here.

[0050] In some embodiments, this step specifically includes: A standard sample database is obtained, which includes absorbance data of standard water samples at different concentrations and their corresponding actual concentration values. The absorbance data is then fitted to linear, exponential, and logarithmic curves to obtain the historical fitting accuracy for each curve type. The initial curve type is determined based on the order of historical fitting accuracy. Absorbance data is collected within a preset wavelength range. The preset wavelength range is divided into multiple continuous wavelength intervals based on the numerical distribution of the absorbance data. The trend of absorbance data change within each wavelength interval is calculated. A wavelength selection coefficient is set for each wavelength interval based on the trend. The distribution pattern of historical fitting accuracy is statistically analyzed, and the goodness-of-fit threshold is set as the weighted average of historical fitting accuracy.

[0051] The standard sample database is a structured data collection storing a large number of water samples of known concentrations and their spectral measurement results. The absorbance data of different concentrations covers a complete concentration gradient from low to high and the corresponding optical response values. The actual concentration values ​​are the true contents determined by standard analytical methods. The linear fitting curve represents the relationship between concentration and absorbance as C=a×A+b, the exponential fitting curve represents the relationship as C=a×e^(b×A)+c, and the logarithmic fitting curve represents the relationship as C=a×ln(A)+b. The historical fitting accuracy is quantified by the coefficient of determination R² or the root mean square error RMSE to measure the fitting effect of each model. The initial curve type is the optimal mathematical model selected according to the accuracy ranking.

[0052] The construction of the standard sample database and the selection of curve types formed the basis for method development. The database contains complete measurement records of multiple batches and types of water samples; for example, it collected data from 500 COD standard samples over the past year, covering concentrations ranging from 5 to 1000 mg / L. Each sample recorded absorbance values ​​at 401 wavelengths within the 200-800 nm range. Data preprocessing included outlier removal, baseline correction, and normalization. Absorbance data at the characteristic wavelength of 254 nm were selected for curve fitting analysis. For the linear model, the least squares method was used to fit COD = 125.3 × A254 + 8.2, with R² = 0.9821 and RMSE = 12.5 mg / L. For the exponential model, nonlinear regression yielded COD = 35.6 × e^(2.15 × A254) - 10.3, with R² = 0.9956 and RMSE = 6.8 mg / L. For the logarithmic model, the fitting result was COD = 185.2 × ln(A254) + 225.6, with R² = 0.9734 and RMSE = 15.3 mg / L. Based on the fitting accuracy, the order was: exponential model (R² = 0.9956) > linear model (R² = 0.9821) > logarithmic model (R² = 0.9734). Therefore, the exponential curve was chosen as the initial curve type. Further analysis of the fitting effect across different concentration ranges revealed that for the low concentration range (<50 mg / L), the average error was 3.2% for the exponential model, 5.8% for the linear model, and 8.5% for the logarithmic model; for the medium concentration range (50-200 mg / L), the average errors were 2.1%, 3.5%, and 6.2%, respectively; and for the high concentration range (>200 mg / L), the average errors were 1.8%, 4.2%, and 9.3%, respectively. This analysis validates the superiority of the exponential model across the entire concentration range.

[0053] The preset wavelength range is the spectral region measured by the instrument, usually 200-800nm. The numerical distribution of absorbance data describes the statistical characteristics of absorption intensity at different wavelengths. The wavelength interval is a sub-region into which the continuous spectrum is divided. The trend indicates the law of change of absorbance with wavelength within the interval, such as monotonically increasing, decreasing, or having peaks and valleys. The wavelength selection coefficient quantifies the contribution weight of each interval to the final result.

[0054] The wavelength range division and coefficient setting are based on a system analysis of spectral characteristics. Absorbance data were collected at 2nm intervals within the 200-800nm ​​range, resulting in 301 data points. The data distribution characteristics were analyzed to identify the positions and intensity variation patterns of absorption peaks. Spectral characteristic points were determined based on the zero points of the first derivative and the extreme points of the second derivative, dividing the entire range into six intervals: 200-280nm (ultraviolet absorption region), 280-380nm (transition region), 380-480nm (blue-violet region), 480-580nm (green region), 580-680nm (red region), and 680-800nm ​​(near-infrared region). Trend indicators for each interval were calculated, including slope k, curvature κ, and coefficient of variation (CV). For example, in the 200-280nm range, an average slope k=0.015 / nm indicates a strong upward trend, a curvature κ=0.0003 indicates approximately linearity, and a coefficient of variation CV=0.35 indicates drastic changes. In the 380-480nm range, k=-0.003 / nm indicates a slow decline, κ=0.0001, and CV=0.12 indicate relative stability. Wavelength selection coefficients are set based on trend analysis, with the principle of assigning greater weight to ranges with drastic changes and high correlation to the target parameters. The coefficients are set as follows: 200-280nm weight 0.35 (strong correlation between UV absorption and organic matter concentration), 280-380nm weight 0.15, 380-480nm weight 0.20 (nitrate interference correction), 480-580nm weight 0.10, 580-680nm weight 0.15 (turbidity compensation), and 680-800nm ​​weight 0.05. Coefficient normalization ensures the sum is 1.0. To verify the rationality of the coefficients, a weighted combination was used to calculate the overall absorbance A_weighted=Σ(wi×Ai), where wi is the weight of the i-th interval and Ai is the average absorbance of that interval. The correlation improvement effect between the weighted result and the actual concentration was then examined.

[0055] The distribution pattern of historical fitting accuracy describes the statistical characteristics of a large number of fitting results, such as mean, variance, and skewness. The goodness-of-fit threshold is the minimum standard for judging the quality of the model. The weighted average is a comprehensive index calculated by taking into account the differences in the importance of accuracy under different conditions.

[0056] Analyzing the historical fitting accuracy distribution and setting reasonable thresholds are key steps in quality control. R² values ​​from the most recent 1000 fitting records were extracted from the database, and an accuracy distribution histogram was constructed. Statistics show that the R² values ​​exhibit a skewed distribution, mainly concentrated in the 0.95-0.99 range, specifically: 0.90-0.92 (5%), 0.92-0.94 (8%), 0.94-0.96 (15%), 0.96-0.97 (22%), 0.97-0.98 (28%), 0.98-0.99 (18%), and 0.99-1.00 (4%). Basic statistics were calculated: arithmetic mean 0.9652, median 0.9685, standard deviation 0.0234, skewness -0.52 (left-skewed), and kurtosis 2.85 (close to normal). Weights are assigned based on the importance of different application scenarios: routine monitoring has a weight of 0.3 (moderate accuracy requirement), compliance testing has a weight of 0.5 (high accuracy requirement), and scientific research analysis has a weight of 0.2 (extremely high accuracy requirement). The corresponding average R² values ​​are 0.9580, 0.9720, and 0.9850, respectively. The weighted average is calculated as: R²_threshold = 0.9580 × 0.3 + 0.9720 × 0.5 + 0.9850 × 0.2 = 0.2874 + 0.4860 + 0.1970 = 0.9704. Considering measurement uncertainty, a conservative estimate is obtained by subtracting 0.5 times the standard deviation from the weighted average: 0.9704 - 0.5 × 0.0234 = 0.9587. The goodness-of-fit threshold is ultimately set to 0.96. A dynamic adjustment mechanism is established, with the accuracy distribution recalculated quarterly and the threshold updated based on the latest data. Model retraining is triggered when the average R² of 10 consecutive fits falls below the threshold. A grading threshold system is established: R²≥0.98 is excellent, 0.96≤R²<0.98 is good, 0.94≤R²<0.96 is acceptable, and R²<0.94 is unacceptable, providing a reference standard for applications with different quality requirements.

[0057] S103. Based on the decision parameters, perform a fitting operation on the absorbance data of the standard sample to obtain the first fitting result, and calculate the relative error value of the first fitting result.

[0058] Among them, decision parameters refer to the set of parameters that control the fitting process, including variables such as wavelength selection coefficient and goodness-of-fit threshold. Fitting operation refers to the calculation process of solving the curve equation parameters through mathematical optimization algorithms, usually using the least squares method or gradient descent method. The first fitting result is used to represent the first fitted curve equation obtained using the initial curve type and decision parameters, including curve parameter values ​​and goodness-of-fit index. The relative error value refers to the relative proportion of the deviation between the fitted predicted value and the actual value, and the calculation formula is |predicted value - actual value| / actual value × 100%. The wavelength selection coefficient represents the weight contribution of different wavelength data in the fitting operation, and the value range is usually between 0 and 1. The goodness-of-fit threshold is used to judge whether the fitting quality meets the standard.

[0059] This step is performed immediately after the initial curve type and decision parameters are determined, and is mainly used to make the first fitting attempt and evaluate the fitting effect. Specifically, the system first weights the multi-wavelength absorbance data according to the wavelength selectivity coefficient. For example, if the absorbance of a standard sample at 450nm, 550nm, and 650nm is 0.5, 0.8, and 0.6 respectively, and the corresponding wavelength selectivity coefficients are 0.2, 0.6, and 0.2, then the weighted comprehensive absorbance is 0.5×0.2+0.8×0.6+0.6×0.2=0.7. Then, a series of concentration-absorbance data are substituted into the initially selected curve equation for parameter fitting. For example, a linear model y=ax+b is used, and the optimal values ​​of slope a and intercept b are obtained by solving the least squares method. After fitting, the coefficient of determination R² and the sum of squared residuals are calculated to evaluate the fitting quality. Next, the fitted equation is used to predict the concentration of each standard sample. The predicted concentration is compared with the actual concentration, and the relative error of each data point is calculated. Finally, the average relative error and the maximum relative error of all data points are calculated as the basis for judging whether the first fitting result meets the requirements.

[0060] In some embodiments, fitting operations and error calculations based on decision parameters can be performed in various ways: Optionally, the system can use weighted least squares for fitting operations. First, a weight matrix W is constructed based on the wavelength selection coefficients, where the diagonal elements are the selection coefficients for each wavelength. Then, an objective function J=(Y-Xβ)ᵀW(Y-Xβ) is established, where Y is the measured absorbance vector, X is the concentration matrix, and β is the parameter vector to be determined. The parameter estimate β=(XᵀWX)⁻¹XᵀW is obtained by solving ∂J / ∂β=0. After fitting, the relative error εᵢ between the predicted concentration Cᵢ' and the actual concentration Cᵢ is calculated point by point: εᵢ = |Cᵢ'-Cᵢ| / Cᵢ×100%. The average relative error ε̄ and standard deviation σ are calculated to determine whether the preset error requirements are met. Optionally, the system can use an iterative optimization method for fitting. First, the initial parameter values ​​and learning rate are set. Then, the predicted value and loss function value under the current parameters are calculated. The loss function can be the mean squared error (MSE) or Huber loss. Then, the parameters are updated according to the gradient information. The parameter update formula is θ. new =θ old -α·∇L(θ), where α is the learning rate and ∇L is the gradient of the loss function. This process is repeated iteratively until the loss function converges or the maximum number of iterations is reached. Finally, the generalization error of the model is calculated using the validation set data, including metrics such as Mean Absolute Percentage Error (MAPE) and Root Mean Square Percentage Error (RMSPE). It is understood that other methods, such as regularized regression and robust regression, can also be used to achieve fitting operations and error evaluation; this is not limited here.

[0061] In some embodiments, this step specifically includes: Obtain absorbance data of standard samples within the wavelength range, and perform weighted calculations on the absorbance data according to the wavelength selection coefficient to obtain weighted absorbance data. Substitute the weighted absorbance data into the fitting equation corresponding to the initial curve type to perform fitting operations, calculate the goodness of fit of the fitting operation, and compare the goodness of fit with the goodness of fit threshold. When the goodness of fit is less than the goodness of fit threshold, adjust the wavelength selection coefficient and perform fitting operations again. Repeat the fitting operation until the goodness of fit is greater than the goodness of fit threshold, and determine the current fitting result as the first fitting result.

[0062] The absorbance data of standard samples within a wavelength range refers to the set of light absorption measurements of samples with known concentrations within each divided interval. Weighted calculation is a mathematical operation that multiplies the data of each interval by the corresponding coefficient and then sums them. The weighted absorbance data represents a single value that comprehensively considers information from multiple wavelengths. Fitting operation is the process of determining curve parameters through algorithms such as the least squares method. The goodness of fit is usually measured by the coefficient of determination R² to measure the degree of agreement between the model and the data. Wavelength selection coefficient adjustment uses methods such as gradient optimization or grid search to improve weight allocation. The first fitting result is the optimized model parameters and curve equation that meet the accuracy requirements.

[0063] The complete process of iterative optimization fitting requires a systematic data processing and parameter tuning strategy. First, complete spectral data for 50 samples of different concentrations (5-500 mg / LCOD) were extracted from a standard sample database. For each sample, absorbance data was extracted according to six predefined wavelength ranges: for sample 1, the average absorbance A1=0.452 in the 200-280 nm range, A2=0.321 in the 280-380 nm range, A3=0.198 in the 380-480 nm range, A4=0.156 in the 480-580 nm range, A5=0.134 in the 580-680 nm range, and A6=0.095 in the 680-800 nm range. Using an initial wavelength selection coefficient w=[0.35,0.15,0.20,0.10,0.15,0.05], a weighted calculation was performed: A_weighted=0.452×0.35+0.321×0.15+0.198×0.20+0.156×0.10+0.134×0.15+0.095×0.05=0.1582+0.0482+0.0396+0.0156+0.0201+0.0048=0.2865. The same calculation was performed on all 50 samples to obtain the weighted absorbance sequence and the corresponding concentration value sequence.

[0064] The weighted data were substituted into the exponential fitting equation C = a × e^(b × A) + c for nonlinear least squares fitting. Initial parameter estimation employed a linearization method: after logarithmic transformation, ln(Cc) = ln(a) + b × A. Initial values ​​a = 38.5, b = 2.08, and c = -8.2 were obtained through linear regression. The Levenberg-Marquardt algorithm was used for iterative optimization, converging to a = 41.2, b = 1.95, and c = -10.5 after 15 iterations. The goodness of fit R² = 1 - Σ(Ci_actual - Ci_fitted)² / Σ(Ci_actual - C_mean)² = 1 - 1250.3 / 38650.2 = 0.9676.

[0065] Comparing R² = 0.9676 with the threshold of 0.96, 0.9676 > 0.96, which meets the requirement. However, to demonstrate the adjustment process, we assume the initial fit R² = 0.9523 < 0.96. The coefficient adjustment program is initiated, using the simplex method to optimize the wavelength selection coefficients. The objective function is defined as maximizing R², with the constraint Σwi = 1 and 0 ≤ wi ≤ 1. The first adjustment: the weights of 200-280nm are increased to 0.40, the weights of 680-800nm ​​are decreased to 0.02, and other parameters are adjusted accordingly, resulting in w_new = [0.40, 0.13, 0.18, 0.11, 0.16, 0.02]. The weighted absorbance is recalculated and fitted, resulting in R² = 0.9612, which is still below the threshold. Second adjustment: Further optimization yielded w=[0.42,0.12,0.16,0.10,0.17,0.03], with a fitted R²=0.9685>0.96, meeting the requirements. The final determined first fitting result is: fitting equation C=43.7×e^(1.92×A)-11.3, wavelength selectivity w=[0.42,0.12,0.16,0.10,0.17,0.03], goodness of fit R²=0.9685, root mean square error RMSE=8.2mg / L, mean absolute percentage error MAPE=3.8%. The complete optimization path was recorded, including 3 iterations, computation time of 2.3 seconds, and convergence criterion |ΔR²|<0.001, providing a reference for subsequent analysis and method improvement.

[0066] S104. When the relative error value exceeds the preset error range, adjust the decision parameters and try other curve types in the curve type set in turn for fitting operation until the relative error value meets the preset range requirement and the target fitting curve is obtained.

[0067] Among them, the preset error range represents the acceptable measurement accuracy boundary, which is usually set according to industry standards or application requirements. For example, environmental monitoring requires the relative error to not exceed 5%. Adjusting decision parameters refers to modifying the values ​​of control variables such as wavelength selection coefficient and goodness-of-fit threshold. Trying in sequence means testing different curve types one by one in a predetermined order. The target fitting curve represents the finally selected optimal fitting model that meets the accuracy requirements, including the curve type and specific parameter values. Other curve types refer to the alternative models in the curve type set other than the initial selection. The preset range requirement means that the relative error must be controlled within the numerical range.

[0068] This step is triggered when the first fitting result does not meet the accuracy requirements. It is mainly used to find the optimal fitting solution through an adaptive adjustment strategy. Specifically, the system first determines whether the relative error of the first fitting result exceeds the preset range. For example, if the average relative error is 8% while the preset requirement is within 5%, and optimization is confirmed, the system will first try to adjust the decision parameters of the current curve type. For example, it may adjust the originally uniformly distributed wavelength selection coefficient to highlight the characteristic wavelength, increase the coefficient at 550nm from 0.33 to 0.5, reduce the weight of interfering wavelengths, and re-perform the fitting calculation and evaluate the error. If the requirements are still not met after adjusting the parameters, the system will switch to the next curve type, for example, from the linear model to the exponential model A=ae^(bC)+c. The new model is used to re-estimate the parameters, and the decision parameters are adjusted accordingly based on the characteristics of the new model. For example, the exponential model is more sensitive to the high concentration range, so the weight of high absorbance data will be increased. This process will continue to iterate, trying all available curve types and parameter combinations in turn. Each iteration will record the fitting result and error index until a fitting solution that meets the accuracy requirements is found. Finally, the curve with the smallest error is determined as the target fitting curve.

[0069] In some embodiments, adaptive adjustment and curve optimization can be achieved in several ways: Optionally, the system can employ a grid search strategy for parameter optimization. First, a search range and step size are set for each decision parameter, such as a wavelength selection coefficient between 0.1 and 0.9 with a step size of 0.1. Then, a grid of all parameter combinations is generated, and a fitting operation is performed on each combination, calculating the error. The parameter combination with the smallest error is recorded. If the optimal parameter combination for the current curve type still does not meet the requirements, the system switches to the next curve type and repeats the grid search. The optimal results for all curve types are compared, and the globally optimal curve type and parameter combination are selected as the target fitting curve. The entire process may require evaluating hundreds of parameter combinations. To ensure the optimal solution is found, the system can optionally employ intelligent optimization algorithms for adaptive adjustment. First, a probabilistic model of error and parameters is established using Bayesian optimization. The expected error for different parameter combinations is predicted through a Gaussian process. Then, based on the acquisition function (such as the desired improvement in EI or the upper confidence bound UCB), the next most promising parameter point is selected for evaluation. The probabilistic model is updated after each evaluation, gradually converging to the optimal parameter region. When a certain curve type fails to meet the requirements, the optimization history of that type is saved as prior knowledge. When switching to a new curve type, transfer learning can be used to accelerate the optimization process. Finally, the model with the lowest computational complexity is selected as the target fitting curve while meeting accuracy requirements. It is understood that other metaheuristic methods such as genetic algorithms and particle swarm optimization can also be used to achieve parameter adjustment and curve selection; this is not limited here.

[0070] In some embodiments, this step specifically includes: Substitute the absorbance data of the standard sample into the fitting equation corresponding to the first fitting result to calculate the predicted concentration value. Calculate the relative error between the predicted concentration value and the actual concentration value of the standard sample, and determine whether the relative error value is within the preset error range. If the relative error value exceeds the preset error range, select the next curve type from the curve type set, adjust the range of the wavelength selection coefficient, modify the goodness-of-fit threshold accordingly, and repeat the fitting operation until the relative error value is within the preset error range. Then, determine the current fitted curve as the target fitted curve.

[0071] The predicted concentration value is the concentration estimate obtained by substituting the measured absorbance into the fitting equation. The relative error value represents the percentage of deviation of the predicted value from the true value. The preset error range is the maximum allowable deviation limit acceptable to the method. The curve type set includes various mathematical models such as linear, exponential, logarithmic, and polynomial. The range of wavelength selection coefficients determines the search space for parameter optimization. Modification of the goodness-of-fit threshold reflects the differences in accuracy requirements for different model types. The target fitting curve is the final selected model that has been fully verified and meets the accuracy requirements.

[0072] The complete process of performing prediction validation and model switching demonstrates the iterative nature of method optimization. Using the equation C = 43.7 × e^(1.92 × A) - 11.3 from the first fitting result, prediction calculations were performed on 50 standard samples. Taking 10 representative samples as examples, the actual concentrations were 10, 25, 50, 75, 100, 150, 200, 300, 400, and 500 mg / L, with corresponding weighted absorbances of 0.085, 0.213, 0.425, 0.638, 0.850, 1.275, 1.700, 2.550, 3.400, and 4.250. Substituting into the equation, the predicted concentration was calculated as: C1 = 43.7 × e^(1.92 × 0.085) - 11.3 = 43.7 × 1.177 - 11.3 = 40.1 mg / L. The actual concentration was 10 mg / L, resulting in a relative error of (|40.1 - 10| / 10) × 100% = 301%, which is significantly exceeding the limit. Further calculations for other samples revealed an average relative error of 85% for the low concentration range (<50 mg / L), 12% for the medium concentration range (50-200 mg / L), and 8% for the high concentration range (>200 mg / L).

[0073] The preset error range is usually set to ±10% (for routine analysis) or ±5% (for precise analysis), but the current results clearly exceed this range. The model switching program is initiated, selecting the next type—linear model—from the curve type set {exponential, linear, logarithmic, quadratic polynomial, power function}. The wavelength selection coefficient's value range is adjusted from the original [0,1] to [0.1,0.6] to avoid extreme weighting. The goodness-of-fit threshold is adjusted from 0.96 to 0.94, considering the inherent limitations of the linear model. The fitting operation is re-executed, yielding the linear equation C=125.8×A-5.2, R²=0.9435, but the error in the low-concentration range still reaches 35%.

[0074] We then switch to a quadratic polynomial model C = a × A² + b × A + c. The search range for wavelength selection coefficients is expanded to [0.05, 0.7], allowing for more flexible weight allocation. The optimal coefficient combination is searched using a particle swarm optimization algorithm, resulting in w = [0.38, 0.08, 0.22, 0.12, 0.15, 0.05] after 50 generations of evolution. The fitted equation is C = -85.3 × A² + 268.5 × A⁻¹².6, with R² = 0.9812. Validation of prediction accuracy: The predicted value for a 10 mg / L sample was 10.8 mg / L, with an error of 8%; for a 25 mg / L sample, the predicted value was 24.2 mg / L, with an error of 3.2%; for a 50 mg / L sample, the predicted value was 48.5 mg / L, with an error of 3%; for a 100 mg / L sample, the predicted value was 97.8 mg / L, with an error of 2.2%; for a 200 mg / L sample, the predicted value was 195.6 mg / L, with an error of 2.2%; and for a 500 mg / L sample, the predicted value was 508.3 mg / L, with an error of 1.7%. The relative errors for all samples were within ±10%, with an average error of 3.4% and a maximum error of 8%.

[0075] Further optimization was attempted using a piecewise fitting strategy, dividing the concentration range into two segments: 0-100 mg / L and 100-500 mg / L, with separate models established for each segment. A modified exponential model (C=28.5×(e^(2.35×A)-1)) was used for the low concentration segment, while a linear model (C=118.2×A+15.3) was used for the high concentration segment. The overall prediction error of the piecewise model was reduced to 2.8%, with all point errors controlled within ±5%. The final target fitting curve was determined to be a piecewise combined model, with the complete expression: when A<0.85, C=28.5×(e^(2.35×A)-1); when A≥0.85, C=118.2×A+15.3. Key parameters of the optimization process were recorded: a total of 4 iterations, 4 model types tried, and the final R²=0.9856, RMSE=5.8mg / L, maximum relative error 4.8%, average relative error 2.8%, and calculation time 8.5 seconds. This provides a complete technical archive for method standardization and quality control.

[0076] S105. Collect the absorbance data of the water sample to be tested, and substitute the absorbance data of the water sample to be tested into the target fitting curve to obtain the concentration value of the water quality parameter.

[0077] Among them, the water sample to be tested refers to the actual water sample that needs to be analyzed, which may come from rivers, lakes, sewage treatment plants or industrial discharge outlets, etc. The absorbance data represents the measured value of the degree of light absorption of the water sample at a specific wavelength, which is usually measured by a spectrophotometer at a set wavelength. The target fitting curve is used to represent the best mathematical model determined after optimization and parameter adjustment, which includes specific curve equations and parameter values. The water quality parameter concentration value refers to the content value of the target pollutant or indicator calculated by the fitting curve, such as the concentration of COD, ammonia nitrogen, total phosphorus, etc. Substitution calculation means that the measured absorbance value is used as the independent variable to solve the dependent variable in the curve equation. Acquisition refers to the measurement process of obtaining the spectral information of the water sample through optical instruments.

[0078] This step is performed after the target fitting curve is established and actual water quality testing is required. It is mainly used to apply the calibrated model to the quantitative analysis of unknown samples. Specifically, the system first performs necessary pretreatment on the water sample to be tested, including filtering to remove suspended particles, adjusting the pH to a suitable range, and adding a colorimetric reagent. Then, the treated water sample is injected into the cuvette of the spectrophotometer, and absorbance is measured at the same wavelength as the established standard curve. For example, absorbances measured at 450nm, 550nm, and 650nm are 0.65, 0.82, and 0.58, respectively. The system then weights these data according to previously determined wavelength selection coefficients, such as 0.2, 0.6, and 0.2. The weighted absorbance is then 0.65×0.2+0.82×0.6+0.58×0.2=0.738. Next, the weighted absorbance value is substituted into the target fitting curve equation. Assuming the target curve is an exponential model C=25×e^(1.2×A)-10, substituting A=0.738, the concentration is calculated as C=25×e^(1.2×0.738)-10=47.3mg / L. The system will also calculate the confidence interval, estimate the uncertainty of the measurement result based on the standard error of the fitting curve, and finally output the water quality parameter concentration value and its confidence range.

[0079] In some embodiments, absorbance acquisition and concentration calculation of the water sample to be tested can be achieved in various ways: Optionally, the system can use a multi-point measurement averaging method to improve accuracy. First, the absorbance of the same water sample to be tested is measured continuously 5-10 times at the target wavelength. After removing obvious outliers, the average value and standard deviation are calculated. For example, the 10 measurements at 550nm are 0.820, 0.823, 0.819, 0.821, 0.822, 0.818, 0.824, 0.821, 0.820, and 0.822. The average absorbance was 0.821, and the standard deviation was 0.002. Then, the average absorbance at different wavelengths was weighted and combined to obtain a comprehensive absorbance value of 0.756. Substituting this value into the target fitting curve equation C = a × ln(A + b) + c, where a = 35.2, b = 0.1, and c = 12.5, the concentration was calculated to be C = 35.2 × ln(0.756 + 0.1) + 12.5 = 41.8 mg / L. Simultaneously, the expanded uncertainty was calculated based on the measurement standard deviation and the curve fitting residual, yielding a result of 41 mg / L. 0.8±2.1 mg / L (95% confidence level); Optionally, the system can use spectral scanning to obtain more comprehensive information. First, the water sample to be tested is scanned across the entire wavelength range of 200-800 nm to obtain a complete absorption spectrum curve. Then, the absorbance values ​​at characteristic wavelengths are extracted. For example, the absorbances at preset key wavelengths of 254 nm, 436 nm, 525 nm, and 620 nm are 0.45, 0.68, 0.73, and 0.52, respectively. Combinations are set according to the correlation between different wavelengths and water quality parameters. Weights are assigned, such as 0.4 and 0.6 for the main COD response wavelengths of 254 nm and 620 nm, respectively. The calculated COD-related absorbance is 0.45 × 0.4 + 0.52 × 0.6 = 0.492. Substituting this value into the COD-specific target fitting curve CCOD = 85 × (A^1.15) + 5, the COD concentration is obtained as 85 × (0.492^1.15) + 5 = 42.3 mg / L. The system also performs cross-validation based on spectral shape characteristics to ensure the reliability of the results. It is understood that other methods, such as differential absorbance and derivative spectroscopy, can be used to achieve more accurate concentration determination; this is not limited here.

[0080] The following provides a more detailed description of the process of the method provided in this implementation. Please refer to [link / reference]. Figure 2 This is another flowchart illustrating the water quality testing method in this application.

[0081] S201. Collect absorbance data of the water sample to be tested, substitute the absorbance data of the water sample to be tested into the target fitting curve, and obtain the concentration value of water quality parameter.

[0082] Understandably, this step is similar to step S105, and will not be described again here.

[0083] S202. Establish a water quality parameter calculation formula library and record the correspondence between the absorbance data of the water sample to be tested in different wavelength ranges and the water quality parameters.

[0084] The water quality parameter calculation formula library is a database system that stores the measurement methods and calculation rules for various water quality indicators. Wavelength range refers to the continuous bands into which the spectral range is divided, such as 200-300nm, 300-400nm, etc. The correspondence between absorbance data and water quality parameters represents the mathematical relationship between light absorption intensity at a specific wavelength and pollutant concentration. For example, the absorbance of COD at 254nm and its concentration have a linear relationship of A254=0.015×COD+0.02.

[0085] The process of establishing a water quality parameter calculation formula library begins with the systematic organization of a large amount of measured data. First, historical testing data is categorized and summarized, with test records for different types of water samples (industrial wastewater, domestic sewage, surface water, etc.) archived according to water quality parameter categories. Each record contains complete spectral scan data, covering absorbance measurements in the 200-800nm ​​range at 1nm or 5nm intervals, along with the corresponding actual concentration values ​​determined by standard methods. After data organization, the wavelength range is divided into multiple intervals, each typically 50-100nm wide, such as 200-250nm, 250-350nm, 350-450nm, 450-550nm, 550-650nm, and 650-750nm. For each wavelength interval, the correlation between characteristic quantities such as the absorbance integral value, peak value, and average value within that interval and various water quality parameters is statistically analyzed. A mathematical model is established through regression analysis, recording significant correspondences with correlation coefficients greater than 0.8. For example, the ammonia nitrogen concentration and the absorbance integral value in the 420-450 nm range exhibit a relationship of CNH3-N = 12.5 × ∫(A420-450)dλ - 0.8, while the total phosphorus concentration and the absorbance peak value in the 690-710 nm range exhibit a relationship of CTP = 8.3 × Amax(690-710) + 0.15. These correspondences, along with their applicable conditions, accuracy ranges, and other metadata, are stored in the formula library, forming a structured knowledge base system.

[0086] S203. Generate a calculation formula template based on the corresponding relationship. The calculation formula template includes wavelength selection parameters, coefficient adjustment parameters, and data processing parameters.

[0087] The calculation formula template is a standardized mathematical expression framework. The wavelength selection parameter determines the characteristic wavelength or wavelength combination involved in the calculation. The coefficient adjustment parameter is used to correct measurement deviations under different conditions. The data processing parameter defines the preprocessing methods for the raw data, such as smoothing, differentiation, normalization and other operations.

[0088] Generating calculation formula templates requires abstracting and parameterizing the correspondences in the formula library. The system analyzes the common characteristics of various correspondences and extracts general mathematical structures. A typical template format is: C=α×f(Aλ1,Aλ2,...,Aλn)+β, where C is the concentration of the parameter to be measured, α is the principal coefficient adjustment parameter, β is the intercept adjustment parameter, f is the data processing function, and Aλi is the absorbance value of the selected wavelength. The wavelength selection parameter is determined through principal component analysis or feature selection algorithms, selecting the wavelength combination with the maximum information content and the minimum interference. For example, when measuring COD, λ1=254nm (characteristic absorption of organic matter), λ2=365nm (nitrate interference correction), and λ3=546nm (turbidity compensation) are selected, generating the formula CCOD=α1×(A254-α2×A365) / (1+α3×A546)+β1. The coefficient adjustment parameters are dynamically set according to the water sample type and environmental conditions. The α1 value ranges from 80 to 120 for industrial wastewater and from 60 to 90 for municipal sewage. Data processing parameters include the moving average window size (typically 5-15 data points), the Savitzky-Golay filter order (2nd-4th order), and the baseline correction method (linear or polynomial). The template also includes data validity check rules, such as absorbance should be within the range of 0.01-2.0; values ​​outside this range require dilution or concentration. Each template comes with an applicability description, indicating its optimal application scenario, expected accuracy, and usage limitations.

[0089] S204.

[0090] Correction calculation is a process of systematically correcting preliminary measurement results to improve accuracy, involving multiple aspects such as interference compensation, matrix effect correction, and nonlinear correction.

[0091] When performing correction calculations using the formula template, the system first identifies the type of water sample and measurement conditions, automatically selecting or allowing the user to specify a suitable template. The correction calculation is performed according to the following steps: First, extract absorbance data for relevant wavelengths, such as A254=0.685, A365=0.234, A546=0.156. Second, determine coefficient values ​​based on the water sample characteristics; assuming it is industrial wastewater, set α1=95, α2=0.3, α3=0.5, β1=2.5. Third, perform data preprocessing, smoothing the original absorbance using a 5-point moving average to eliminate random noise, obtaining smoothed data A'254=0.683, A'365=0.235, A'546=0.155. Step 4: Substitute the values ​​into the formula template to calculate: CCOD = 95 × (0.683 - 0.3 × 0.235) / (1 + 0.5 × 0.155) + 2.5 = 95 × 0.613 / 1.078 + 2.5 = 54.0 + 2.5 = 56.5 mg / L. Step 5: Perform temperature compensation. If the measurement temperature is 18℃, the standard temperature is 25℃, and the temperature coefficient is 0.02 / ℃, then the correction value is 56.5 × [1 + 0.02 × (25 - 18)] = 56.5 × 1.14 = 64.4 mg / L. Step 6: Check the reasonableness of the results by comparing them with historical data or parallel samples. If the deviation exceeds 20%, a retest procedure is triggered. The correction calculation also includes a cross-validation step, using multiple templates to calculate the same parameter and taking the weighted average as the final result. For example, when COD is calculated using both UV absorption and multi-wavelength regression methods, the results are 64.4 mg / L and 62.8 mg / L, respectively. Based on the reliability of the methods, weights of 0.6 and 0.4 are assigned, and the final result is 64.4 × 0.6 + 62.8 × 0.4 = 63.8 mg / L.

[0092] S205. Save the corrected water quality parameter concentration values ​​and calculation formula templates into the water quality parameter calculation formula library.

[0093] The corrected water quality parameter concentration values ​​are the final measurement results obtained through system calibration and optimization calculations. The calculation formula template is a complete mathematical expression containing specific parameter values. The water quality parameter calculation formula library is a database system that centrally stores and manages measurement data and calculation methods. The storage operation includes processes such as data formatting, index creation, and related information recording.

[0094] Storing the corrected data into the formula library requires a standardized data management process. The system first encapsulates the corrected concentration values ​​to ensure data integrity, generating a complete record containing the measurement timestamp, sample number, measurement conditions, original absorbance data, correction process parameters, and final result. For example, a complete record includes: measurement time 2025-09-25 14:30:00, sample number WS-2025-0925-001, water sample type: dyeing and printing wastewater, measurement temperature 22℃, pH value 7.8, original absorbance dataset {λ254:0.685,λ365:0.234,λ546:0.156}, the calculation formula template used is CCOD=95×(A254-0.3×A365) / (1+0.5×A546)+2.5, corrected COD concentration value 63.8mg / L, measurement uncertainty ±3.2mg / L. Data storage employs a relational database structure. The main table records basic information and results, while sub-tables store detailed spectral data, linked by sample number. Calculation formula templates are synchronously updated to the template library, recording performance indicators such as usage frequency, success rate, and average error. Each storage operation generates a transaction log, recording the user, time, and modifications to ensure data traceability. The database automatically executes backup strategies, performing daily incremental backups and weekly full backups to guarantee data security. The storage process also triggers data quality checks to verify the reasonableness of numerical ranges and mark abnormal data for subsequent review. Multi-dimensional indexes support rapid retrieval of historical data based on conditions such as time, sample type, parameter category, and concentration range.

[0095] S206. Update the parameters of the calculation formula template based on historical data in the water quality parameter calculation formula library.

[0096] Historical data consists of a large number of measurement records and calculation results accumulated in the formula library. Updating the calculation formula template is a process of optimizing model parameters based on statistical analysis. Parameter updates include coefficient adjustments, weight optimization, and revision of the applicable scope.

[0097] Updating the calculation formula template parameters is a data-driven, continuous optimization process. The system periodically (e.g., monthly or after accumulating 100 new data entries) initiates the parameter update procedure. First, historical data from the most recent period is extracted from the database, and records using the same template and with standard method verification results are selected. For example, 500 records using the COD template within the last 30 days are extracted, of which 300 have national standard method comparison data. Statistical analysis is performed on these data to calculate the deviation distribution between the template predicted value and the standard value. Assuming the original template is CCOD=90×(A254-0.25×A365) / (1+0.4×A546)+3.0, statistics show that the predicted values ​​are generally 5-8% lower, with even greater deviations in the high concentration range (>100mg / L). The parameters were refitted using least squares regression, resulting in optimized coefficients: the principal coefficient was adjusted from 90 to 94.5, the interference correction coefficient from 0.25 to 0.28, the turbidity compensation coefficient from 0.4 to 0.45, and the intercept from 3.0 to 2.2. A gradual strategy was adopted for parameter updates, initially setting the weight of the new parameter to 0.3 and the original parameter weight to 0.7, gradually increasing the weight of the new parameter after a validation period. The system also performed segmented optimization, dividing the concentration range into three segments: 0-50 mg / L, 50-200 mg / L, and >200 mg / L, each using a different set of coefficients. The update process retained the parameter change history, generating parameter evolution curves to identify long-term trends. When parameter changes exceeded a preset threshold (e.g., 15%), the system issued an alert, prompting the need for instrument recalibration or reagent quality checks.

[0098] S207. Receive the water quality parameter calculation formula input by the user, apply the water quality parameter calculation formula to the absorbance data of the water sample to be tested, and obtain the calculation result. The calculation formula includes wavelength combination method and calculation weight.

[0099] The water quality parameter calculation formula input by the user is a measurement method customized by the operator based on experience or specific needs. The wavelength combination method defines the selection of wavelengths involved in the calculation and the calculation relationship. The calculation weight represents the contribution ratio of different wavelengths or items in the final result. The calculation result is the parameter concentration value obtained by applying the customized formula.

[0100] Receiving and applying user-defined formulas requires a robust input parsing and validation mechanism. Users input formulas through the system interface, in a format such as "COD_custom=0.6×(A254-A365 / 2)+0.3×A436+0.1×(A525+A620) / 2". The system first performs syntax parsing, identifying variables (A254, A365, A436, A525, A620), operators, and constants in the formula. It verifies whether the wavelength values ​​are within the instrument's measurement range (200-800nm) and checks the rationality of the calculation logic, such as ensuring the divisor is not zero and that weights and sums are normalized. After successful parsing, the system extracts the absorbance values ​​for the corresponding wavelengths from the current measurement data, assuming A254=0.720, A365=0.280, A436=0.450, A525=0.380, and A620=0.320. The calculations are performed according to the order of operations defined in the formula: First term = 0.6 × (0.720 - 0.280 / 2) = 0.6 × 0.580 = 0.348, Second term = 0.3 × 0.450 = 0.135, Third term = 0.1 × (0.380 + 0.320) / 2 = 0.1 × 0.350 = 0.035, Final result = 0.348 + 0.135 + 0.035 = 0.518 (absorbance units). If the formula includes a concentration conversion coefficient, such as "C = 120 × Result + 5", then the final concentration = 120 × 0.518 + 5 = 67.16 mg / L. The system provides a real-time preview function, displaying the calculation results instantly as the user enters the formula, facilitating adjustments and optimizations. After the formula verification is successful, the system asks whether to save it as a new template. If saved, it requires the input of metadata such as the template name and applicable conditions. The application process records detailed logs, including formula content, input data, intermediate results, and final output, which facilitates result verification and method traceability.

[0101] S208. Obtain multiple sets of standard water samples with different concentrations, collect the absorbance data of the standard water samples, apply the water quality parameter calculation formula to the absorbance data of the standard water samples, and obtain the calculated concentration value of the standard water samples.

[0102] A standard water sample is a reference material with a known and accurate concentration. It is certified by the National Standard Material Center or prepared according to standard methods. Different concentrations refer to a series of standard samples covering multiple concentration gradients such as low, medium, and high. The absorbance data of the standard water sample is the spectral response value obtained under specified measurement conditions. The calculated concentration value is the concentration estimate obtained after processing the absorbance data through mathematical formulas.

[0103] The acquisition and measurement of standard water samples followed strict quality control procedures. The laboratory prepared standard water samples with concentration gradients following a logarithmic or arithmetic progression, for example, a COD standard series of 10, 25, 50, 100, 200, and 500 mg / L. Standard water samples were prepared using analytical grade reagents and ultrapure water. Potassium hydrogen phthalate was used as the COD standard substance, with each liter of solution containing 850 mg of potassium hydrogen phthalate equivalent to 1000 mg of COD. The preparation process was carried out at a constant temperature of 20 ± 1℃ using a calibrated analytical balance (accuracy 0.0001 g) and Class A volumetric flasks. Three parallel samples were prepared for each concentration to ensure reproducibility. Absorbance data were acquired under standardized conditions: the instrument was preheated for 30 minutes until stable, using quartz cuvettes (10 mm path length), with ultrapure water as a blank control. For each standard water sample, a full-band scan was performed in the 200-800 nm range, with a scan interval of 2 nm and an integration time of 0.5 seconds. The measurement was repeated 5 times, and the average value was taken. After obtaining complete spectral data, the absorbance values ​​at key wavelengths were extracted, such as A254 = 0.125, 0.312, 0.625, 1.250, 2.500, and 6.250 at 254 nm (corresponding to 10-500 mg / L). These data were substituted into a user-defined calculation formula, for example, CCOD = 85 × (A254 - 0.2 × A365)^1.1 + 3, to calculate the concentration values ​​of each standard water sample: 9.8, 24.5, 49.2, 98.7, 197.3, and 493.5 mg / L. All intermediate data were retained during the calculation process, including the original absorbance at each wavelength, background correction values, and the calculation results of each formula, forming a complete data chain for easy quality traceability.

[0104] S209. Calculate the relative error between the calculated concentration value and the actual concentration value of the standard water sample to obtain the first error result.

[0105] The calculated concentration value is the result of the measurement obtained by the water quality parameter calculation formula. The actual concentration value is the certified value or nominal value of the standard water sample. The relative error indicates the degree to which the measured value deviates from the true value. The first error result is a set of quantitative indicators for evaluating the accuracy of the calculation formula.

[0106] Calculating the first error result requires a systematic error analysis process. For each standard water sample, the formula for calculating the relative error is: RE = (|Ccalc - Creal| / Creal) × 100%, where Ccalc is the calculated concentration value and Creal is the actual concentration value. Taking the aforementioned data as an example, the relative error of the 10 mg / L standard sample is (|9.8-10| / 10)×100%=2.0%, the relative error of the 25 mg / L standard sample is (|24.5-25| / 25)×100%=2.0%, the relative error of the 50 mg / L standard sample is (|49.2-50| / 50)×100%=1.6%, the relative error of the 100 mg / L standard sample is (|98.7-100| / 100)×100%=1.3%, the relative error of the 200 mg / L standard sample is (|197.3-200| / 200)×100%=1.35%, and the relative error of the 500 mg / L standard sample is (|493.5-500| / 500)×100%=1.3%. In addition to single-point errors, comprehensive error indices were calculated: mean relative error MRE = (2.0 + 2.0 + 1.6 + 1.3 + 1.35 + 1.3) / 6 = 1.59%, maximum relative error MaxRE = 2.0%, and root mean square error RMSE = √[Σ(Ccalc - Creal)² / n] = 3.82 mg / L. Error analysis also included linear regression evaluation. Plotting the calculated values ​​against the actual values ​​yielded a fitted line y = 0.987x + 0.15, with a coefficient of determination R² = 0.9998. The slope being close to 1 and the intercept close to 0 indicates a small systematic error. Segmented error statistics showed an average error of 1.87% for the low concentration range (<50 mg / L), 1.32% for the medium concentration range (50-200 mg / L), and 1.3% for the high concentration range (>200 mg / L), indicating that the formula is stable across the entire range. The first error results also include statistical charts such as error distribution histograms and QQ plots, which are used to determine whether the error conforms to a normal distribution and provide a basis for subsequent uncertainty assessment.

[0107] S210. Substitute the absorbance data of the standard water sample into the target fitting curve to obtain the fitted concentration value of the standard water sample. Calculate the relative error between the fitted concentration value and the actual concentration value to obtain the second error result.

[0108] The target fitted curve is the optimal mathematical model selected through optimization. The fitted concentration value is the concentration estimate obtained by back-calculation from the fitted curve. The second error result is used to evaluate the accuracy of the fitted curve method and is compared with the first error result.

[0109] The process of substituting standard water sample data into the target fitted curve for verification calculation highlights the importance of method comparison. Assume the target fitted curve is an exponential model C = 42.5 × e^(1.85 × A) - 15, where A is the weighted absorbance. For the same series of standard water samples, the absorbance data is first processed according to the wavelength selection and weight settings used when establishing the fitted curve. If the weighting coefficients are λ254:0.5, λ436:0.3, and λ525:0.2, then the weighted absorbance of the 10 mg / L standard sample is A = 0.125 × 0.5 + 0.08 × 0.3 + 0.06 × 0.2 = 0.0985. Substituting this into the curve yields C = 42.5 × e^(1.85 × 0.0985) - 15 = 42.5 × 1.200 - 15 = 36.0 - 15 = 10.3 mg / L. The fitted concentration values ​​for all standard samples were calculated sequentially: 10.3, 25.8, 51.2, 102.1, 203.5, and 508.2 mg / L. The relative errors of the second error results are calculated as follows: 10 mg / L sample = (|10.3-10| / 10)×100%=3.0%, 25 mg / L sample = (|25.8-25| / 25)×100%=3.2%, 50 mg / L sample = (|51.2-50| / 50)×100%=2.4%, 100 mg / L sample = (|102.1-100| / 100)×100%=2.1%, 200 mg / L sample = (|203.5-200| / 200)×100%=1.75%, 500 mg / L sample = (|508.2-500| / 500)×100%=1.64%. The characteristic values ​​of the second error results are: mean relative error 2.35%, maximum relative error 3.2%, standard deviation 0.65%. The difference between the two methods was compared using a paired t-test. The t-statistic was 2.13, with 5 degrees of freedom (df) and a p-value of 0.086 > 0.05, indicating no significant difference between the two methods. Error comparison analysis revealed that the calculation formula method performed better at low concentrations (mean error 1.87% vs 3.1%), while the fitted curve method was more stable at high concentrations (mean error 1.3% vs 1.7%). The second error result also included a residual analysis plot, showing the trend of the deviation between the fitted and actual values ​​as concentration changes, used to identify systematic biases and optimization directions.

[0110] S211. Compare the magnitudes of the first error result and the second error result. When the first error result is smaller than the second error result, it is determined that the accuracy of the water quality parameter calculation formula is higher than that of the target fitting curve.

[0111] The first error result is the relative error value generated by the water quality parameter calculation formula, and the second error result is the relative error value generated by the target fitting curve. Comparing the magnitudes is a process of quantitatively comparing the two values. The accuracy is higher than that of the measurement accuracy represented by the calculation formula, which is better than that of the fitting curve method.

[0112] Comparing the error results of the two methods requires point-by-point comparison and comprehensive evaluation. For each standard water sample concentration point, the relative error values ​​are directly compared. Taking the aforementioned calculation results as an example: for the 10 mg / L standard sample: the first error 2.0% < the second error 3.0%, the calculation formula is more accurate; for the 25 mg / L standard sample: the first error 2.0% < the second error 3.2%, the calculation formula is more accurate; for the 50 mg / L standard sample: the first error 1.6% < the second error 2.4%, the calculation formula is more accurate; for the 100 mg / L standard sample: the first error 1.3% < the second error 2.1%, the calculation formula is more accurate; for the 200 mg / L standard sample: the first error 1.35% < the second error 1.75%, the calculation formula is more accurate; for the 500 mg / L standard sample: the first error 1.3% < the second error 1.64%, the calculation formula is more accurate. In this example, the error of the calculation formula at all concentration points is less than that of the fitted curve, indicating that the calculation formula performs better across the entire range. In addition to point-by-point comparisons, a comprehensive index comparison was also conducted: the average relative error was 1.59% vs. 2.35%, a difference of 0.76 percentage points; the maximum relative error was 2.0% vs. 3.2%, a difference of 1.2 percentage points; and the standard deviation of the error was 0.34% vs. 0.65%, indicating that the calculation formula has better stability. Error ratio analysis showed that the second error was 1.48 times the first error (2.35% / 1.59%), meaning that the average error of the fitted curve was 48% higher than that of the calculation formula. Through statistical testing of the error difference, the mean difference of the paired samples was 0.91%, the standard error was 0.15%, and the 95% confidence interval was [0.52%, 1.30%], excluding zero, proving that the accuracy of the calculation formula is statistically significantly higher than that of the target fitted curve.

[0113] S212. Calculate the percentage of standard water samples where the first error result is less than the second error result. When the percentage exceeds a preset ratio, determine that the accuracy result of the water quality parameter calculation formula meets the preset accuracy condition. When the accuracy result meets the preset accuracy condition, save the water quality parameter calculation formula to the formula library.

[0114] The sample size ratio is the ratio of the number of samples that meet specific conditions to the total number of samples. The preset ratio is the minimum acceptable pass rate threshold for the formula. The preset accuracy condition is the quality standard for the formula to be included in the database. Saving to the formula database means that the verified formula will be included in the system knowledge base for later use.

[0115] Statistical analysis and condition determination constitute the core of the formula's quality control. First, the number of standard water samples where the first error is less than the second error is counted. Among the aforementioned six standard samples: 10 mg / L sample: 2.0% < 3.0%, counted; 25 mg / L sample: 2.0% < 3.2%, counted; 50 mg / L sample: 1.6% < 2.4%, counted; 100 mg / L sample: 1.3% < 2.1%, counted; 200 mg / L sample: 1.35% < 1.75%, counted; 500 mg / L sample: 1.3% < 1.64%, counted. The number of samples meeting the condition is six, and the total number of samples is six, so the percentage is calculated as 6 / 6 × 100% = 100%. The preset percentage threshold is usually set at 70% or 80% to ensure that the formula outperforms existing methods in most cases. In this example, 100% > 80%, meeting the preset percentage requirement. The accuracy requirements include multiple dimensions: (1) the proportion of dominant samples ≥ 80%; (2) the average relative error ≤ 5% (1.59% in this example meets the requirement); (3) the maximum relative error ≤ 10% (2.0% in this example meets the requirement); (4) the correlation coefficient R² with the standard method ≥ 0.995 (0.9998 in this example meets the requirement); and (5) it outperforms the control method at at least 3 concentration levels (all 6 levels in this example meet the requirement). After all conditions are met, the system executes the formula entry process. The entry operation includes: generating a unique formula number such as F-2025-0925-001, recording the formula expression, applicable range (10-500mg / LCOD), validation dataset, performance indicators (average error 1.59%, maximum error 2.0%, R²=0.9998), creator information, validation date, and other metadata. Formulas are categorized and stored under the corresponding parameter category, such as the COD determination formula sub-library. Set the formula status to "Verified," prioritizing it based on accuracy. In this example, due to its 100% advantage rate, it can be set to high priority. Establish a formula usage tracking mechanism to record each call and its effect feedback. Generate formula documentation, including explanations of principles, usage conditions, and precautions, to facilitate understanding and application by other users. The formula library automatically performs version control, retaining historical versions for easy backtracking and comparison.

[0116] The water quality testing equipment in the embodiments of this invention is described below from the perspective of hardware processing. Please refer to [link / reference needed]. Figure 3 This is a schematic diagram of the physical structure of a water quality testing device in an embodiment of this application.

[0117] It should be noted that, Figure 3 The structure of the water quality testing equipment shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0118] like Figure 3As shown, the water quality testing equipment includes a Central Processing Unit (CPU) 301, which can perform various appropriate actions and processes according to a program stored in a Read-Only Memory (ROM) 302 or a program loaded from a storage section 308 into a Random Access Memory (RAM) 303, such as performing the methods described in the above embodiments. The RAM 303 also stores various programs and data required for system operation. The CPU 301, ROM 302, and RAM 303 are interconnected via a bus 304. An Input / Output (I / O) interface 305 is also connected to the bus 304.

[0119] The following components are connected to I / O interface 305: input section 306 including audio input devices, push-button switches, etc.; output section 307 including liquid crystal display (LCD) and audio output devices, indicator lights, etc.; storage section 308 including hard disks, etc.; and communication section 309 including network interface cards such as LAN (Local Area Network) cards, modems, etc. Communication section 309 performs communication processing via a network such as the Internet. Drive 310 is also connected to I / O interface 305 as needed. Removable media 311, such as disks, optical disks, magneto-optical disks, semiconductor memories, etc., are installed on drive 310 as needed so that computer programs read from them can be installed into storage section 308 as needed.

[0120] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing computer programs for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 309, and / or installed from removable medium 311. When the computer program is executed by central processing unit (CPU) 301, it performs the various functions defined in the present invention.

[0121] It should be noted that specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0122] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. Each block in a flowchart or block diagram may represent a module, program segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those shown in the drawings.

[0123] Specifically, the water quality testing device in this embodiment includes a processor and a memory. The memory stores a computer program, and when the computer program is executed by the processor, it implements the water quality testing method provided in the above embodiment.

[0124] In another aspect, the present invention also provides a computer-readable storage medium, which may be included in the water quality testing device described in the above embodiments; or it may exist independently and not assembled into the water quality testing device. The storage medium carries one or more computer programs that, when executed by a processor of the water quality testing device, cause the water quality testing device to implement the water quality testing method provided in the above embodiments.

[0125] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

[0126] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".

[0127] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A method of testing water quality, characterized by, The method is applied to a water quality testing device, and comprises the following steps: A standard sample database is obtained, and a curve type set is established, the standard sample database comprising absorbance data of standard samples at different concentrations and corresponding actual concentration values, and the curve type set comprising a linear fitting curve, an exponential fitting curve and a logarithmic fitting curve; An initial curve type is selected from the curve type set based on historical fitting accuracy of the standard samples, and a decision parameter is established according to the historical fitting accuracy, the decision parameter comprising a wavelength selection coefficient and a goodness-of-fit threshold value; The absorbance data of the standard samples is subjected to fitting operation according to the decision parameter, a first fitting result is obtained, and a relative error value of the first fitting result is calculated; When the relative error value exceeds a preset error range, the decision parameter is adjusted, and other curve types in the curve type set are sequentially tried for fitting operation until the relative error value meets a preset range requirement, and a target fitting curve is obtained; Absorbance data of a water sample to be tested is collected, and the absorbance data of the water sample to be tested is substituted into the target fitting curve to obtain a water quality parameter concentration value.

2. The method of claim 1, wherein, The step of selecting an initial curve type from the curve type set based on historical fitting accuracy of the standard samples and establishing a decision parameter according to the historical fitting accuracy specifically comprises the following steps: A standard sample database is obtained, and the standard sample database comprises absorbance data of the standard water sample at different concentrations and corresponding actual concentration values; The absorbance data is substituted into the linear fitting curve, the exponential fitting curve and the logarithmic fitting curve respectively for fitting, and historical fitting accuracy of each curve type is obtained; The initial curve type is determined according to the size order of the historical fitting accuracy; The absorbance data is collected in a preset wavelength range, and the preset wavelength range is divided into a plurality of continuous wavelength intervals according to the numerical distribution of the absorbance data; The variation trend of the absorbance data in the wavelength interval is calculated, and the wavelength selection coefficient is set for each wavelength interval according to the variation trend; The distribution rule of the historical fitting accuracy is counted, and the goodness-of-fit threshold value is set as a weighted average value of the historical fitting accuracy.

3. The method of claim 1, wherein, The step of subjecting the absorbance data of the standard samples to fitting operation according to the decision parameter to obtain a first fitting result specifically comprises the following steps: The absorbance data of the standard samples in a wavelength interval is obtained; The absorbance data is subjected to weighted calculation according to the wavelength selection coefficient to obtain weighted absorbance data; The weighted absorbance data is substituted into a fitting equation corresponding to the initial curve type for fitting operation; The goodness-of-fit of the fitting operation is calculated, and the goodness-of-fit is compared with the goodness-of-fit threshold value; When the goodness-of-fit is less than the goodness-of-fit threshold value, the wavelength selection coefficient is adjusted, and the fitting operation is performed again; The fitting operation is repeatedly performed until the goodness-of-fit is greater than the goodness-of-fit threshold value, and a current fitting result is determined as the first fitting result.

4. The method of claim 1, wherein, The step of adjusting the decision parameter and sequentially trying other curve types in the curve type set for fitting operation when the relative error value exceeds the preset error range until the relative error value meets the preset range requirement to obtain the target fitting curve specifically comprises: Substitute the absorbance data of the standard sample into the fitting equation corresponding to the first fitting result to obtain a predicted concentration value; Calculate the relative error value between the predicted concentration value and the actual concentration value of the standard sample; Determine whether the relative error value is within the preset error range; When the relative error value exceeds the preset error range, select the next curve type in the curve type set; Adjust the value range of the wavelength selection coefficient and correspondingly modify the goodness of fit threshold; Repeat the fitting operation until the relative error value is within the preset error range, and determine the current fitting curve as the target fitting curve.

5. The method of claim 1, wherein, After the step of substituting the absorbance data of the water sample to be tested into the target fitting curve to obtain the water quality parameter concentration value, the method further comprises: Establish a water quality parameter calculation formula library to record the corresponding relationship between the absorbance data of the water sample to be tested in different wavelength intervals and the water quality parameters; Generate a calculation formula template according to the corresponding relationship, wherein the calculation formula template includes wavelength selection parameters, coefficient adjustment parameters and data processing parameters; Use the calculation formula template to perform correction calculation on the water quality parameter concentration value; Store the corrected water quality parameter concentration value and the calculation formula template in the water quality parameter calculation formula library; Update the parameters of the calculation formula template according to the historical data in the water quality parameter calculation formula library.

6. The method of claim 1, wherein, After the step of substituting the absorbance data of the water sample to be tested into the target fitting curve to obtain the water quality parameter concentration value, the method further comprises: Receive a water quality parameter calculation formula input by a user, apply the water quality parameter calculation formula to the absorbance data of the water sample to be tested to obtain a calculation result, and the calculation formula includes a wavelength combination mode and a calculation weight; Compare the difference between the calculation result and the water quality parameter concentration value to evaluate the accuracy result of the water quality parameter calculation formula, and save the water quality parameter calculation formula to a formula library when the accuracy result meets a preset accuracy condition.

7. The method of claim 6, wherein, The step of comparing the difference between the calculation result and the water quality parameter concentration value to evaluate the accuracy result of the water quality parameter calculation formula specifically comprises: Obtain multiple groups of standard water samples with different concentrations, collect the absorbance data of the standard water samples, apply the water quality parameter calculation formula to the absorbance data of the standard water samples to obtain the calculated concentration values of the standard water samples; Calculate the relative error between the calculated concentration values and the actual concentration values of the standard water samples to obtain a first error result; Substitute the absorbance data of the standard water samples into the target fitting curve to obtain the fitting concentration values of the standard water samples, calculate the relative error between the fitting concentration values and the actual concentration values to obtain a second error result; Compare the first error result and the second error result, and when the first error result is smaller than the second error result, determine that the accuracy of the water quality parameter calculation formula is higher than the target fitting curve; Determine the proportion of the number of samples in the standard water sample in which the first error result is smaller than the second error result, and when the proportion exceeds a preset proportion, determine that the accuracy result of the water quality parameter calculation formula meets the preset accuracy condition.

8. A water quality testing device, characterized by, The water quality testing device comprises one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors invoke the computer instructions to enable the water quality testing device to execute the method according to any one of claims 1-7.

9. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are run on the water quality testing device, the water quality testing device is enabled to execute the method according to any one of claims 1-7.

10. A computer program product, characterised in that, When the computer program product is run on the water quality testing device, the water quality testing device is enabled to execute the method according to any one of claims 1-7.