A gas flow detection method, system and device
By comprehensively analyzing the differences between gas flow data and building temperature, the problems of false alarms and false alarms in existing gas flow detection algorithms have been solved, enabling timely detection and early warning of gas pipeline leaks and improving the accuracy and safety of detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENENG NATURAL GAS CO LTD
- Filing Date
- 2025-10-13
- Publication Date
- 2026-05-19
AI Technical Summary
Existing gas flow anomaly detection algorithms are prone to false alarms due to environmental changes and equipment aging, and analysis of single data anomalies may lead to unnecessary emergency responses and cannot effectively identify abnormal situations such as gas pipeline leaks.
By monitoring the differences, variances, and correlations between gas flow data and historical data, and combining the differences between building temperature and ambient temperature, the degree of gas flow anomaly is comprehensively judged. Stable moments are screened using time series prediction algorithms and Otsu threshold algorithms, and anomaly thresholds are calculated using weighted calculations for detection.
It improves the accuracy of gas flow detection, reduces the probability of false alarms and missed alarms, and can detect abnormalities such as gas pipeline leaks in a timely manner, thereby improving safety and operation and maintenance efficiency.
Smart Images

Figure CN121278600B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of flow measurement technology, specifically to a method, system, and device for detecting gas flow. Background Technology
[0002] Natural gas, as a clean, efficient, and safe energy source, is widely used in industrial production, commercial services, and residential life. The stability and safety of gas supply systems not only affect the daily lives of countless households but also directly impact urban operational efficiency and public safety. The development of next-generation information technologies such as the Internet of Things, big data, and artificial intelligence has made the application of these advanced technologies to the operation monitoring of the gas industry an inevitable trend. By deploying high-precision sensors, establishing data analysis platforms, and applying intelligent algorithm models, all-weather monitoring, anomaly identification, and automatic early warning of gas flow data can be achieved, significantly improving the operational efficiency and risk control capabilities of gas companies.
[0003] Furthermore, anomaly detection systems based on data analysis and intelligent algorithms enable remote monitoring, automatic analysis, and precise early warning, providing gas companies with more scientific and efficient management tools. This shift from "passive response" to "proactive prevention" is a significant step in driving the gas industry towards digitalization and intelligentization.
[0004] Existing anomaly detection algorithms may generate false alarms due to flow fluctuations caused by environmental changes, equipment aging, or other non-fault factors. This not only increases the workload of maintenance personnel but may also lead to unnecessary emergency responses. Furthermore, most existing anomaly detection algorithms analyze only whether a single data point is abnormal. However, a single data point anomaly could be caused by external interference during data acquisition, and cannot necessarily indicate an anomaly in the gas data due to factors such as gas pipeline leaks. Therefore, a comprehensive analysis combining gas pipeline changes is needed to obtain more reliable gas data anomaly analysis results. This would avoid wasting human and material resources by triggering alarms based on a single data point anomaly. Summary of the Invention
[0005] To address the aforementioned technical problems, the purpose of this application is to provide a gas flow detection method, system, and device, the specific technical solution of which is as follows:
[0006] In a first aspect, embodiments of this application provide a gas flow detection method, which includes the following steps:
[0007] Monitor gas flow data for the current day and several previous historical days;
[0008] Predict the gas flow rate for the day using historical gas flow data; and compare the difference between the monitoring results and the predicted results of the gas flow rate for the day to determine the first abnormal gas flow rate value.
[0009] Calculate the variance of the gas flow rate values between the same adjacent monitoring time over all historical days, and use the variance value to filter adjacent stable times; consider adding the difference between the variance values before and after the current day to all historical days when calculating the variance of all adjacent stable times, in order to determine the second gas flow rate anomaly.
[0010] The third abnormal gas flow value was confirmed by the correlation coefficient between the fitted curves of the gas flow data on that day and those of all historical days.
[0011] The average of the outliers in the first, second, and third gas flow data will be used as the fourth outlier in the gas flow data.
[0012] By combining the building temperature difference with the ambient temperature, the correlation between gas flow and building temperature difference is analyzed at all monitoring times on all historical days, and the change in the correlation before and after adding the data of the current day is calculated to determine the fifth gas flow data anomaly.
[0013] The abnormal values of the fourth and fifth gas flow data are weighted according to the correlation to determine the degree of gas flow abnormality on the day. The abnormal values are then compared with the preset abnormal threshold to determine whether there is an abnormality in the gas pipeline.
[0014] Preferably, the historical gas flow data used is the gas flow data of the previous 30 consecutive days.
[0015] Preferably, the method for determining the first abnormal gas flow value is as follows:
[0016] Calculate the absolute value of the difference between the monitored gas flow data and the predicted value at each corresponding monitoring time for the day, and take the normalized value of the average of all absolute values of the differences calculated within the day as the first abnormal gas flow value.
[0017] Preferably, the method for screening adjacent stable moments using variance values is as follows: the variance values calculated for all adjacent monitoring moments are thresholded to obtain a segmentation threshold; the two adjacent monitoring moments corresponding to variance values less than the segmentation threshold are taken as adjacent stable moments.
[0018] Preferably, the method for determining the second abnormal gas flow value is as follows:
[0019] For any adjacent stable moment, the variance difference is obtained by subtracting the variance of all variance values calculated before the day of addition from the variance of all variance values calculated after the day of addition.
[0020] The variance differences calculated at all adjacent stable moments are normalized and the average value is taken as the second abnormal gas flow value.
[0021] Preferably, the correlation between the gas flow rate and the building temperature difference over all monitoring times across all historical days is calculated as follows:
[0022] ;
[0023] in, This indicates the correlation between gas flow data and differences in building temperature. Indicates the number of historical monitoring days. Indicates the number of daily monitoring data. Indicates the first day The normalized value of the gas flow rate at each monitoring time. Indicates the first day Normalized values of building temperature differences at each monitoring time point It indicates that all historical days are on the 1st The average value of gas flow rate at each monitoring time. It indicates that all historical days are on the 1st The average value of the building temperature difference at each monitoring time.
[0024] Preferably, the method for determining the degree of abnormality in the daily gas flow is as follows:
[0025] ;
[0026] in, Indicates the degree of abnormality in gas flow on that day. This indicates an abnormal value in the fourth gas flow data. This indicates an abnormal value in the fifth gas flow data. This indicates the correlation between gas flow data and building temperature differences. Represents the normalization function. The weights representing outliers in the fourth gas flow data. The weights represent the outliers in the fifth gas flow data.
[0027] Preferably, the method for determining whether the gas pipeline is abnormal is as follows: when the abnormality of the gas flow rate on a given day is greater than a preset abnormality threshold, the gas pipeline is abnormal; otherwise, the gas pipeline is normal.
[0028] Secondly, embodiments of this application provide a gas flow detection system, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements a gas flow detection method as described in any of the above-mentioned embodiments.
[0029] Thirdly, embodiments of this application also provide a gas flow detection device, the device storing a computer program, which, when executed by a processor, implements a gas flow detection method as described in any of the above claims.
[0030] As can be seen from the above embodiments, the gas flow detection method, system, and device provided in this application have at least the following beneficial effects:
[0031] This application comprehensively utilizes multiple analytical methods, including time series prediction bias, the relationship between different moments within daily flow, daily data change trends, and correlation with gas usage, to detect anomalies in gas flow data from different perspectives. Compared to single methods, it can more comprehensively capture anomalies and effectively reduce the probability of false alarms and missed alarms. This application not only focuses on the changing patterns of the gas flow data itself but also incorporates factors related to gas usage, such as building temperature and ambient temperature. It fully considers various factors affecting gas flow in actual usage scenarios, making the anomaly detection results closer to reality and improving detection accuracy. Finally, by analyzing the real-time gas flow data collected daily and comparing and calculating with historical data, this application can quickly determine the abnormal values of the daily gas flow. Once the abnormal value exceeds a set threshold, an alarm can be issued in a timely manner, reminding relevant personnel to check and handle potential gas pipeline leaks and other anomalies. This effectively avoids safety accidents caused by undetected gas leaks and other anomalies, improving the accuracy of gas flow detection. Attached Figure Description
[0032] To more clearly illustrate the technical solutions and advantages in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0033] Figure 1 This is a flowchart illustrating the steps of a gas flow detection method provided in one embodiment of this application. Detailed Implementation
[0034] To further illustrate the technical means and effects adopted by this application to achieve the intended inventive purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of a gas flow detection method, system, and apparatus proposed according to this application. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.
[0035] Unless otherwise specified and limited, terms such as “comprising,” “including,” or any other variations thereof are intended to cover a non-exclusive inclusion, such that a circuit structure, article, or device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such an article or device. Without further limitation, an element defined by the phrase “comprising one…” does not exclude the presence of other identical elements in the article or device that includes said element. Furthermore, the term “and / or” as used herein includes any and all combinations of one or more of the associated listed items. All technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.
[0036] The following description, in conjunction with the accompanying drawings, details a specific scheme for a gas flow detection method, system, and device provided in this application.
[0037] Please see Figure 1 The diagram illustrates a flowchart of a gas flow detection method according to an embodiment of this application, which includes the following steps:
[0038] Step S1: Monitor the gas flow data for the current day and several previous historical days;
[0039] This application uses a gas flow sensor to monitor gas flow, with data collected every 15 minutes. A total of 96 data points are collected over one day (24 hours) as the daily gas flow data. The target of this application's anomaly analysis and detection is the daily gas flow data.
[0040] Step S2: Predict the gas flow data for the day using historical gas flow data; and compare the difference between the monitoring results and the prediction results of the gas flow data for the day to determine the first abnormal gas flow value;
[0041] Gas flow data is time series data, and outliers can be detected by predicting deviations. That is, by analyzing the deviation between each monitoring data point in the daily gas flow data and the corresponding data obtained at other monitoring times, it can be determined whether an anomaly has occurred based on the deviation value.
[0042] Accordingly, this application uses historical daily gas flow data acquired over the previous 30 consecutive days as input to the existing time series prediction algorithm ARIMA to obtain the predicted gas flow data for the current day. By comparing the monitored gas flow data for the current day with its predicted result, and calculating the absolute value of the difference between the monitored value and the predicted value at each monitoring time, the normalized value of the average of all calculated absolute values of differences within the day is taken as the first gas flow anomaly. That is, the larger the difference between the obtained monitoring result and the predicted result, the less the monitoring data conforms to historical data, and the more likely the corresponding gas flow data for that day is an anomaly. The ARIMA time series prediction algorithm is a well-known technology and will not be described in detail here.
[0043] Step S3: Calculate the variance of the gas flow rate values between the same adjacent monitoring time over all historical days, and use the variance value to filter adjacent stable times; consider the difference between the variance values before and after the current day when calculating the variance of all historical days over all adjacent stable times, in order to determine the second gas flow rate anomaly.
[0044] There may be a certain relationship between daily gas flow data under normal circumstances. For example, the greater the difference in building temperature, the greater the corresponding gas flow consumption. This relationship is relatively stable. By analyzing whether this relationship exists in the data obtained from real-time monitoring, it is possible to analyze whether there are any abnormalities in the gas flow data obtained on that day.
[0045] First, we analyze the correlation between gas flow rates at adjacent monitoring times in the daily gas flow data. We obtain the difference between the gas flow rate at the t-th monitoring time and the gas flow rate at the (t+1)-th monitoring time each day, and form a sequence of gas flow rate difference between the t-th and (t+1)-th monitoring times. We then calculate the variance of this sequence.
[0046] Similarly, obtain the gas flow difference sequence between other monitoring times and their next adjacent monitoring times. Use the Otsu threshold algorithm to process all variance values to obtain a segmentation threshold. Select the two adjacent monitoring times corresponding to variance values less than the segmentation threshold as adjacent stable times with strong correlation. The number of these times is denoted as L.
[0047] Correspondingly, we can analyze the impact of adding the daily gas flow data on these data. If adding the data weakens the gas flow stability, it indicates that the gas flow data acquired at the current moment may be abnormal; conversely, it indicates that the daily data is normal. The Otsu threshold algorithm is a well-known technique and will not be elaborated upon further.
[0048] For any adjacent stable time point, the variance of all variance values calculated before the addition of that day is subtracted from the variance of all variance values calculated after the addition of that day. This variance difference is used as the variance difference value for that adjacent stable time point. A smaller variance difference value indicates that the previously stable data became unstable after the addition of that day's data, suggesting an anomaly in the data for that day. The variance differences calculated for all adjacent stable time points are normalized, and their average is taken as the second abnormal gas flow rate value. A larger second abnormal gas flow rate value indicates that the previously stable data became abnormal after the addition of that day, reflecting an anomaly in the data for that day.
[0049] Step S4: Determine the third abnormal gas flow value based on the correlation coefficient between the fitted curves of the gas flow data of the current day and all historical days;
[0050] Since gas flow rate changes over time, for example, the gas flow rate will be higher when gas is used for heating during the day, the daily flow rate data shows a trend over time. Therefore, we can use this to analyze the anomalies in the time trend of the data.
[0051] First, the daily gas flow data is fitted with a curve. The normalized mean of the correlation coefficients between the fitted curve for the current day and the fitted curves for all historical days is calculated. The result of subtracting the mean from the value of 1 is taken as the third gas flow anomaly. In this embodiment, the Pearson correlation coefficient is used to calculate the correlation coefficient.
[0052] The above analysis can determine whether the trend of the gas flow rate data obtained on the current day is consistent with the historical trend of gas flow rate. In other words, the closer the trend of the gas flow rate curve for the current day is to the historical trend, i.e., the larger the correlation coefficient, and the smaller the corresponding third gas flow anomaly value, the less likely there is an anomaly in the gas flow rate change on that day.
[0053] Step S5: Take the average of the first, second, and third abnormal gas flow data values as the fourth abnormal gas flow data value. .
[0054] Step S6: Combining the building temperature difference with the ambient temperature, analyze the correlation between gas flow and building temperature difference at all monitoring times on all historical days, and calculate the change in the correlation before and after adding the data of the current day to determine the fifth gas flow data anomaly.
[0055] This application takes the difference between building temperature and ambient temperature as an example to analyze the correlation between changes in gas flow rate and building temperature difference, thereby correcting the degree of abnormality in the obtained data.
[0056] Since the greater the difference between the building's internal temperature and the ambient temperature, the greater the gas consumption may be, the correlation between gas flow rate and the difference between building temperature and ambient temperature can be analyzed to infer the gas flow rate at the corresponding moment based on the difference between building temperature and ambient temperature, thereby indirectly determining whether the flow rate data is abnormal.
[0057] First, based on historical monitoring data, the stability of building temperature is analyzed. Temperature data inside the building and ambient temperature data outside the building are acquired using temperature sensors. The acquired data corresponds one-to-one with the monitoring time of gas flow data, thus obtaining the temperature difference between the building temperature and the ambient temperature, i.e., the building temperature difference. Based on this, the correlation between the building temperature difference and gas flow can be obtained. The correlation calculation method is as follows:
[0058] ;
[0059] in, This indicates the correlation between gas flow data and building temperature differences. This indicates the number of historical monitoring days, which is set to 30 days in this embodiment. This indicates the number of daily monitoring data points; in this example, it is set to 96. Indicates the first day The normalized value of the gas flow rate at each monitoring time. Indicates the first day Normalized values of building temperature differences at each monitoring time point It indicates that all historical days are on the 1st The average value of gas flow rate at each monitoring time. It indicates that all historical days are on the 1st The average value of the building temperature difference at each monitoring time.
[0060] It should be understood that the smaller the difference between the ratio of the daily gas flow rate to the corresponding building temperature difference and the historical average ratio, the stronger the correlation between the gas flow rate and the building temperature difference. In this case, it is possible to analyze whether the gas flow rate is also abnormal based on whether the building temperature data is abnormal.
[0061] The corresponding data is added to the historical data to obtain the impact of the data on the correlation. That is, if the correlation changes greatly when the data of the day is added to the historical data, it means that the data of the day is more likely to have abnormal data. Therefore, the difference between the correlation between the gas flow data and the building temperature difference obtained before and after adding the data of the day is normalized and used as the fifth abnormal value Pd of the gas flow data obtained based on the building temperature.
[0062] Step S7: Combine the correlation to weight the abnormal values of the fourth and fifth gas flow data respectively to determine the degree of gas flow abnormality on the day, and compare it with the preset abnormal threshold to determine whether there is an abnormality in the gas pipeline.
[0063] Based on the above information, an analysis of the anomalies in the daily gas flow data is performed. The specific calculation method is as follows:
[0064] ;
[0065] in, Indicates the degree of abnormality in gas flow on that day. This indicates an abnormal value in the fourth gas flow data. This indicates an abnormal value in the fifth gas flow data. This indicates the correlation between gas flow data and building temperature differences. Represents the normalization function. The weights representing outliers in the fourth gas flow data are used to characterize the weights of outliers obtained from the gas flow analysis itself for the day. The weight representing the outlier value of the fifth gas flow data is used to characterize the outlier value of the gas flow data obtained from the analysis of building temperature difference data related to gas flow.
[0066] Thus, this application analyzes the degree of data anomaly based on the changes in the gas flow rate data on the day itself, and also obtains the degree of gas data anomaly by combining the analysis results of building temperature data that is highly related to the gas usage, thereby improving the accuracy and reliability of the detection of the degree of data anomaly.
[0067] Set a preset anomaly threshold V=0.8, and determine the degree of anomaly in the gas flow rate for the desired day. If the value is greater than V, an abnormality has occurred in the gas pipeline, and an alarm should be issued promptly; otherwise, the gas pipeline is normal.
[0068] Based on the same inventive concept as the above method, this application provides a gas flow detection system, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements a gas flow detection method as described above.
[0069] Based on the same inventive concept as the above method, this application also provides a gas flow detection device, which stores a computer program. When the computer program is executed by a processor, it implements a gas flow detection method as described in any of the above claims.
[0070] The various embodiments in this application are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.
[0071] It should be noted that, unless otherwise specified and limited, terms such as “comprising,” “including,” or any other variations thereof are intended to cover non-exclusive inclusion, such that a circuit structure, article, or device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such article or device. Without further limitations, an element defined by the phrase “comprising one…” does not exclude the presence of other identical elements in the article or device that includes said element. Furthermore, the term “and / or” as used herein includes any and all combinations of one or more of the associated listed items.
[0072] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not invented in this application.
[0073] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope.
Claims
1. A method for detecting gas flow rate, characterized in that, The method includes the following steps: Monitor gas flow data for the current day and several previous historical days; Predict the daily gas flow rate using historical gas flow data; and compare the difference between the monitoring results and the predicted results of the daily gas flow rate to determine the first abnormal gas flow rate value. Calculate the variance of the gas flow rate values between the same adjacent monitoring time over all historical days, and use the variance value to filter adjacent stable times; consider adding the difference between the variance values before and after the current day to all historical days when calculating the variance of all adjacent stable times, in order to determine the second gas flow rate anomaly. The third abnormal gas flow value was determined by comparing the fitted curve of the gas flow data for the day with the fitted curves of the gas flow data for all historical days. The average of the outliers in the first, second, and third gas flow data will be used as the fourth outlier in the gas flow data. By combining the building temperature difference with the ambient temperature, the correlation between gas flow and building temperature difference is analyzed at all monitoring times on all historical days, and the change in the correlation before and after adding the data of the current day is calculated to determine the fifth gas flow data anomaly. The abnormal values of the fourth and fifth gas flow data are weighted according to the correlation to determine the degree of gas flow abnormality on the day. The abnormal values are then compared with the preset abnormal threshold to determine whether there is an abnormality in the gas pipeline.
2. The gas flow detection method as described in claim 1, characterized in that, The historical gas flow data used refers to the gas flow data of the previous 30 consecutive days.
3. The gas flow detection method as described in claim 1, characterized in that, The method for determining the first abnormal gas flow value is as follows: Calculate the absolute value of the difference between the monitored gas flow data and the predicted value at each corresponding monitoring time for the day, and take the normalized value of the average of all absolute values of the differences calculated within the day as the first abnormal gas flow value.
4. The gas flow detection method as described in claim 1, characterized in that, The method for filtering adjacent stable moments using variance values is as follows: the variance values calculated for all adjacent monitoring moments are divided by a threshold to obtain a segmentation threshold; the two adjacent monitoring moments corresponding to variance values less than the segmentation threshold are taken as adjacent stable moments.
5. The gas flow detection method as described in claim 1, characterized in that, The method for determining the second abnormal gas flow value is as follows: For any adjacent stable moment, the variance difference is obtained by subtracting the variance of all variance values calculated before the day of addition from the variance of all variance values calculated after the day of addition. The variance differences calculated at all adjacent stable times are normalized and the average value is taken as the second abnormal gas flow value.
6. The gas flow detection method as described in claim 1, characterized in that, The method for calculating the correlation between the gas flow rate and the building temperature difference across all monitoring times on all historical days is as follows: ; in, This indicates the correlation between gas flow data and building temperature differences, where P represents the number of historical monitoring days and M represents the number of daily monitoring data points. This represents the normalized value of the gas flow rate at the j-th monitoring time on day i. This represents the normalized value of the building temperature difference at the j-th monitoring time on the i-th day. This represents the average gas flow rate at the j-th monitoring time across all historical days. This represents the average of the building temperature differences at the j-th monitoring time across all historical days.
7. The gas flow detection method as described in claim 1, characterized in that, The method for determining the degree of abnormality in the daily gas flow is as follows: ; Where Uv represents the degree of gas flow abnormality on that day, Kb represents the fourth abnormal value of gas flow data, Pd represents the fifth abnormal value of gas flow data, represents the correlation between gas flow data and building temperature differences, and norm represents the normalization function. The weights representing outliers in the fourth gas flow data. The weights represent the outliers in the fifth gas flow data.
8. The gas flow detection method as described in claim 1, characterized in that, The method for determining whether a gas pipeline is abnormal is as follows: when the abnormality of the gas flow rate on a given day is greater than a preset abnormality threshold, then the gas pipeline is abnormal. Conversely, the gas pipeline is normal.
9. A gas flow detection system, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements a gas flow detection method as described in any one of claims 1-8.
10. A gas flow detection device, the device storing a computer program, characterized in that, When the computer program is executed by the processor, it implements a gas flow detection method as described in any one of claims 1 to 8.