Temperature correction method for water quality pH value spectrum detection and water quality pH value optical detection device
By selecting characteristic wavelength variables that are stable due to temperature, combining the differential spectral standard deviation and continuous projection algorithm, the impact of temperature changes on the detection accuracy of water quality pH spectral is solved, efficient and accurate temperature correction and model stability are achieved, and detection efficiency is improved.
Patent Information
- Application Number
- CN202510886006.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-09-02
AI Technical Summary
In the detection of water quality pH spectral, the impact of temperature changes on the spectrum leads to a decrease in the prediction accuracy of the model, making it difficult to achieve efficient and accurate temperature correction.
The characteristic wavelength variable correction method that is stable due to temperature influence is adopted, and the stable band is selected through the differential spectral standard deviation (SDDSI), combined with the continuous projection algorithm (SPA) and the segmented direct standardization (PDS) method, a temperature correction matrix is established to eliminate the irregular influence of temperature on the spectrum.
It improves the modeling accuracy, stability and efficiency of water quality pH spectroscopy detection, ensures that the sample is detected under a uniform temperature environment, simplifies the operation process, and reduces external temperature interference.
Smart Images

Figure CN120577243A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of spectrum detection, in particular to a temperature correction method for spectrum detection of pH value of water quality and an optical detection device for pH value of water quality. Background Art
[0002] pH is one of the key indicators for assessing the acidity and alkalinity of water. It not only affects the solubility of nutrients in the water, but also the formation and transformation of harmful substances such as ammonia nitrogen, nitrite, and sulfide. Excessively high or low pH values can disrupt the chemical balance of the water, thereby affecting the biodiversity and stability of the aquatic ecosystem. Near-infrared spectroscopy is used to detect water pH, which allows for rapid, real-time online testing without disrupting the water, and can promptly reflect changes in water pH. By collecting spectral data on water pH in real time and transferring it to an established multivariate calibration model, the current water pH value can be determined.
[0003] However, in actual data collection, water temperature is not always constant due to geographic location and climatic conditions; it varies across time periods. Spectral acquisition is also susceptible to environmental interference, with temperature being a major factor. Temperature changes alter the intensity and position of the absorption bands of the OH groups in water molecules, thereby shifting the intensity and peak positions of the spectrum, affecting the accuracy of the prediction model. Consequently, commercial products often struggle to meet accuracy requirements in real-world testing.
[0004] Currently, there are three main methods for correcting temperature effects on spectra: global modeling, temperature-insensitive variable selection, and spectral correction. Global modeling combines spectral data measured at all temperatures into a model, but this method requires a large number of calibration samples. Temperature-insensitive variable selection methods, such as simulated annealing (SA) and genetic algorithms (GA), can improve the model's robustness to temperature variations, but can reduce accuracy if the primary concentration information lies in temperature-sensitive wavelengths. Spectral correction methods correct the predicted sample's spectrum to that at a reference temperature, then use the correction model to predict concentrations. These methods can be categorized as requiring or not requiring standard samples. Standard samples involve identifying representative samples from the primary and secondary spectra, and using these spectra to construct the transfer model. Methods that do not require standard samples include orthogonal signal processing (OSC), external parameter orthogonalization (EPO), and generalized least squares weighting (GLSW), which are equivalent to spectral preprocessing. Methods that do require standard samples include direct standardization (DS) and piecewise direct standardization (PDS), with PDS being the most commonly used temperature correction method.
[0005] However, in practical applications, the water spectrum is unstable under temperature influences, and the spectrum's temperature stability is poor at most wavelengths. Temperature changes simply add random noise to the spectrum, making it impossible to explore clear relationships between spectra at different temperatures and easily leading to spectral redundancy. Directly using the full spectrum or selecting wavelength variables that are unstable under temperature influence for temperature correction can easily lead to overcorrection, significantly reducing the accuracy of the model. Therefore, it is crucial to select wavelengths with relatively consistent temperature effects for accurate and efficient temperature correction. Summary of the Invention
[0006] In view of this, the purpose of the present invention is to provide a temperature correction method for water quality pH value spectrum detection and a water quality pH value optical detection device, which are used to correct the influence of temperature on the spectrum to improve the modeling accuracy of the water pH value spectrum, and to design a water quality pH value optical detection device for collecting visible and near-infrared spectra of a group of samples at different temperatures. The experimental device can present multiple samples, adopts a water bath heating method, and adopts intelligent temperature control, with the advantages of high efficiency and temperature stability. The temperature correction method proposed in the present invention adopts a variable correction method for characteristic wavelengths that are stable under temperature influence, which includes using the standard deviation of the difference spectrum (SDDSI) between the primary and secondary instruments to select the bands that are stable under temperature influence, and then using the continuous projection algorithm (SPA) to find the characteristic wavelengths that are stable under temperature influence, and finally correcting the characteristic wavelengths that are stable under temperature influence by the segmented direct standardization method (PDS), thereby achieving the purpose of temperature correction.
[0007] To achieve the above object, the present invention adopts the following technical solution: a temperature correction method for water quality pH value spectral detection, comprising the following steps:
[0008] Step 1: Prepare samples with different pH values, measure the pH value of each pH sample, and use a water quality pH optical detection device to collect visible / near-infrared spectral data of the samples at different temperatures;
[0009] Step 2: Preprocess the collected spectral data of samples at different temperatures;
[0010] Step 3: After screening the temperature-stable wavelengths of the pre-processed spectral data, a characteristic variable optimization algorithm is used to select the characteristic wavelengths with stable temperature effects;
[0011] Step 4: Use the temperature correction algorithm to establish a temperature correction matrix for the characteristic wavelengths at different temperatures;
[0012] Step 5: Establish a pH prediction model using the characteristic wavelength at the main temperature;
[0013] Step 6: Input the characteristic wavelengths at other temperatures into the pH prediction model after temperature correction to complete the pH value prediction.
[0014] In a preferred embodiment, in step 3, a temperature is selected as a reference temperature, and the reference temperature spectrum and other temperature spectra are used to perform standard deviation processing of the differential spectrum, and the band that is stable under the influence of temperature is selected based on the prediction accuracy of modeling different bands; then, the continuous projection algorithm SPA characteristic wavelength optimization is performed on the band that is stable under the influence of temperature, and finally a multivariate correction model is established, and the characteristic wavelength that is stable under the influence of temperature is selected based on the principle of minimum prediction root mean square error RMSEP.
[0015] In a preferred embodiment, in step 3, the standard deviation SDDSI(j) of the difference spectrum between the reference temperature spectrum and the other temperature spectra is processed as follows:
[0016]
[0017] Among them A ij =M ij -S ij , i and j represent the number of samples and wavelengths respectively; m is the number of samples used for wavelength selection; A is the difference spectrum between the spectrum at the reference temperature and the spectrum at other temperatures, is the average spectrum of all samples of A, for Spectral response at the jth wavelength; M ij and S ij are the spectral responses of the i-th sample at the j-th wavelength at the reference temperature and other temperatures, respectively. The smaller the SDDSI(j), the higher the consistency of the spectral signals between the reference temperature and other temperatures.
[0018] In a preferred embodiment, in step 3, the preferred calculation steps of the SPA characteristic variables of the continuous projection algorithm on the band stable under the influence of temperature are:
[0019] Step 31: Initialization: Set the number of wavelengths to be extracted M. Before the first iteration m = 1, select X N×p The jth column x j Denoted as x k(0) , k(0)=j,j∈1,…,p. Where X N×p is the spectrum matrix, N is the number of samples, p is the total number of wavelengths, x j For X N×p The spectral response of the jth column, k is our custom set, and k(m) is used to record the selected column;
[0020] Step 32: Record the set of column vector positions that are not selected as
[0021] Step 33: Calculate the remaining column vectors x j and the current column vector x k(m-1) for their projections
[0022] Step 34: Select the serial number of the wavelength point corresponding to the maximum projection value, and let
[0023] Step 35: Let SIf m < M, return to Step 32; otherwise, end the algorithm;
[0024] The wavelength variable combination finally extracted by the successive projections algorithm SPA is {k(m), m = 0,..., M - 1}.
[0025] In a preferred embodiment, Step 4 includes: establishing the spectral response between the main temperature and the slave temperature spectra, i.e., the conversion matrix F, which is calculated from the representative standard samples in the main temperature and slave temperature spectra; multiplying the spectrum of the unknown sample measured at the slave temperature by the conversion matrix F to correct the difference between the slave temperature spectrum and the main temperature spectrum;
[0026] The acquisition of the conversion matrix F is restricted to a local region of the spectrum; the standard sample spectrum at the main temperature is X m , X m The spectral response X m,i at wavelength i; the standard sample spectrum at the slave temperature is X s , X s The spectral response within a small window near wavelength i is Z i , Z i represents the spectral matrix of 2k + 1 points with a window size W from i - k to i + k on X s :
[0027] Z i = [X ss,j-k , X ss,j-k+1 , …, X ss,i+k-1 , X ss,i+k
[0028] Establish the mathematical relationship between X m,i and Z i :
[0029] X m,i = Z i b i + e i
[0030] where b iis the regression coefficient; e i is the residual vector; this equation is calculated by partial least squares method to calculate the regression coefficient b i , i=1, 2, …, p;
[0031] By b i The transformation matrix F is:
[0032]
[0033] The temperature correction formula of the PDS algorithm is obtained as follows:
[0034] X s,tr =X s,un F+E
[0035] Where: E is the residual matrix; X s,un is the spectrum of the unknown sample measured from the temperature, X s,tr It's X s,un The spectral matrix is obtained after temperature correction.
[0036] In a preferred embodiment, step 5 includes: taking the spectral data of the preprocessed spectral data obtained in step 2 at the characteristic wavelength that is stable under the influence of temperature in step 3, dividing the calibration set and the validation set using SPXY, and establishing a PLS pH value prediction model.
[0037] In a preferred embodiment, step 6 includes: selecting a validation set at any other temperature and using the same preprocessing method in step 2 to obtain preprocessed spectral data, substituting the spectral data corresponding to the characteristic wavelength that is stable under the influence of temperature into the temperature correction formula at the corresponding temperature to obtain temperature-corrected spectral data; finally, substituting the temperature-corrected spectral data into the main model to obtain the predicted value of the pH value of this validation set; the temperature of the main model is different from the temperature of the validation set.
[0038] The present invention also provides a water quality pH value optical detection device, which is applied to the temperature correction method of the above-mentioned water quality pH value spectrum detection; the device comprises a box, a rotating module, a water bath temperature control module, an optical fiber connection module, a display interaction module, a control processing module and a power access module;
[0039] The box includes a support body and a support plate. A plurality of support bodies are fixed to the bottom of the box in a rotationally symmetrical manner along the center. The other ends of the support bodies are connected to the support plate. The support plate is disc-shaped. A circular channel is provided in the middle of the support plate. The rotating module is arranged through the circular channel.
[0040] The rotating module includes a motor holder, a stepper motor, a connector, and a cuvette sample holder; the motor holder is mounted at the bottom of the box, the stepper motor is fixedly mounted on the motor holder, the connector is mounted on the output shaft of the stepper motor, and the connector is also connected to the cuvette sample holder, which is used to place samples and has a hollowed-out middle.
[0041] The water bath temperature control module includes a water tank, a semiconductor cooling plate, a PTC heating plate, and a temperature sensor. The water tank is placed on a support plate, and liquid is placed in the water tank. The PTC heating plate is installed in the water tank to heat the liquid in the water tank, the semiconductor cooling plate is installed in the water tank to cool the liquid in the water tank, and the temperature sensor is installed in the water tank to collect the temperature of the liquid in the water tank.
[0042] The fiber optic connection module includes a fiber optic connection platform, an incident fiber fixture, an output fiber fixture, an SMA905 fiber fixture, and a slide rail. The fiber optic connection platform is mounted on a support plate to connect an external incident fiber and an external output fiber. The incident fiber fixture is mounted on the slide rail and moves relative to the slide rail to adjust the appropriate optical path length. The output fiber fixture is mounted on the inner end of the fiber optic connection platform. There are two SMA905 fiber fixtures, one mounted on the incident fiber fixture and the other mounted on the output fiber fixture. The external incident fiber transmits the incident light to the sample by connecting to the SMA905 fiber fixture on the incident fiber fixture. The external output fiber receives the output light transmitted from the sample by connecting to the SMA905 fiber fixture on the output fiber fixture.
[0043] The display interaction module includes a display screen, a run button, and a rotary button. The display screen and the buttons are installed on the outer shell of the box. The display screen is used to display the actual temperature of the liquid in the water tank, as well as the set temperature and the temperature control time. The set temperature and temperature control time are adjusted by the setting button. Click the run button and the water bath temperature control module starts working, changing the temperature of the liquid by heating or cooling. After reaching the set temperature, the temperature of the liquid is allowed to stabilize through fine-tuning. The duration of the whole process is the temperature control time. After the temperature control is completed, the water bath temperature control module stops working and waits for the next button operation. There is also a rotary button. Click it and the motor in the rotary module rotates, thereby realizing the switching of samples.
[0044] The control processing module includes a control chip, which is electrically connected to the stepping motor, the semiconductor cooling plate, the PTC heating plate, the temperature sensor, the display screen operation button and the rotation button.
[0045] In a preferred embodiment, a plurality of slots are provided on the cuvette sample holder for placing samples; the control chip sends a control signal to the stepper motor, the stepper motor rotates to drive the connecting member to rotate, and the connecting member drives the cuvette sample holder to rotate.
[0046] In a preferred embodiment, the temperature sensor uses a single bus protocol, and the bus communication is realized through a control signal line. The temperature sensor collects the temperature of the liquid in the water tank and sends a temperature signal to the main control chip; the main control chip sends a heating signal to the PTC heating plate, and the PTC heating plate heats the liquid in the water tank; the main control chip sends a cooling signal to the semiconductor refrigeration plate, and the semiconductor refrigeration plate cools the liquid in the water tank.
[0047] Compared with the prior art, the present invention has the following beneficial effects:
[0048] 1. By selecting a band that is stable under the influence of temperature, the successive projection algorithm (SPA) is used to extract the characteristic wavelength variables related to temperature and pH value. This removes useless and interfering information, eliminates the irregular influence of temperature on the spectral wavelength variables, and improves the stability of the measurement model.
[0049] 2. The sample is heated evenly by water bath heating, avoiding the influence of inconsistent temperature of different parts of the sample due to uneven heating on the spectrum.
[0050] 3. It can hold 36 samples at the same time and control the temperature of all 36 samples at the same time. Compared with other cuvette experimental devices, this device is more efficient and can also ensure that all samples are heated and cooled in the same environment.
[0051] 4. The device is easy to operate, and there's no need to remove the sample each time you change it. Once 36 samples are placed in the device, temperature-controlled sampling can begin. Simply click the sample change button when you want to change samples. This also ensures that the samples are minimally affected by external temperature. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 The SDDSI curves of the spectra pre-processed at various temperatures and the spectra pre-processed at 20° C. according to the preferred embodiment of the present invention;
[0053] Figure 2 Schematic diagram of the distribution of characteristic wavelengths stable under temperature influence in the first sample of spectral data after preprocessing at 20° C. according to a preferred embodiment of the present invention;
[0054] Figure 3 The reference value and predicted value distribution diagrams of the validation set at four temperatures in the preferred embodiment of the present invention before and after temperature correction, (a) before temperature correction; (b) after temperature correction;
[0055] Figure 4 A schematic diagram of the device structure of a preferred embodiment of the present invention;
[0056] Figure 5 A half-sectional view of the device structure of a preferred embodiment of the present invention;
[0057] Figure 6 A schematic diagram of a rotation module according to a preferred embodiment of the present invention;
[0058] Figure 7 A half-sectional view of an optical fiber connection module according to a preferred embodiment of the present invention;
[0059] Figure numerals: 10 box, 11 support body, 12 support plate, 20 rotation module, 21 motor fixing seat, 22 stepping motor, 23 connecting part, 24 cuvette sample holder, 30 water bath temperature control module, 31 water tank, 32 semiconductor refrigeration plate, 33 PTC heating plate, 34 temperature sensor, 35 temperature control module, 40 optical fiber connection module, 41 optical fiber connection platform, 42 incident optical fiber fixing body, 43 output optical fiber fixing body, 44 SMA905 optical fiber fixing part, 45 slide rail, 50 display interaction module, 51 run button, 52 rotation button, 53 display screen, 60 power access module, 70 sample, 80 control processing module. DETAILED DESCRIPTION
[0060] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0061] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present application belongs.
[0062] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application; as used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form, and it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or their combinations.
[0063] A temperature correction method for water quality pH value spectrum detection, reference Figure 1-7 , the specific steps are:
[0064] Step (1) prepares samples with different pH values, measures the pH value of each pH value sample, and uses the above-mentioned transmission experimental device with temperature adjustment function with a spectrometer, a light source and an optical fiber to build a visible / near-infrared spectral water quality pH value optical detection device to collect visible / near-infrared spectral data at different temperatures.
[0065] Step (2) preprocesses the collected spectral data at different temperatures.
[0066] Step (3) screens the temperature-stable wavelengths of the preprocessed spectral data, and then uses a characteristic variable optimization algorithm to select characteristic wavelengths that are stable due to temperature effects.
[0067] Step (4) uses a temperature correction algorithm to establish a temperature correction matrix for the characteristic wavelengths at different temperatures.
[0068] Step (5) establishes a pH prediction model using the characteristic wavelength at the main temperature
[0069] Step (6) inputs the characteristic wavelengths at other temperatures into the pH value prediction model after temperature correction to complete the pH value prediction.
[0070] Each step specifically includes:
[0071] Step (1):
[0072] Samples with varying pH values were prepared by randomly adding 0.1 mol / L HCl solution or 0.1 mol / L NaOH solution to distilled water. The pH values of the samples were measured using a pH meter with an accuracy of ±0.01 pH units. A total of 32 samples were prepared, with a pH range of 3.67 to 9.10, an average of 6.38, and a standard deviation of 1.59.
[0073] The spectrometer used was a visible-near-infrared spectrometer (FLAME-T-XR1–RS), collecting 2860 wavelength points from 400 to 1049 nm. The optical fiber used was a transmission fiber from Ocean Optics (US) and a halogen light source (HL-2000-LL). These, along with a 1-cm quartz cuvette and a temperature-controlled transmission experimental setup, were used to construct a visible / near-infrared spectroscopy optical water quality pH measurement device.
[0074] The spectrum acquisition steps are:
[0075] 1) One end of the incident fiber of the transmission fiber is connected to a halogen light source, and the other end is connected to the SMA905 fixture of the incident fiber fixture of a transmission-type experimental device with temperature control. One end of the output fiber of the transmission fiber is connected to the SMA905 fixture of the output fiber fixture, and the other end is connected to a spectrometer. The spectrometer is connected to a host computer for data acquisition, and the optical path length can be fine-tuned by moving the incident fiber fixture.
[0076] 2) Place 32 samples in 1cm quartz cuvettes and place them in the cuvette sample holder. Then add water to the water tank to a height that is 1 / 2 the height of the samples.
[0077] 3) Click the power button to initialize the system and the actual temperature of the liquid in the tank will be displayed on the screen.
[0078] 4) Set the temperature to 20°C and the temperature control time to 1 hour using the setting button in the display interaction module.
[0079] 5) Click the Start button. The control module begins temperature control of the liquid. After 50 minutes, the computer collects the first sample's spectral data. Then, click the Sample Change button to collect the second sample's spectral data. Repeat this process until all 32 samples have been collected. Then, click the Sample Change button five times in a row to ensure that the first sample remains in the first position.
[0080] 6) Continue to repeat steps 4) to 5) to continue collecting spectral data at four temperatures: 30°C, 40°C, 50°C, and 60°C. So far, a total of spectral data at five temperatures have been collected.
[0081] Step (2):
[0082] The spectral data at each temperature were preprocessed by using a second-order polynomial, Savitzky-Golay convolution smoothing (SG) with 21 smoothing points (SG(2,21)) and standard normal variable transformation (SNV) to remove the influence of surface scattering and background noise on the spectrum.
[0083] Step (3):
[0084] After preprocessing the spectral data, a reference temperature is selected. Standard deviation differential spectral analysis (SDDSI) is performed between the reference temperature spectrum and spectra at other temperatures. Temperature-stable bands are selected based on the prediction accuracy of modeling across different bands. Successive projections (SPA) are then used to optimize characteristic wavelengths within these temperature-stable bands. Finally, a multivariate calibration model is established, selecting temperature-stable characteristic wavelengths based on the minimum root mean square error (RMSEP).
[0085] Step 3.1: The standard deviation of the difference spectrum between the reference temperature spectrum and the other temperature spectra in step (3) is calculated as follows:
[0086]
[0087] Among them A ij =M ij -S ij , i and j represent the number of samples and wavelengths respectively. m is the number of samples used for wavelength selection. A is the difference spectrum between the spectrum at the reference temperature and the spectrum at other temperatures. is the average spectrum of all samples of A, for Spectral response at the j-th wavelength; M ij and S ij are the spectral responses at the j-th wavelength of the i-th sample at the reference temperature and other temperatures, respectively. The smaller SDDSI(j) is, the higher the spectral signal consistency between the reference temperature and other temperatures is.
[0088] Step 3.2: The calculation steps for feature variable optimization using the successive projections algorithm (SPA) on the bands stable against temperature effects are as follows:
[0089] (1) Initialization: Set the number of wavelengths M to be extracted. Before the first iteration (m = 1), arbitrarily select the j-th column x N×p of X j denoted as x k(0) , k(0) = j, j ∈ 1, …, p.
[0090] (2) Denote the set of positions of the column vectors not yet selected as
[0091] (3) Calculate the projections j of the remaining column vectors x k(m-1) (j ∈ S) onto the current column vector x
[0092] (4) Select the serial number of the wavelength point corresponding to the maximum projection, and let
[0093] (5) Let If m < M, return to step (2); otherwise, end the algorithm.
[0094] (6) The wavelength variable combination finally extracted by SPA is {k(m), m = 0, …, M - 1}.
[0095] The specific implementation process of step (3) in this example is as follows:
[0096] The standard deviation curve (SDDSI) of the difference spectrum between the preprocessed spectrum with 20 °C as the reference temperature and the spectra at other temperatures is shown as Figure 1 Each SDDSI curve at each temperature has valleys near the 1000th (645.49 nm) and 2000th (871.73 nm) wavelength points, that is, the consistency of the spectral variation of the samples near this wavelength is better affected by temperature.
[0097] With the 1000th wavelength point as the center, the wavelengths of 100 wavelength points on each side are extracted, and a total of 201 wavelength points SDDSI1 from 900 to 1100 (621.76 to 669.02 nm) are obtained; with the 2000th wavelength point as the center, the wavelengths of 100 wavelength points on each side are extracted, and a total of 201 wavelength points SDDSI2 from 1900 to 2100 (850.04 to 893.20 nm) are obtained.
[0098] Ten sets of spectral data, totaling 10 at five temperatures, were collected at wavelengths SDDSI1 and SDDSI2. Each set of data was divided into a calibration set and a validation set using the SPXY method, and a partial least squares (PLS) multivariate calibration model was established. Table 1 shows that the root mean square error (RMSEP) of the predictions for the validation set of the PLS multivariate calibration model corresponding to the spectral data at wavelength SDDSI1 was smaller than the root mean square error (RMSEP) of the predictions for the validation set of the PLS multivariate calibration model corresponding to the spectral data at wavelength SDDSI2. This indicates that this region contains a wealth of spectral information and can be used to establish a water pH detection model. Therefore, the wavelength band corresponding to wavelength SDDSI1 was selected as the band that is stable under temperature influence.
[0099] Table 1 Prediction results of PLS models for various temperatures in different SDDSI bands
[0100]
[0101] Then, the spectral data of all temperatures in the bands that are stable under temperature influence are subjected to variable optimization using the successive projection algorithm (SPA). Because there are 22 calibration sets, the number of variables selected based on SPA cannot exceed the number of modeling samples. To maximize the retention of spectral information, the number of variables selected by SPA is 20.
[0102] After SPA variable optimization, the spectral data of each temperature-stable band were divided into a calibration set and a validation set using SPXY, with 22 calibration sets and 10 validation sets. A PLS multivariate calibration model was then established, as shown in Table 2.
[0103] Table 2 Prediction results of the model after SPA variable optimization for the bands stable under temperature influence
[0104]
[0105] Under the PLS multivariate calibration model corresponding to 20°C, the model validation set achieved the lowest root mean square error (RMSEP), indicating the highest prediction accuracy. Therefore, the 20°C model was selected as the master model, with 20°C as the master temperature and the other temperatures as slave temperatures. The wavelengths in the calibration set under the 20°C model are the characteristic wavelengths that are stable under temperature. The characteristic wavelengths that are stable under temperature are 621.76, 632.22, 624.62, 664.80, 634.36, 636.49, 653.04, 667.38, 650.68, 639.34, 669.02, 645.49, 659.16, 626.52, 647.61, 656.33, 641.47, 661.27, 649.03, and 662.92 nm. The distribution of characteristic wavelengths that are stable under temperature influence in the first sample of spectral data after preprocessing at 20℃ is as follows: Figure 2 shown.
[0106] Step (4):
[0107] A temperature correction algorithm is used to establish a temperature correction matrix for characteristic wavelengths that are stable under temperature influence at different temperatures. Spectral data at characteristic wavelengths that are stable under temperature influence at five temperatures are extracted. The Kennard-Stone (KS) algorithm is used to select representative samples from the 20°C spectral data in these spectral data. The number of selected samples does not exceed the total number of samples. At the same time, samples corresponding to the representative samples in the 20°C spectral data are selected from the four groups of temperature spectral data. Four groups of standard samples are obtained. The four groups of standard samples are input into the PDS algorithm to obtain the temperature correction formula X s,tr =X s,un F+E, four groups in total.
[0108] The PDS algorithm establishes the spectral response between the master and slave temperature spectra, namely the conversion matrix F. This conversion matrix F is calculated from representative standard samples of the master and slave temperature spectra. By multiplying the unknown sample spectrum measured at the slave temperature by the conversion matrix F, the difference between the slave and master temperature spectra can be corrected, thus achieving temperature correction.
[0109] The acquisition of the conversion matrix F is limited to a local area of the spectrum. The spectrum of the standard sample at the main temperature is X m , X m Spectral response X at wavelength i m,i ; From the standard sample spectrum at temperature X s , X s The spectral response in a small window around wavelength i is Z i , Z i Represents X sThe spectral matrix of the window size W from i-k to i+k is 2k+1 points:
[0110] Z i =[X ss,j-k ,X ss,j-k+1 ,…,X ss,i+k-1 , X ss,i+k ]
[0111] Build X m,i With Z i The mathematical relationship between:
[0112] X m,i =Z i b i +e i
[0113] where b i is the regression coefficient; e i is the residual vector. This equation is calculated by partial least squares method to calculate the regression coefficient b i , i=1, 2,…, p.
[0114] By b i The conversion matrix F can be obtained:
[0115]
[0116] The temperature correction formula of the PDS algorithm is obtained as follows:
[0117] X s,tr =X s,un F+E
[0118] Where: E is the residual matrix; X s,un is the spectrum of the unknown sample measured from the temperature, X s,tr It's X s,un The spectral matrix is obtained after temperature correction.
[0119] Step (5):
[0120] The spectral data at 20°C obtained in step 2 after pretreatment are taken as the spectral data at the characteristic wavelength that is stable under the influence of temperature in step 3, and the calibration set and validation set are divided using SPXY, and a PLS pH value prediction model is established.
[0121] Step (6):
[0122] Select a validation set at any of 30°C, 40°C, 50°C, or 60°C and use the same preprocessing method as in Step 2 to obtain preprocessed spectral data. Substitute the spectral data corresponding to the characteristic wavelength that is stable under temperature into the temperature correction formula at the corresponding temperature to obtain the temperature-corrected spectral data. Finally, substitute the temperature-corrected spectral data into the main model at 20°C to obtain the predicted pH value for this validation set.
[0123] Figure 3 The following diagram shows the distribution of reference and predicted values for the validation set at four temperatures, 30°C, 40°C, 50°C, and 60°C, before and after temperature correction. (a) shows the prediction results for the spectral data without temperature correction, and (b) shows the prediction results for the spectral data with temperature correction. Table 3 shows the prediction results of the master model using the temperature spectral data at 20°C after temperature correction. It can be seen that before temperature correction, the master model's prediction results for the validation set at the four temperatures had significant errors. After temperature correction using SDDSI-SPA-PDS, the prediction errors for the validation set were reduced.
[0124] Table 3 Prediction results of the four temperature validation sets in the main model at 20℃ after temperature correction
[0125]
[0126] The advantages of this temperature correction algorithm are:
[0127] By selecting the bands that are stable under the influence of temperature, the successive projection algorithm (SPA) is used to extract the characteristic wavelength variables related to temperature and pH value. This removes useless and interfering information, eliminates the irregular influence of temperature on the spectral wavelength variables, and improves the stability of the measurement model.
[0128] The principles and functions of each step of the temperature correction method are as follows:
[0129] The SDDSI algorithm calculates the standard deviation of the differential spectrum between the primary and secondary instruments, used here to process spectral data at different temperatures. According to the SDDSI algorithm, the degree and direction of spectral variation at different temperatures can be reflected in the differential spectrum. The standard deviation of the differential spectrum (SDDSI) processing can be used to observe the stability of the differential spectrum. A smaller SDDSI indicates less dispersion in the differential spectrum and greater stability, indicating a higher consistency in spectral variation at different temperatures. Selecting a band with a smaller SDDSI as the temperature correction region maximizes the resolution of temperature issues. Compared to using the entire spectrum, there is less concern about the conversion matrix over-converting non-temperature-consistent bands, leading to reduced model accuracy.
[0130] The Successive Projection Algorithm (SPA) is a forward-loop selection method that selects a spectral variable and calculates its projection onto the unselected variables. The wavelength with the largest projection vector is then added to the wavelength set. This process is iterated repeatedly, ensuring that each selected wavelength minimizes its linear relationship with the previous one, ultimately resulting in a wavelength set with minimal collinearity. The SPA algorithm removes redundant information from the spectrum and identifies the characteristic wavelength in the spectrum with the least linear relationship affected by pH.
[0131] (3) The PDS algorithm establishes the spectral response between the master and slave temperature spectra, namely the conversion matrix F. This conversion matrix F is usually calculated from representative standard samples of the master and slave temperature spectra. Multiplying the unknown sample spectrum measured from the slave temperature by the conversion matrix F can correct the difference between the master and slave temperature spectra, thereby achieving temperature correction. For the PDS algorithm, the acquisition of the conversion matrix F is limited to a local region of the spectrum. Therefore, the PDS algorithm has the characteristics of local correction and is suitable for multivariate correction.
[0132] Therefore, by using the local correction characteristics of the PDS algorithm to jointly screen the characteristic variables of the SDDSI algorithm and the SPA algorithm, it is possible to achieve efficient and accurate correction of characteristic wavelengths with high stability in spectral variation affected by temperature and small linear relationship.
[0133] An optical detection device for pH value of water quality Figure 5 As shown, it includes a box 10, a rotating module 20, a water bath temperature control module 30, an optical fiber connection module 40, a display interaction module 50, a control processing module 80 and a power access module 60.
[0134] The box 10 is provided with a support body 11 and a support plate 12. There are six support bodies 11 fixed to the bottom surface of the box 10 for fixing the support plates 12. The support plates 12 are placed on the support bodies 11 with screws. The support plates 11 are disc-shaped with a circular channel in the middle. The rotating module 20 runs through the circular channel.
[0135] like Figure 5 As shown, the rotating module 20 is set on the support plate 12 and passes through the circular channel of the support plate 12 for switching different samples. The rotating module 20 includes a motor fixing base 21, a stepper motor 22, a connecting piece 23, and a cuvette sample holder 24. The motor fixing base 21 is installed on the box just below the circular channel of the support plate 11 to place the stepper motor 22. Figure 6As shown, a stepper motor 22 is mounted on a motor mount 21 to provide circumferential rotation. A connector 23 is fixed to the output shaft of the stepper motor 22. The bottom end of the cuvette sample holder 24 cooperates with the connector 23 to achieve circumferential rotation to drive the sample 70 to rotate. The cuvette sample holder 24 has 36 slots and can accommodate 36 samples. The connector 23 drives the cuvette sample holder 24 to rotate 10 degrees each time, that is, each time a sample is converted. 36 samples need to rotate 360 degrees, which is exactly one rotation.
[0136] like Figure 5 As shown, the water bath temperature control module 30 is installed on the support body 11 for controlling the temperature of the sample 70. The water bath temperature control module 30 includes a water tank 31, a semiconductor cooling sheet 32, a PTC heating sheet 33, a temperature sensor 34 and a temperature control module 35. The semiconductor cooling sheet 32 is installed in the water tank 31 to cool the water in the water tank, the PTC heating sheet 33 is installed in the water tank 31 to heat the water in the water tank, and the temperature sensor 34 is installed in the water tank 31 to collect the water temperature in the water tank. The temperature control module 35 is installed on the box 10 and is connected to the semiconductor cooling sheet 32, the PTC heating sheet 33 and the temperature sensor 34 to control the semiconductor cooling sheet 32, the PTC heating sheet 33 and the temperature sensor 34 to achieve water temperature control. Temperature sensor 34 adopts DS18B20 temperature sensor, uses single bus protocol, and bus communication is realized through a control signal line. The temperature measurement range is -50 ~ 150 ° C, with multiple resolutions optional, and the temperature division can reach 0.0625 ° C. Compared with other temperature sensors, it has higher accuracy.
[0137] like Figure 4 As shown, the optical fiber connection module 40 is installed on the support plate 12 to connect the external incident optical fiber and the output optical fiber. Figure 7 As shown, the fiber connection module 40 includes a fiber connection platform 41, an incident fiber fixture 42, an exit fiber fixture 43, an SMA905 fiber fixture 44, and a slide rail 45. The incident fiber fixture 42 is mounted on the slide rail 45 and can be slightly moved relative to the slide rail to adjust the appropriate optical path length. The exit fiber fixture 43 is mounted on the inner end of the fiber connection platform 41. There are two SMA905 fiber fixtures 44: one mounted on the incident fiber fixture 42 and the other mounted on the exit fiber fixture 43. The external incident fiber transmits incident light to the sample 70 by connecting to the SMA905 fiber fixture 44 on the incident fiber fixture 42. The external exit fiber receives exit light transmitted from the sample 70 by connecting to the SMA905 fiber fixture 44 on the exit fiber fixture 43.
[0138] The power access module is connected to the external power supply to enable all parts of the device to work normally.
[0139] like Figure 4 As shown, the control processing module 80 is installed on the side wall inside the box to control the operation of the entire device, and the power access module 60 is installed on the outer wall of the box to provide power to the device.
[0140] The specific experimental steps of the above device are:
[0141] Step 1: Connect the external input fiber and output fiber to the device, and fine-tune the optical path length by moving the input fiber fixture.
[0142] Step 2: Place 36 samples in the cuvette sample rack in the rotating module in sequence, and then add liquid to the water tank to cool and heat the samples. Be careful not to add too much liquid, and do not exceed 1 / 2 of the sample height.
[0143] Step 3. Click the power button, the system initializes, and the actual temperature of the liquid in the current tank is displayed on the screen.
[0144] Step 4: Set the set temperature and temperature control time through the display interaction module. The control module will set the temperature and temperature control time according to the input of the buttons and display them on the display screen.
[0145] Step 5: Click the Start button. The control module activates the cooling element or heating element to control the temperature of the liquid in the water tank. If the set temperature is lower than the actual temperature of the liquid in the water tank, the control module activates the semiconductor cooling element to cool it. If the set temperature is higher than the actual temperature of the liquid in the water tank, the control module activates the PTC heating element to heat it. When the temperature of the liquid in the water tank approaches the set temperature, the control module activates the semiconductor cooling element and PTC heating element to switch between them continuously to stabilize the temperature. The entire temperature control process begins when the Start button is clicked and ends when the temperature control time is reached.
[0146] Step 6. During the temperature control time of step 5, the spectrum data of all samples must be collected. Generally, sampling begins ten minutes before the end of the temperature control time. The external spectrometer equipment is connected to the computer host software, and sampling can be performed on the host computer. There is a sample change button in the display interaction module of this device. After completing the data collection of a sample spectrum, click the sample change button. The cuvette sample holder rotates 10° with the cooperation of the motor and locates the next sample in the middle of the light path. Then click the sampling button to complete the sampling of the second sample. Repeat this process continuously to complete the collection of all sample spectra in the cuvette sample holder.
[0147] Step 7: After data collection is completed, repeat steps 4 to 6 to complete the spectrum data collection of all samples at the next temperature.
Claims
1. A temperature correction method for water quality pH value spectrum detection, characterized in that: The following steps are involved: Step 1: Prepare samples with different pH values, measure the pH value of each pH sample, and use a water quality pH optical detection device to collect visible / near-infrared spectral data of the samples at different temperatures; Step 2: Preprocess the collected spectral data of samples at different temperatures; Step 3: After screening the temperature-stable wavelengths of the pre-processed spectral data, a characteristic variable optimization algorithm is used to select the characteristic wavelengths with stable temperature effects; Step 4: Use the temperature correction algorithm to establish a temperature correction matrix for the characteristic wavelengths at different temperatures; Step 5: Establish a pH prediction model using the characteristic wavelength at the main temperature; Step 6: Input the characteristic wavelengths at other temperatures into the pH prediction model after temperature correction to complete the pH value prediction.
2. The temperature correction method for water quality pH value spectrum detection according to claim 1, characterized in that: In step 3, a temperature is selected as the reference temperature, and the standard deviation of the differential spectrum is processed between the reference temperature spectrum and the other temperature spectra. The band that is stable under the influence of temperature is selected according to the prediction accuracy of modeling in different bands. Then, the continuous projection algorithm SPA characteristic wavelength optimization is performed on the band that is stable under the influence of temperature. Finally, a multivariate correction model is established, and the characteristic wavelength that is stable under the influence of temperature is selected based on the principle of minimum prediction root mean square error RMSEP.
3. The temperature correction method for water quality pH value spectrum detection according to claim 2, characterized in that: In step 3, the standard deviation SDDSI(j) of the difference spectrum between the reference temperature spectrum and the other temperature spectra is processed as follows: Among them A ij =M ij -S ij , i and j represent the number of samples and wavelengths respectively; m is the number of samples used for wavelength selection; A is the difference spectrum between the spectrum at the reference temperature and the spectrum at other temperatures, is the average spectrum of all samples of A, for Spectral response at the jth wavelength; M ij and S ij are the spectral responses of the i-th sample at the j-th wavelength at the reference temperature and other temperatures, respectively. The smaller the SDDSI(j), the higher the consistency of the spectral signals between the reference temperature and other temperatures.
4. The temperature correction method for water quality pH value spectrum detection according to claim 3, characterized in that: In step 3, the calculation steps for the optimal SPA characteristic variable of the continuous projection algorithm on the band that is stable under the influence of temperature are as follows: Step 31: Initialization: Set the number of wavelengths to be extracted M. Before the first iteration m = 1, select X N×p The jth column x j Denoted as x k(0) , k(0)=j,j∈1,…,p;where X N×p is the spectrum matrix, N is the number of samples, p is the total number of wavelengths, x j For X N×p The spectral response of the jth column, k is a custom set, and k(m) is used to record the selected column; Step 32: Record the set of column vector positions that are not selected as Step 33: Calculate the remaining column vectors x separately j With the current column vector Projection Step 34: Select the wavelength point number corresponding to the maximum projection value, and let Step 35: Let m = m + 1: If m < M, then return to Step 32; otherwise, end the algorithm; Step 36: The wavelength variable combination finally extracted by the continuous projection algorithm SPA is {k(m), m=0, ..., M-1}.
5. The temperature correction method for water quality pH value spectrum detection according to claim 1, characterized in that: Step 4 includes: establishing a spectral response between the master temperature and the slave temperature spectra, i.e., a conversion matrix F, wherein the conversion matrix F is calculated from representative standard samples of the master temperature and the slave temperature spectra; multiplying the unknown sample spectrum measured at the slave temperature by the conversion matrix F to correct the difference between the slave temperature spectrum and the master temperature spectrum; The acquisition of the conversion matrix F is limited to a local area of the spectrum; the spectrum of the standard sample at the main temperature is X m , X m Spectral response X at wavelength i m,i ; From the standard sample spectrum at temperature X s , X s The spectral response in a small window around wavelength i is Z i , Z i Represents X s The spectral matrix of the window size W from i-k to i+k is 2k+1 points: Z i =[X ss,j-k ,X ss,j-k+1 ,…,X ss,i+k-1 ,X ss,i+k ] Build X m,i With Z i The mathematical relationship between: X m,i =Z i b i +e i where b i is the regression coefficient; e i is the residual vector; this equation is calculated by partial least squares method to calculate the regression coefficient b i , i=1, 2, …, p; By b i The transformation matrix F is: The temperature correction formula of the PDS algorithm is obtained as follows: X s,tr =X s,un F+E Where: E is the residual matrix; X s,un is the spectrum of the unknown sample measured from the temperature, X s,tr It's X s,un The spectral matrix is obtained after temperature correction.
6. The temperature correction method for water quality pH value spectrum detection according to claim 1, characterized in that: Step 5 includes: taking the spectral data of the preprocessed spectral data obtained in step 2 at the characteristic wavelength stable under the influence of temperature in step 3, dividing the calibration set and the validation set using SPXY, and establishing a PLS pH value prediction model.
7. The temperature correction method for water quality pH value spectrum detection according to claim 1, characterized in that: Step 6 includes: selecting a validation set at any other temperature and using the same preprocessing method as in step 2 to obtain preprocessed spectral data, substituting the spectral data corresponding to the characteristic wavelength that is stable under the influence of temperature of the preprocessed spectral data into the temperature correction formula at the corresponding temperature to obtain temperature-corrected spectral data; finally, substituting the temperature-corrected spectral data into the main model to obtain the predicted value of the pH value of this validation set; the temperature of the main model is different from the temperature of the validation set.
8. An optical detection device for pH value of water quality, characterized in that A temperature correction method for water quality pH value spectral detection as described in any one of claims 1 to 7; It includes a box, a rotating module, a water bath temperature control module, an optical fiber connection module, a display interaction module, a control processing module and a power access module; The box includes a support body and a support plate. A plurality of support bodies are fixed to the bottom of the box in a rotationally symmetrical manner along the center. The other ends of the support bodies are connected to the support plate. The support plate is disc-shaped. A circular channel is provided in the middle of the support plate. The rotating module is arranged through the circular channel. The rotating module includes a motor holder, a stepper motor, a connector, and a cuvette sample holder; the motor holder is mounted at the bottom of the box, the stepper motor is fixedly mounted on the motor holder, the connector is mounted on the output shaft of the stepper motor, and the connector is also connected to the cuvette sample holder, which is used to place samples and has a hollowed-out middle. The water bath temperature control module includes a water tank, a semiconductor cooling plate, a PTC heating plate, and a temperature sensor. The water tank is placed on a support plate, and liquid is placed in the water tank. The PTC heating plate is installed in the water tank to heat the liquid in the water tank, the semiconductor cooling plate is installed in the water tank to cool the liquid in the water tank, and the temperature sensor is installed in the water tank to collect the temperature of the liquid in the water tank. The optical fiber connection module includes an optical fiber connection platform, an input optical fiber fixing body, an output optical fiber fixing body, an SMA905 optical fiber fixing member, and a slide rail. The optical fiber connection platform is mounted on a support plate to connect the external input optical fiber and the external output optical fiber. The input optical fiber fixing body is mounted on the slide rail and moves relative to the slide rail to adjust the appropriate optical path length. The output optical fiber fixing body is mounted on the inner end of the optical fiber connection platform. There are two SMA905 optical fiber fixing parts, one is installed on the incident optical fiber fixing body, and the other is installed on the output optical fiber fixing body; The external input optical fiber transmits the incident light to the sample by connecting to the SMA905 optical fiber fixture on the input optical fiber fixture, and the external output optical fiber receives the output light transmitted from the sample by connecting to the SMA905 optical fiber fixture on the output optical fiber fixture; The display interaction module includes a display screen, a run button, and a rotary button. The display screen and the buttons are installed on the outer shell of the box. The display screen is used to display the actual temperature of the liquid in the water tank, as well as the set temperature and the temperature control time. The set temperature and temperature control time are adjusted by the setting button. Click the run button and the water bath temperature control module starts working, changing the temperature of the liquid by heating or cooling. After reaching the set temperature, the temperature of the liquid is allowed to stabilize through fine-tuning. The duration of the whole process is the temperature control time. After the temperature control is completed, the water bath temperature control module stops working and waits for the next button operation. There is also a rotary button. Click it and the motor in the rotary module rotates, thereby realizing the switching of samples. The control processing module includes a control chip, which is electrically connected to the stepping motor, the semiconductor cooling plate, the PTC heating plate, the temperature sensor, the display screen operation button and the rotation button.
9. The optical detection device for pH value of water quality according to claim 1, characterized in that: The cuvette sample holder is provided with a plurality of notches for placing samples; the control chip sends a control signal to the stepper motor, the stepper motor rotates to drive the connecting member to rotate, and the connecting member drives the cuvette sample holder to rotate.
10. The optical detection device for pH value of water quality according to claim 1, characterized in that: The temperature sensor uses a single bus protocol, and bus communication is achieved through a control signal line. The temperature sensor collects the temperature of the liquid in the water tank and sends a temperature signal to the main control chip; the main control chip sends a heating signal to the PTC heating plate, and the PTC heating plate heats the liquid in the water tank; the main control chip sends a cooling signal to the semiconductor refrigeration plate, and the semiconductor refrigeration plate cools the liquid in the water tank.