1 Introduction

Due to the continuous increase of greenhouse gases, a series of environmental problems seriously affecting human production and life such as global warming, rising sea level and ozone layer hole are becoming increasingly prominent [1]. In order to deal with the above crisis, the real-time detection of greenhouse gases is essential.Among them, methane (CH4) and carbon dioxide (CO2) gas are the main components of greenhouse gases, and real-time accurate detection of them will provide important scientific basis for the prediction of the development trend of greenhouse gases and the formulation of energy conservation, emission reduction and environmental management strategies [2]. At present, researchers have developed various sensing devices for the above gases, among which the cavity ring-down spectroscopy (CRDS) has attracted much attention due to its high measurement accuracy, short response time, convenient sampling, high potential for integration and non-invasive measurement advantages [3,4,5,6]. Moreover, CRDS determines the concentration of the gas in the cavity by analyzing the ring-down time of light within the gas cell, making it less susceptible to fluctuations in the light source. This results in increased resistance to interference and improved accuracy. Additionally, due to multiple reflections of light within the gas cell, the actual optical path interacting with the sample gas can reach thousands of times the cavity length, providing CRDS with exceptionally high sensitivity.

In recent years, CRDS has been widely used in the accurate measurement of various gases in the atmosphere [7,8,9,10]. However, the measurement of a certain gas alone can no longer meet the practical application needs. How to realize the synchronous detection of various gases by CRDS has become a hot research field. Using multi-laser array or multi-gas chamber is one of the common methods to realize multi-type gas measurement [11, 12]. However, this method will make the gas sensor system complicated, poor stability and high cost. Another commonly method is to employ a tunable laser to cover the respective spectral lines of different gases. For example, Chen et al. used the CRDS gas analyzer to complete the continuous measurement of CO2 and CH4 over the Amazon rainforest [13]. Wei et al. proposed a method based on CRDS technique for simultaneous measurement of CH4, N2O, and residual H2O concentrations [14]. Although these methods are straight forward, it is difficult to avoid the problem of spectral line crosstalk. Besides, combining multiple photodetectors with time-division multiplexing (TDM) or frequency-division multiplexing (FDM) for measuring spectral line of different gas is a viable approach. Dong et al. develop a TDM-based multi-gas measurement system by using a single broadband light source [15]. Chen et al. measured methane isotope ratios using an optical-switched dual-wavelength CRDS system [16]. Quartz enhanced photoacoustic spectroscopy (QEPAS) sensor for simultaneous detection of CH4 and H2O using FDM technology was reported by Wu et al. [17].

Furthermore, to enhance detection sensitivity, it is crucial to perform rapid and effective denoising of spectral data [18]. During the use of the CRDS system, fluctuations in the ring-down time are almost impossible to completely eliminate from a hardware perspective, so it always carries a certain amount of noise when measuring absorption spectra. Especially when approaching the absorption peak position, due to the strong absorption of gas by the laser, the ring-down time will be shorter, and the fluctuations during the measurement process will be more prominent. Various denoising algorithms, such as moving average, wavelet transformation [19], Kalman filtering [20, 21], and Savitzky-Golay filtering [22, 23], have been reported. However, the moving average method is suitable only for processing white noise and is time-consuming. Wavelet transformation requires complex parameters and calculations, limiting its filtering capability. Although the Kalman filtering method has been widely used in various spectral signal processing fields, it still has certain shortcomings in handling nonlinear signal processing, potentially causing significant deviations in spectral absorption. The Savitzky-Golay filtering algorithm, due to its requirement for a moving window, exhibits poor filtering performance at the data boundaries. In comparison to the aforementioned algorithms, the Whittaker-Henderson (W-H) filter algorithm, based on the principle of least squares multiplication, can eliminate high-frequency noise and clutter from the signal and adaptively handle data boundaries, effectively smoothing the entire dataset [24, 25]. It emerges as a superior filtering algorithm. However, determining the optimal values for the W-H filter algorithm’s weight parameters poses a challenge when manually calculated.

In this paper, grounded in the concept of time-division multiplexing (TDM), a CRDS sensing system capable of simultaneously measuring CH4 and CO2 in the atmosphere by using a mechanical optical switch to swiftly switch the laser wavelength is developed. The mechanical optical switch has the advantages of low insertion loss, high isolation and difficult crosstalk. To effectively reduce signal noise, a convolutional neural network (CNN)-based adaptive W-H filtering algorithm is proposed. Inputting novel spectral data into a pre-trained CNN model enables the rapid acquisition of optimal parameters for the Whittaker-Henderson filtering algorithm, leading to effective denoising. Experimental results demonstrate that the CRDS system can perform fast detection of CH4 and CO2 simultaneously, with detection limits of 2 ppb and 0.16 ppm, respectively. The system exhibits excellent stability and holds promise for synchronous detection of multiple gas components by incorporating lasers of different wavelengths.

2 Theoretical framework and experimental details

2.1 Experimental system design

Figure 1 is the schematic diagram of the proposed CRDS system experimental setup designed for simultaneous detection of CH4 and CO2 gas.The laser output section comprises two distributed feedback (DFB) lasers, two isolators, a mechanical optical switch, and a collimator. The two DFB lasers (NEL, NLK1U5FAAA and NLK1L5GAAA) operate at central wavelengths of 1650 nm and 1600 nm, with linewidths of approximately ∼2 MHz. The mechanical optical switch used (CORERAY, 1550 nm MEMS 1 × 2 PM Switch) operates under computer program control, with a wavelength switch time of less than 50 ms. The gas cell consists of a 50 cm absorption cell, a pair of one-inch diameter mirrors (Layertec), and a piezoelectric ceramic (Coremorrow, NAC2125) for adjusting the cavity length. The reflectance of the mirrors is R ≈ 99.994% (centered at a 1.6 μm). The calculated free spectral range (FSR) of the cavity is 300 MHz, with a finesse of 52,300, equivalent to a cavity length exceeding 5 km. The gas control section comprises a pressure controller (Alicat, IVC-Series), a vacuum pump, a flowmeter (Alicat, MC-Series), and a gas desiccant. When measuring sample gas, the flow rate of reference gas and nitrogen gas, controlled by a flowmeter, is adjusted to change the concentration of the sample gas. Simultaneously, a gas desiccant reduces the water vapor concentration of methane and carbon dioxide in the atmospheric environment from around 20,000 ppm to approximately 400 ppm, thereby minimizing the impact of water vapor on measurement results.The signal detection and laser control section consists of a photodetector (Thorlab, APD430C), a shut-off trigger board, and a computer. The photodetector converts received light signals into electrical signals, transmitting them to both the computer and the shut-off trigger board. When the electrical signal reaches the trigger threshold (usually set at 0.5 V), the shut-off trigger board issues a command to stop the laser. The shut-off time is 0.2 ms, allowing for the recording of a complete ring-down curve. Additionally, the computer’s built-in data acquisition card automatically collects signals and fits the ring-down time τ using Eq. (1):

$$\text{I}\left(\text{t}\right)={\text{I}}_{0}\text{e}\text{x}\text{p}(-\frac{\text{t}}{{\tau }})+\text{b}$$
(1)

where I(t) is the light intensity that varies with time t, I0 is the initial light intensity, and b is the bias amount when fitting the ring-down time.

Subsequently, Eq. (2) is used to calculate the absorption coefficient:

$${\alpha }\left(\upsilon \right)=\frac{1}{\text{c}}(\frac{1}{\tau \left(\upsilon \right)}-\frac{1}{{\tau }_{empty}})$$
(2)

Here, c represents the speed of light, τ and τempty are the ring-down times when the target gas is absorbed and when the cavity is empty, respectively. Finally, using Eq. (3), the concentration of the target gas is calculated:

$$\chi =\frac{\text{RT}}{{\text{N}}_{\text{A}}\text{P}}\cdot \frac{{\alpha }\left(\upsilon \right)}{\sigma \left(\upsilon \right)}$$
(3)

Here, NA is Avogadro’s constant (NA = 6.0221367 × 1023 mol− 1), P is the pressure in the absorption cell (Pa, with standard atmospheric pressure at 1.01325 × 105 Pa), R is the gas constant (8.31451 × 106 Pa·cm3/(mol·K)), T is the temperature in the absorption cell (K, with room temperature typically at 296 K), and σ(ν) is the absorption cross-section of the molecule at the laser frequency ν (cm2/molecule).

Fig. 1
figure 1

Schematic illustration of the cavity ring-down spectroscopy (CRDS) systemfor simultaneous detection of CH4and CO2gas.

2.2 Whittaker-Henderson filtering algorithm

If there is a segment of noisy spectral data y with a length of m, the W-H smoothing algorithm aims to make the denoised data z fit as closely as possible to y. This involves balancing two aspects: the fidelity of the data and the degree of overfitting. The fidelity S can be represented by Eq. (4):

$$\text{S}=\sum _{\text{i}}{\left({\text{y}}_{\text{i}}-{\text{z}}_{\text{i}}\right)}^{2}$$
(4)

The overfitting degree R can be expressed by Eq. (5):

$$\text{R}=\sum _{\text{i}}{\left({\text{z}}_{\text{i}}-{\text{z}}_{\text{i}-1}\right)}^{2}$$
(5)

The comprehensive indicator of both influences is represented by Q and can be expressed as Eq. (6):

$$\text{Q}=\text{S}+{\lambda }\text{R}$$
(6)

For the overfitting degreeR, we introduce the difference multiplication algorithm, depending on the scenario, to choose the derivative order d (d = 1, 2, 3…). In Eq.(6), λ is the weighting parameter for W-H smoothing algorithm. λ affects the value of Q: the larger λ, the greater the impact of R on the target, resulting in smoother denoised data z but poorer fidelity of the data. We usually adopt cross-validation to choose the most suitable λ. This involves sequentially removing each element yi,smoothing the remaining elements, and simulatingŷyi for the removedyi. By repeating this process for eachyz, the cross-validation standard deviationScv is obtained as Eq. (7), wherem is the length ofy. The λ that minimizesScv is considered the optimal parameter.

$${\text{S}}_{\text{c}\text{v}}=\sqrt{\frac{\sum _{\text{i}}{\left({\text{y}}_{\text{i}}-{\widehat{\text{y}}}_{-\text{i}}\right)}^{2}}{\text{m}}}$$
(7)

2.3 Optimized adaptive Whittaker-Henderson filtering algorithm

A round-robin algorithm can be used to compute the optimal λ. However, the disadvantage of this method is that as the amount of data increases, the running time of the program also increases, usually around 30 s. The use of convolutional neural networks (CNN) provides an intelligent solution to this challenge. When the obtained spectral data is input into the trained model, the spectrum filtered by the optimal weight parameter λ will be obtained directly. The time required for this process has been shortened to the millisecond level.

The workflow of the optimized adaptive W-H filtering algorithm is depicted in Fig. 2. Gaussian and non-Gaussian random noise (with a mean of 0 and a variance of 0.002) are introduced to the obtained absorption spectra, generating 1000 sets of data. The optimal λ value in the W-H filter for each noisy data set is regarded as the label value for that data. Before model training, 80% of the data in the training set is randomly chosen for training, and the remaining 20% is assigned as the test set.

The model takes the noisy spectral data as input and produces the predicted \(\widehat{{\uplambda }}\) as output. The neural network is structured in layers, with multiple hidden layers following the input layer. Each hidden layer comprises a convolutional layer, an activation function layer, and a max-pooling layer. The convolutional and pooling layers are essential modules for feature extraction in a convolutional neural network. Feature extraction through the convolutional layer generates numerous feature maps, and the pooling layer effectively reduces the dimensionality of the output from the convolutional layer, efficiently decreasing network parameters. The fully connected layer consolidates information from the convolutional and pooling layers, and the output layer provides the result with the highest probability based on the information. Parameters undergo iterative optimization based on the error between the predicted value and the actual label value until the error is below a predefined threshold, resulting in a well-optimized training model.

During the prediction phase of the model, the measured absorption spectra are input into the well-trained model to obtain the predicted \(\widehat{{\uplambda }}\) value. And then, the predicted \(\widehat{{\uplambda }}\) value is substituted into W-H filtering algorithm, and finally the smooth-filtered absorption spectrum is obtained.

Fig. 2
figure 2

The workflow of the optimized adaptive W-H filtering algorithm

3 Results and discussion

3.1 Selection of absorption lines

In order to simultaneously measure CH4 and CO2, it is crucial to choose an appropriate spectral range. As the reflectivity of mirrors can only be maintained at a high level within a specific range, adjacent absorption spectral lines of CH4 and CO2need to be selected as measurement targets. Figure 3 illustrates the simulated distribution characteristics of absorption line strengths for carbon dioxide and methane based on the HITRAN database [26]. It is evident that CH4 and CO2 gas both exhibit rich absorption spectral features in the near-infrared range of 5800 cm− 1 to 6400 cm− 1. Additionally, the intensity of absorption peaks also must be considered. While measuring at the positions of stronger absorption peaks can achieve lower concentration detection limits under constant system measurement precision, excessively strong absorption at selected positions may lead to complete laser absorption, preventing the triggering of the cutoff circuit. Furthermore, interference from other gases in the air, particularly water vapor, must be avoided. For these reasons, we selected the absorption spectral line near 6057 cm− 1 for CH4 measurement and the line near 6246 cm− 1 for CO2 measurement. Figure 4(b-c) respectively depict the simulated absorption cross-sections for CH4 and CO2 (Temperature: 296 K, Pressure: 1 atm). As shown, the peak absorption for CH4 is at 6057.098 cm− 1, corresponding to 1650.955 nm, while the peak absorption for CO2 is at 6246.306 cm− 1, corresponding to 1600.946 nm. The selected absorption lines wavelength difference between the CH4 and CO2 is only 50 nm, which ensures that the operating wavelength of the mirror can completely cover the above absorption lines.

Fig. 3
figure 3

(a) Simulated distribution of absorption line strengths for CH4 and CO2 based on the HITRAN database; (b) Simulation of CH4 absorption spectral line distribution; (c) Simulation of CO2 absorption spectral line distribution

3.2 Output characteristics of the selected DFB lasers

To ensure effective coverage of the absorption peaks of methane and carbon dioxide, the laser output wavelengths of the DFB lasers across varying temperatures and injection currents are investigated. In Fig. 4(a), the relationship between the output wavelength of DFB-1 laser and temperature, as well as injection current, is depicted, while Fig. 4(b) illustrates the corresponding relationship for DFB-2 laser. The figures reveal a redshift in the laser’s output wavelength with excellent linearity as the injection current increases. Additionally, an increase in temperature contributes to a redshift in the laser’s output wavelength. During testing, at a temperature of 33 °C and an injection current ranging from 80 to 140 mA, the output wavelength of DFB-1 laser precisely spans from 1600.6 nm to 1601.4 nm, effectively covering CO2 absorption line. Similarly, for laser DFB-2, at a temperature of 28 °C and an injection current of 60–120 mA, the output wavelength range extends from 1650.4 nm to 1651.3 nm, accurately encompassing CH4 absorption line.

Fig. 4
figure 4

The selected two DFB lasers output wavelengths under varying operating temperatures and currents

3.3 Analysis of filtering results

Taking the absorption spectra collection of CH4 as an example, the starting and ending voltages of DFB-2 are set to 80 mA and 110 mA, with a step size of 0.1 mA. At each current, 100 sets of ring-down times are measured, and the average is calculated. The absorption coefficient is obtained using Eq. (2). The wavelength at each current is calibrated based on the relationship between wavelength and current. This process yields a set of absorption spectra. In this manner, 100 sets of different noisy data are measured, including 50 sets of CH4 and 50 sets of CO2. The amplitude of noise is altered by changing the aperture area of the pinhole aperture in the optical path and adjusting the focal length of the collimator. The 50 sets of data are input into the trained model, and the output \(\widehat{{\uplambda }}\) is illustrated in Fig. 5. Figure 5(a) represents the model-predicted values \(\widehat{{\uplambda }}\) for CO2, with output values ranging from 57.8 to 79.8. Figure 5(b) illustrates the model-predicted values \(\widehat{{\uplambda }}\) for CH4, with output values ranging from 394.7 to 514.9. Despite both being absorption spectra data, the line widths and noise levels of CH4 and CO2 spectra are not identical, resulting in varying levels of model output \(\widehat{{\uplambda }}\).

Fig. 5
figure 5

The output \(\widehat{\varvec{\uplambda }}\) of the data entered into the training model; (a) 50 sets of CO2 absorption spectra as input values; (b) 50 sets of CH4 absorption spectra as input values

Using one set of CH4 spectral data as a sample, different λ values (λ = 10^i, i = 0, 1, 2, 3) are chosen for filtering and compared with \(\widehat{{\uplambda }}\). The results are shown in Fig. 6. The same processing is applied to a set of CO2 spectral data, and the results are presented in Fig. 7. For clarity, the smooth curves have been shifted vertically. The scale of CH4 shift is 2 × 10− 8 cm− 1, while the scale of CO2 shift is 5 × 10− 8 cm− 1.The Scv corresponding to different λ values is calculated and summarized in Table 1, where \(\widehat{{\uplambda }}\) for CH4 is 510 and \(\widehat{{\uplambda }}\) for CO2 is 67. It can be observed that the Scv corresponding to the predicted values \(\widehat{{\uplambda }}\) is the minimum, demonstrating the optimal filtering effect of \(\widehat{{\uplambda }}\). It can be noticed that when λ = 1000, the data is overfitting. In the lower left corner of Fig. 6, the position of the baseline is noticeable; the original data exhibit significant noise, which is unfavorable for calculating cavity ring-down times. After filtering, more accurate baseline absorption coefficients are obtained. In Fig. 7, the wavelength corresponding to the CO2 absorption peak is identified as 1600.959 nm, which slightly differs from the HITRAN database. This discrepancy is attributed to the imperfect calibration of wavelength and current. However, setting the current at the position corresponding to 1600.959 nm enables the measurement of CO2 concentration.

Fig. 6
figure 6

Using one set of CH4 spectral data as a sample, different λ values are chosen for filtering and compared with\(\widehat{\varvec{\uplambda }}\)

Fig. 7
figure 7

Using one set of CO2 spectral data as a sample, different λ values are chosen for filtering and compared with\(\widehat{\varvec{\uplambda }}\)

Table 1 The Scv for different λ values

3.4 Laser switching functions

TDM involves transmitting different signals over the same physical connection during different time intervals. In this CRDS system, TDM is achieved by controlling the working time of different lasers in the optical path through a mechanical optical switch. This enables the synchronous measurement of two gases using a single optical path, improving measurement efficiency without compromising accuracy. The laser input process based on the optical switch in the CRDS system is illustrated in Fig. 8. DFB-1 and DFB-2 are alternate input into the system, each lasting for 16 s. The switching time of the optical switch is < 50 ms, accounting for 0.3% of one cycle, and its impact on the measurement is negligible. Additionally, a program is developed based on the working status of the optical switch to correspond to the measurement periods for CH4 and CO2.

Fig. 8
figure 8

Schematic diagram of optical switching for DFB laser switching control

Using laboratory air as the sample, the concentrations of CH4 and CO2 are measured, and the results are presented in Fig. 9. As shown, the proposed system can alternately and in real-time measure the concentrations of CH4 and CO2 without overlap, yielding measurements of 2.16 ppm and 431 ppm, respectively. The standard deviations of CH4 and CO2 are 0.005 ppm and 0.612 ppm, respectively.

Fig. 9
figure 9

The real-time measure results of the concentrations of CH4 and CO2.

3.5 Measurement results for different concentrations

Due to variations in environmental conditions, temperatures, and seasonal changes, the atmospheric concentrations of CH4 and CO2 exhibit a significant dynamic range over time and space. Therefore, it is essential to measure gradient concentrations of CH4 and CO2 to study the concentration response characteristics of the CRDS system. The measurement samples are created by blending high-purity nitrogen gas (> 99.999%) with standard concentration gases. According to the certified concentrations indicated on the gas cylinder labels, the concentration of CH4 is 200 ppm, and CO2 is 1000 ppm. The concentration of CH4 or CO2 within the cavity is controlled using a flowmeter. The average measurement time for CH4 here is about 3 min, while the average measurement time for CO2 is shorter, about 90 s.

Figure 10 presents the results obtained by the proposed CRDS system for different concentrations of CH4 and CO2. As shown in Fig. 10(a), the system exhibits excellent responsiveness to different concentrations of CH4, with stable measurement results at the same concentration. The inset demonstrates the measurement stability for the first set of CH4 concentrations. The maximum, minimum, average, and standard deviation of the test results are 1.062 ppm, 1.013 ppm, 1.032 ppm, and 0.009 ppm, respectively. Figure 10(b) illustrates the system’s response characteristics to different concentrations of CO2. The system shows an obvious response to concentrations between 353 and 624 ppm of CO2. The inset displays the measurement stability for the first set of CO2 concentrations. The maximum, minimum, average, and standard deviation of the test results are 354.67 ppm, 353.24 ppm, 353.87 ppm, and 0.35 ppm, respectively. Thus, the system demonstrates good stability in the detection of CO2 as well.

Fig. 10
figure 10

Test results for different concentrations of gases; (a) CH4; (b) CO2.

3.6 System detection sensitivity

To determine the limit of detection (LOD) of CRDS system, the Allan deviation analysis method was employed for concentration analysis. Outdoor air was introduced into the cavity, driven by a pump to establish continuous airflow. Measurements were conducted at a flow rate of 200 cubic centimeters per minute for a duration of 30 min. The time-series concentration data for CH4 and CO2 are presented in Fig. 11(a) and (b), respectively. Throughout the measurement process, the concentration variation ranges for CH4 remained primarily within 2.14 ~ 2.18 ppm, while that for CO2 ranged approximately from 428.4 to 433.8 ppm. The Allan deviation analysis is depicted in Fig. 11(c) and (d) for CH4 and CO2, respectively. At an average number of 1, the detection limits for CH4 and CO2 are determined as 8 ppb and 0.85 ppm, respectively. Furthermore, with an increased average number of 39, the detection limit for CH4 improves to 2 ppb. At an average number of 51, the detection limit for CO2 reaches 0.16 ppm. Considering the average atmospheric concentrations of CH4 and CO2 are around 1.8 ppm and 415 ppm, respectively, the developed CRDS system is more than capable of meeting the measurement sensitivity requirements for CH4 and CO2 in atmospheric backgrounds.

Fig. 11
figure 11

The time-series concentration data for (a) CH4 and (b) CO2; The Allan deviation analysis for (c) CH4 and (d) CO2.

4 Conclusion

In this study, a CRDS system for simultaneous measurement of multiple gases was proposed based on the principle of TDM. Meanwhile, combining CNN and the W-H filtering algorithm, effective denoising of the absorption spectra for CO2 and CH4 was achieved. The laser switching process and concentration gradient experiments demonstrated that the CRDS system has excellent reliability and meets the sensitivity requirements for measuring CH4 and CO2 in atmospheric backgrounds, with detection limits of 2 ppb and 0.16 ppm, respectively. In summary, the proposed system offers advantages such as high sensitivity, compact size, rapid response, and the capability to simultaneously measure two gases. By increasing the number of DFB lasers and the channels of the optical switch, the variety of gases measured at the same time can be further increased. Moreover, the W-H filtering algorithm based on CNN is a novel and rapid approach to enhance detection sensitivity and reduce absorption spectrum noise. Therefore, we believe that the proposed CRDS system holds significant potential for important applications in gas monitoring.