An online foreign matter disturbance identification method, system, device and medium based on analog data driving of a weighing type rain and snow gauge

By employing a simulated data-driven two-stage pipeline architecture and a lightweight machine learning model, the problem of low power consumption and high accuracy in foreign object disturbance identification of weighing rain and snow gauges in complex environments was solved, achieving efficient foreign object disturbance identification.

CN122132916APending Publication Date: 2026-06-02HEBEI UNIV OF ENG +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HEBEI UNIV OF ENG
Filing Date
2026-02-28
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing weighing rain and snow gauges are difficult to achieve high-precision foreign object disturbance identification in complex observation environments, and traditional methods are difficult to balance identification accuracy and system power consumption while maintaining low power consumption.

Method used

A two-stage pipeline architecture based on simulated data is adopted. A machine learning recognition model is used to identify foreign object disturbances online. High-precision real precipitation signals and foreign object disturbance signals are generated through simulated data, a lightweight machine learning classifier is trained, and deployed in the main controller of the weighing rain and snow gauge.

Benefits of technology

While maintaining low power consumption, it achieves high-precision real-time foreign object disturbance identification, improving the observation accuracy of the weighing rain and snow gauge and adapting to complex field environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122132916A_ABST
    Figure CN122132916A_ABST
Patent Text Reader

Abstract

This invention relates to the field of foreign object disturbance identification technology, and discloses a method, system, device, and medium for online foreign object disturbance identification in a weighing rain and snow gauge based on analog data-driven simulation. The method includes: outputting a formula for calculating the weight increase based on the rain-collecting area of ​​the weighing rain and snow gauge; generating a basic precipitation signal with noise and instantaneous disturbances based on the weight increase calculation formula and disturbance rules; generating a disturbance label array based on the basic precipitation signal; training a learner using window data filtered from the disturbance label array; using the trained classifier as a machine learning recognition model for online disturbance identification; deploying the machine learning recognition model into the main controller of the weighing rain and snow gauge; and using a two-stage pipeline architecture to achieve online identification of foreign object disturbances in the weighing rain and snow gauge. This invention employs a two-stage pipeline architecture for anomaly-triggered classification, ensuring high-precision real-time identification while maintaining low power consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of foreign object disturbance identification technology, and more specifically, to an online foreign object disturbance identification method, system, device, and medium for a weighing rain and snow gauge based on analog data driven. Background Technology

[0002] In recent years, with the intensification of global warming and the frequent occurrence of extreme rain and snow events, accurate rain and snow measurement data has become a core foundation for meteorological forecasting and early warning, hydrological and water resource assessment, disaster prevention and mitigation decision-making, and agricultural production guidance. Weighing rain and snow gauges, with their advantages of directly measuring the total weight of rain and snow and achieving all-weather observation without distinguishing precipitation patterns, have become the mainstream equipment for collecting rain and snow in ground meteorological observations. They are widely used in key scenarios such as meteorological observation stations, hydrological monitoring points, airport runways, and highways. The accuracy of their observation data directly affects the scientificity and reliability of various decisions.

[0003] Currently, the core technologies for the research and application of weighing rain and snow gauges, especially the engineering application of signal recognition algorithms, are still imperfect. This makes it difficult for existing domestic equipment to meet the precision requirements in complex observation environments. Moreover, most weighing rain and snow gauges on the market rely solely on simple threshold judgment or filtering to extract precipitation signals. Research and application of automated and intelligent interference recognition algorithms are still weak, making it difficult to effectively cope with various foreign object disturbances in the field environment.

[0004] In recent years, with the rapid development of embedded technology and artificial intelligence algorithms, the intelligent upgrading of weighing rain and snow gauges has made some progress. However, the complexity of field observation scenarios has brought severe challenges to signal recognition. On the one hand, foreign object interference such as birds landing, fallen leaves accumulating, and dust covering frequently occurs, and there are different disturbance forms such as instantaneous impacts (such as hail impacts and falling branches) and slow accumulations (such as snow compaction and dust deposition), which are easily misjudged as real precipitation. On the other hand, weighing rain and snow gauges are mostly deployed in remote areas, and embedded platforms are limited by hardware costs, with strict constraints on computing power, storage, and power consumption, making it difficult to directly port complex intelligent recognition models. Therefore, building an efficient interference recognition system on resource-constrained embedded platforms to improve the observation accuracy of weighing rain and snow gauges is of great significance to the development of meteorological observation and disaster prevention and mitigation.

[0005] Meanwhile, the observation signals of weighing rain and snow gauges are greatly affected by environmental interference. The signal characteristics of real precipitation and foreign object disturbances overlap. Furthermore, the embedded platform has strict resource constraints. In the face of complex and dynamic signal recognition scenarios, traditional threshold judgment or simple filtering methods cannot guarantee the balance between recognition accuracy and system power consumption, resulting in limited control effects. Therefore, lightweight intelligent recognition algorithms have been introduced into the signal processing system of weighing rain and snow gauges to improve the anti-interference performance of the equipment.

[0006] No effective solutions have yet been proposed to address the problems in the relevant technologies. Summary of the Invention

[0007] (a) Technical problems to be solved To address the shortcomings of existing technologies, this invention provides an online method, system, device, and medium for identifying foreign object disturbances in a weighing rain and snow gauge based on analog data-driven methods. This method has the advantage of achieving high-precision real-time identification while maintaining low power consumption, thereby solving the problem of difficulty in balancing identification accuracy and system power consumption, and limited control effect.

[0008] (II) Technical Solution To achieve the advantages of high-precision real-time recognition while maintaining low power consumption, the specific technical solution adopted by this invention is as follows: In a first aspect, the present invention provides an online method for identifying foreign object disturbances in a weighing rain and snow gauge based on analog data-driven methods, comprising: Based on the area of ​​the rain-collecting inlet of the weighing rain and snow gauge, the formula for calculating the weight increase is output; and based on the formula for calculating the weight increase and the disturbance rules, a basic precipitation signal with noise disturbance and instantaneous disturbance is generated. A perturbation label array is generated based on the basic precipitation signal, and a learner is trained based on the window data filtered by the perturbation label array. The trained classifier is used as the machine learning recognition model for online perturbation identification. The machine learning recognition model is deployed into the main controller of the weighing rain and snow gauge. Based on a two-stage pipeline architecture, the machine learning recognition model is used to realize the online recognition of foreign object disturbances in the weighing rain and snow gauge.

[0009] Preferably, based on the area of ​​the rain-collecting inlet of the weighing rain gauge, a formula for calculating the weight increase is output; and according to the formula for calculating the weight increase and the disturbance rules, a basic precipitation signal with noise disturbance and instantaneous disturbance is generated, including: The system obtains the rain-collecting area and precipitation of the weighing rain and snow gauge, outputs the calculation formula for the weight increase of the weighing rain and snow gauge, and generates a basic rainfall signal based on the weight increase calculation formula and programming technology. The time array is determined based on the basic rainfall signal, and a drift array with an initial value of zero and the same length as the time array is created. The drift value of each position in the drift array is determined by setting the starting point according to the loop traversal rule. Calculate the maximum absolute value of all elements in the drift array. If the maximum value is zero, the restricted drift array is equal to the original drift array. If the maximum value is non-zero, multiply the original drift array by the restricted drift range to obtain the restricted drift array, thus completing the noise disturbance addition process. Based on the constrained drift array, instantaneous perturbation processing is added, the perturbation data array is output, and a curve is plotted in the plotting area. Based on the curve, a basic precipitation signal with noise perturbation and instantaneous perturbation is generated.

[0010] Preferably, based on the constrained drift array, instantaneous perturbation processing is added, an output perturbation data array is generated, and a curve is plotted within the plotting area. The generation of a baseline precipitation signal with noise perturbation and instantaneous perturbation based on the curve includes: The event time and increment value are obtained from the constrained drift array, and the absolute difference between each element in the time array and the event time is calculated. The index corresponding to the element with the smallest absolute difference is selected as the position index. Incremental values ​​are added to each element in the constrained drift array based on the position index to complete the instantaneous perturbation processing, obtain instantaneous perturbation data, and create a canvas based on the drawing area of ​​the data visualization library; Use the canvas to draw a curve between the time array and the instantaneous disturbance data, and set the curve label to instantaneous disturbance. At the same time, add a vertical reference line to the canvas and set the vertical reference line label to disturbance occurrence. Set the title and vertical axis labels of the plotting area as instantaneous disturbance and weight respectively. Use the plotting area to visualize the time and weight change process of the disturbance. Output the basic precipitation signal with noise disturbance and instantaneous disturbance based on the visualization results.

[0011] Preferably, a perturbation label array is generated based on the baseline precipitation signal, and a learner is trained based on the window data filtered from the perturbation label array. The trained classifier is then used as the machine learning recognition model for online perturbation identification, including: A disturbance label array is generated based on the basic precipitation signal with noise and instantaneous disturbances. The disturbance type and the parameter set of the disturbance type are traversed. The difference between two adjacent time points in the time array is calculated based on the traversal results to obtain the sampling rate. By combining the sampling rate with the window time length and the step time, the number of samples contained in the window and the number of samples when the sliding window moves each time are calculated, thus obtaining the number of sample points in the window and the number of sample points in the step. The window's initial position is initialized by performing a cyclic sliding process using the number of window sample points and the step size sample points to obtain window data in array form. Feature data of the stored window data is extracted and stored in an empty list. By using synthetic minority class oversampling to balance the feature data, and training a random forest model based on the processed feature data, a machine learning recognition model for online identification of foreign object disturbances is obtained.

[0012] Preferably, extracting feature data from the storage window data and storing it in an empty list includes: The mean, standard deviation, range, and absolute median of the window data are extracted as basic statistical features, and the time index sequence of the window data is obtained. The time index sequence and the window data are then linearly fitted. The slope of the linear fitting result is determined to reflect the rate of change of weight over time. The first difference of the window data is calculated to obtain the sequence of changes in the window data. The mean and maximum value of the sequence of changes are then calculated. The mean and maximum values ​​reflect the drastic changes and single-time drastic changes in the window data. At the same time, the standard deviation of the first-order difference is calculated to determine the stability of the window data and the number of abnormal disturbances. Create an empty list, and then add the integrated basic statistical features, slope, degree of change, degree of single change, stability of change and number of abnormal disturbances to the empty list to complete the feature data addition process.

[0013] Preferably, the feature data is balanced using synthetic minority class oversampling technology, and a random forest model is trained based on the processed feature data to obtain a machine learning recognition model for online foreign object disturbance identification, including: After standardizing the feature data, a random seed for the synthetic minority oversampler is initialized, and the synthetic minority oversampler is used to balance the feature data and output the oversampled training feature matrix. The training feature matrix is ​​used as the test input of the random forest model. The random forest model outputs a predicted label array, and the matching between the true labels of the training feature matrix and the predicted label array is statistically analyzed to obtain the binary classification confusion matrix. Based on the generation of a binary confusion matrix, a trade-off is made between the ability of the random forest model to identify positive classes and the cost of misclassification. The random forest model is then optimized using this trade-off to obtain a machine learning recognition model for online identification of foreign object disturbances.

[0014] Preferably, the binary confusion matrix is ​​a two-dimensional numerical value, in the format of true negative examples and false positive examples, and false negative examples and true examples; True negative examples indicate that normal samples are correctly identified, while false positive examples indicate that normal samples are misidentified as perturbations; false negative examples indicate that perturbation samples are misidentified as normal, while true positive examples indicate that perturbation samples are correctly identified.

[0015] Secondly, the present invention also provides an online foreign object disturbance identification system for a weighing rain and snow gauge based on analog data driving, the system comprising: The simulation data generation module is used to output the weight increase calculation formula based on the area of ​​the rain-collecting inlet of the weighing rain and snow gauge; and to generate a basic precipitation signal with noise and instantaneous disturbances according to the weight increase calculation formula and disturbance rules. The identification model building module is used to generate a perturbation label array based on the basic precipitation signal, and to train a learner based on the window data filtered by the perturbation label array. The trained classifier is used as the machine learning identification model for online perturbation identification. An online identification module is deployed to deploy the machine learning identification model into the main controller of the weighing rain and snow gauge. Based on a two-stage pipeline architecture, the machine learning identification model is used to realize the online identification of foreign object disturbances in the weighing rain and snow gauge.

[0016] Thirdly, the present invention also proposes an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the above-described method when executed by the processor.

[0017] Fourthly, the present invention also provides a computer-readable storage medium on which a computer program is stored, and which, when executed by a processor, implements the above-described method.

[0018] (III) Beneficial Effects Compared with existing technologies, this invention provides an online method for identifying foreign object disturbances in a weighing rain and snow gauge based on analog data, which has the following advantages: This invention uses Python to build a physical model-driven data simulator. The simulator can generate high-precision real precipitation signals and various foreign object disturbance signals. Based on the simulated data, features are extracted to train a lightweight machine learning classifier. The trained model is then deployed on the MCU of the rain and snow gauge. A two-stage pipeline architecture with anomaly triggering fine classification is adopted to ensure high-precision real-time identification while maintaining low power consumption. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a flowchart of an online foreign object disturbance identification method for a weighing rain and snow gauge based on analog data driven according to an embodiment of the present invention; Figure 2 This is a schematic diagram of an online foreign object disturbance identification system for a weighing rain and snow gauge based on analog data driven according to an embodiment of the present invention. Figure 3 This is a schematic diagram of the hardware operating environment involved in the embodiments of the present invention; Figure 4This is a schematic diagram illustrating the process of visualizing disturbance occurrence and weight change in the online foreign object disturbance identification method for a weighing rain and snow gauge based on analog data driven according to an embodiment of the present invention. Figure 5 This is a schematic diagram illustrating the importance ranking of features extracted in the online foreign object disturbance identification method for a weighing rain and snow gauge based on analog data driven according to an embodiment of the present invention. Figure 6 This is a schematic diagram of the instantaneous disturbance weight, tag, disturbance probability change graph, and common model evaluation indicators of the online foreign object disturbance identification method for a weighing rain and snow gauge based on analog data driven according to an embodiment of the present invention.

[0021] In the picture: 1. Simulated data generation module; 2. Recognition model construction module; 3. Deployment of online recognition module. Detailed Implementation

[0022] To further illustrate the various embodiments, the present invention provides accompanying drawings, which are part of the disclosure of the present invention. These drawings are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these drawings, those skilled in the art should be able to understand other possible implementation methods and the advantages of the present invention.

[0023] According to embodiments of the present invention, an online method, system, device, and medium for identifying foreign object disturbances in a weighing rain and snow gauge based on analog data-driven methods are provided.

[0024] The present invention will now be further described in conjunction with the accompanying drawings and specific embodiments, such as... Figure 1 and Figures 4 to 6 As shown, the online foreign object disturbance identification method for a weighing rain and snow gauge based on analog data driven according to an embodiment of the present invention includes: Step S1: Based on the area of ​​the rain-collecting inlet of the weighing rain gauge, output the formula for calculating the weight increase; and generate a basic precipitation signal with noise disturbance and instantaneous disturbance according to the formula for calculating the weight increase and the disturbance rules.

[0025] In one embodiment, based on the area of ​​the rain-collecting inlet of a weighing rain gauge, a formula for calculating the weight increase is output; and according to the formula for calculating the weight increase and the perturbation rules, a basic precipitation signal with noise perturbation and instantaneous perturbation is generated, including: The system obtains the rain-collecting area and precipitation of the weighing rain and snow gauge, outputs the calculation formula for the weight increase of the weighing rain and snow gauge, and generates a basic rainfall signal based on the weight increase calculation formula and programming technology. The time array is determined based on the basic rainfall signal, and a drift array with an initial value of zero and the same length as the time array is created. The drift value of each position in the drift array is determined by setting the starting point according to the loop traversal rule. Calculate the maximum absolute value of all elements in the drift array. If the maximum value is zero, the restricted drift array is equal to the original drift array. If the maximum value is non-zero, multiply the original drift array by the restricted drift range to obtain the restricted drift array, thus completing the noise disturbance addition process. Based on the constrained drift array, instantaneous perturbation processing is added, the perturbation data array is output, and a curve is plotted in the plotting area. Based on the curve, a basic precipitation signal with noise perturbation and instantaneous perturbation is generated.

[0026] In one embodiment, adding transient perturbation processing to the constrained drift array, outputting a perturbation data array, plotting a curve within a plotting area, and generating a base precipitation signal with noise perturbation and transient perturbation based on the curve includes: The event time and increment value are obtained from the constrained drift array, and the absolute difference between each element in the time array and the event time is calculated. The index corresponding to the element with the smallest absolute difference is selected as the position index. Incremental values ​​are added to each element in the constrained drift array based on the position index to complete the instantaneous perturbation processing, obtain instantaneous perturbation data, and create a canvas based on the drawing area of ​​the data visualization library; Use the canvas to draw a curve between the time array and the instantaneous disturbance data, and set the curve label to instantaneous disturbance. At the same time, add a vertical reference line to the canvas and set the vertical reference line label to disturbance occurrence. Set the title and vertical axis labels of the plotting area as instantaneous disturbance and weight respectively. Use the plotting area to visualize the time and weight change process of the disturbance. Output the basic precipitation signal with noise disturbance and instantaneous disturbance based on the visualization results.

[0027] Step S2: Generate a perturbation label array based on the basic precipitation signal, and train a learner based on the window data filtered by the perturbation label array. Use the trained classifier as the machine learning recognition model for online perturbation identification.

[0028] In one embodiment, a perturbation label array is generated based on the baseline precipitation signal, and a learner is trained using window data filtered based on the perturbation label array. The trained classifier is then used as a machine learning recognition model for online perturbation identification, including: A disturbance label array is generated based on the basic precipitation signal with noise and instantaneous disturbances. The disturbance type and the parameter set of the disturbance type are traversed. The difference between two adjacent time points in the time array is calculated based on the traversal results to obtain the sampling rate. By combining the sampling rate with the window time length and the step time, the number of samples contained in the window and the number of samples when the sliding window moves each time are calculated, thus obtaining the number of sample points in the window and the number of sample points in the step. The window's initial position is initialized by performing a cyclic sliding process using the number of window sample points and the step size sample points to obtain window data in array form. Feature data of the stored window data is extracted and stored in an empty list. By using synthetic minority class oversampling to balance the feature data, and training a random forest model based on the processed feature data, a machine learning recognition model for online identification of foreign object disturbances is obtained.

[0029] In one embodiment, extracting feature data from the storage window data and storing it in an empty list includes: The mean, standard deviation, range, and absolute median of the window data are extracted as basic statistical features, and the time index sequence of the window data is obtained. The time index sequence and the window data are then linearly fitted. The slope of the linear fitting result is determined to reflect the rate of change of weight over time. The first difference of the window data is calculated to obtain the sequence of changes in the window data. The mean and maximum value of the sequence of changes are then calculated. The mean and maximum values ​​reflect the drastic changes and single-time drastic changes in the window data. At the same time, the standard deviation of the first-order difference is calculated to determine the stability of the window data and the number of abnormal disturbances. Create an empty list, and then add the integrated basic statistical features, slope, degree of change, degree of single change, stability of change and number of abnormal disturbances to the empty list to complete the feature data addition process.

[0030] In one embodiment, a synthetic minority class oversampling technique is used to balance the feature data, and a random forest model is trained based on the processed feature data to obtain a machine learning recognition model for online foreign object disturbance identification, including: After standardizing the feature data, a random seed for the synthetic minority oversampler is initialized, and the synthetic minority oversampler is used to balance the feature data and output the oversampled training feature matrix. The training feature matrix is ​​used as the test input of the random forest model. The random forest model outputs a predicted label array, and the matching between the true labels of the training feature matrix and the predicted label array is statistically analyzed to obtain the binary classification confusion matrix. Based on the generation of a binary confusion matrix, a trade-off is made between the ability of the random forest model to identify positive classes and the cost of misclassification. The random forest model is then optimized using this trade-off to obtain a machine learning recognition model for online identification of foreign object disturbances.

[0031] Step S3: Deploy the machine learning recognition model into the main controller of the weighing rain and snow gauge, and use the machine learning recognition model based on the two-stage pipeline architecture to realize the online recognition of foreign object disturbances in the weighing rain and snow gauge.

[0032] likeFigure 2 As shown, according to another embodiment of the present invention, an online foreign object disturbance identification system for a weighing rain and snow gauge based on analog data driving is also provided. The system includes: The simulation data generation module 1 is used to output the weight increase calculation formula based on the area of ​​the rain-collecting inlet of the weighing rain and snow gauge; and to generate a basic precipitation signal with noise disturbance and instantaneous disturbance according to the weight increase calculation formula and disturbance rules. The identification model building module 2 is used to generate a disturbance label array based on the basic precipitation signal, and to train a learner based on the window data filtered by the disturbance label array. The trained classifier is used as the machine learning identification model for online disturbance identification. Deploy online identification module 3 to deploy the machine learning identification model into the main controller of the weighing rain and snow gauge, and realize online identification of foreign object disturbances in the weighing rain and snow gauge based on a two-stage pipeline architecture using the machine learning identification model.

[0033] It should be explained that this embodiment uses Python to build a physics model-driven data simulator, which can generate high-precision real precipitation signals and various foreign object disturbance signals. Features are extracted and used to train a lightweight machine learning classifier to achieve foreign object identification, thereby improving the accuracy of the weighing rain and snow gauge. To facilitate understanding of the above technical solution of this invention, the working principle or operation method of this invention in actual practice will be described in detail below: Step 1: Based on the formula for converting the weight of the sensor in the weighing rain and snow gauge to the weight of the rainfall, generate a basic precipitation signal using Python simulation, and add noise and disturbances to this signal. There are three types of noise and disturbances, and the timing of the disturbances and the entire weight change process are visualized.

[0034] A specific basic rainfall model t The formula for the weight at time is: w ( t )= w 0+ i × A × t In the formula w ( t )for t The weight of time w 0 represents the initial weight, which is usually 0. i Rainfall intensity, expressed in mm / h. A The area of ​​the rain-collecting inlet of a weighing rain gauge is expressed in cm². 2 , t For time, the unit is hours (h).

[0035] The formula for deriving the increase in weight is: ΔM = h × A In the formula Δ M The increase in weight, expressed in grams. h Rainfall amount, in mm. A The area of ​​the rainwater inlet is expressed in cm². 2 In this embodiment, a 1500-type gravimetric rain and snow gauge with a rain collection port diameter of 20cm and a rain collection port area of ​​314.16cm² is selected. 2 The simplified formula for the increase in weight is: Δ M =0.1× h × A。 This code generates a basic precipitation signal using Python, and then adds noise and disturbances to it. Three types of noise (electronic noise, temperature noise, and wind noise) can be added using the following code logic. Taking temperature noise as an example: Create a time array array A drift array of the same length, initially set to 0, is used to iterate through each time point, starting from the second element of the time array with index 1. The drift value at each position t Equal to the drift value of the previous position. t-1 Add a random number that follows a normal distribution with a mean of 0 and a standard deviation of 0.001, and simultaneously calculate the maximum value of the absolute values ​​of all elements in the drift array. drift According to max drift The value limits the drift range: If max drift If the drift array is all zeros, then the constrained drift array is... limited It equals the original drift array; if max drift If the value is not 0, multiply each element of the original drift array by 0.5max. drift The drift array after the constraint is obtained. limited .

[0036] The following code logic allows you to add three types of perturbations (instantaneous perturbation, continuous perturbation, and complex perturbation), taking instantaneous perturbation as an example: Get the event time from the input parameters. time If not provided, the default value is 1800s.

[0037] Obtain the increment value from the input parameters. m If not provided, the default value is 15g.

[0038] In the time array arrayIn the middle, search for events with time. time Nearest position index event idx Specifically, it is necessary to calculate the absolute difference between each element in the time array and the event time, and find the index corresponding to the element with the smallest difference, which is the event. idx From the disturbed data array data event idx Starting from position 1, increment all subsequent elements by the increment value. m Returns the modified disturbed data array. data .

[0039] To visualize the timing of the disturbance and the entire weight change process, we can use the matplotlib library in Python. The following code logic can be used to visualize the entire weight change, taking an instantaneous disturbance as an example: Create a canvas and draw the time array "time" in the drawing area. array With instantaneous disturbance data step disturbed The curve is set to red and labeled "Instantaneous Disturbance". A vertical reference line is added to the plotting area with an x-coordinate of 1200, a green color, a dashed line (--), and a label "Disturbance Occurrence". The plotting area is titled "Instantaneous Disturbance", such as "Bird Droppings" or "Pebble". The plotting area's vertical axis label is set to "Weight g". Grid lines are added to the plotting area. A legend (containing labels for the curve and reference line) is displayed in the plotting area.

[0040] Step 2: Generate a perturbation label array for the generated precipitation signal containing three types of noise and three types of perturbation. The perturbation label array is 1 for perturbation and 0 for no perturbation. Create a dataset for machine learning based on the generated data and extract features. The perturbation label array is generated using the following code logic (taking instantaneous perturbation as an example): Iterate through the combinations of perturbation types and corresponding parameters, specifically dist type The perturbation type is `dist`, and `params` is the set of parameters for that type. If the current perturbation type is a step perturbation, i.e., `dist`... type Equals step: in the time array array In the context of the search, find the event in the event time parameter (params). time Nearest position index event idx The method is to calculate the relationship between each time point and the event. time The absolute difference is taken, and the index of the smallest difference is selected from the event of the label array labels. idxStarting at position 1, assign the value 1 to all elements after it.

[0041] The necessary dataset for subsequent machine learning model training is created through the following code logic: (1) Calculate the sampling rate: Divide 1 by the difference between two adjacent time points in the time array, which is the reciprocal of the time interval; (2) Calculate the number of sample points in the window: the window time length is... size Multiply by the sampling rate and round to the nearest integer to get the number of samples contained in the window. points .

[0042] (3) Calculate the step size sample number: Multiply the step time step by the sampling rate, and take the integer as the number of samples that the sliding window moves in each step step. points .

[0043] Initialize two empty lists X and y, where X stores the raw data of all windows, with a shape of sample number × window sample point number, and y stores the label of each window. It should be noted that the label has a shape of sample number.

[0044] (4) Initialize the window to position 0, and slide the window in a loop: When the starting position plus the number of window sample points does not exceed the total data length, perform the following operations: Calculate the end position of the window: end = start position + number of sample points in the window; Extract the raw data of the current window, specifically the portion of data from start to end, and store it in window. data ; Extract the label corresponding to the current window, that is, the part from start to end in labels, and store it in window. labels ; Determine the window label: If window labels If any element in the array has a value of 1, the current window label is recorded as 1; otherwise, it is recorded as 0. window data Add to list X, add the current window label to list y; Update the starting position: start = start + step size sample points, i.e., move the window; (5) After the loop ends, return X and y in array form, where X is the window data and y is the window label.

[0045] Simultaneously, features with clear physical meaning are extracted to improve model training, which is achieved through the following code logic: Initialize an empty list named features to store all extracted features, including: Extract basic statistical features and add them to the features list: mean, standard deviation, range, and absolute median of the window data. It should be noted that the mean of the window data reflects the overall weight level; the standard deviation reflects the degree of weight fluctuation; the range is the difference between the maximum and minimum values, reflecting the maximum fluctuation range; and the absolute median is calculated by first taking the absolute value of the difference between the data and the median, then calculating the median, reflecting the degree of noise resistance fluctuation.

[0046] Extracting trend features to reflect the rate of change of weight over time, used to distinguish between precipitation and disturbances: Generate a time index sequence corresponding to the window data, consisting of consecutive integers starting from 0; perform a linear fit between the window data and the time index, calculate the slope of the fitted line, which represents the rate of weight change per unit time, and add the slope to the features.

[0047] Extract mutation features, i.e. the core identification features of perturbation: calculate the first difference of the window data, i.e. the absolute value of the difference between adjacent data points, to obtain the change sequence; calculate the mean of the change sequence to reflect the overall degree of change and add it to features.

[0048] The maximum value of this change sequence is calculated to reflect the most dramatic single change and is a key indicator of step disturbances; it is then added to the features.

[0049] Extract periodic features to distinguish between vibration-related disturbances and normal precipitation: Calculate the standard deviation of the first-order difference sequence to reflect the stability of the changes. Vibration disturbances usually have a larger standard deviation, so add them to the features list. At the same time, set the anomaly threshold to 3 times the standard deviation of the difference sequence, count the number of times the difference sequence exceeds this threshold. Disturbances have more abrupt changes, so add the number of changes to the features list. Convert the features list to an array and return it.

[0050] Step 3: Select a machine learning model to train, optimize, and evaluate the enhanced dataset.

[0051] The data is standardized, and the SMOTE algorithm from the imbalanced-learn library in Python is used to handle the class imbalance problem. This is specifically implemented through the following code logic: Initialize the SMOTE oversampler with random as its input. state The random seed is set to 42, thus fixing the random seed to ensure that the result is reproducible; the output is the initialized SMOTE instance smote.

[0052] Perform SMOTE oversampling: Input is Xtrainscaled ytrain is the standardized training feature matrix, where rows = samples and columns = features; ytrain is the original training set labels, which contain majority and minority classes and exhibit class imbalance; the output is Xtrain. balanced ytrain is the training feature matrix that has been balanced after oversampling. balanced This refers to the balanced training labels after oversampling, where the number of samples in the majority class and the minority class are the same.

[0053] The random forest model is selected to train, tune, and evaluate the segmented data, ultimately yielding metrics such as the confusion matrix and ROC curve. The confusion matrix, generated using the sklearn.metrics.confusion matrix library in Python, is based on the comparison between the model's predicted labels and the true labels. The specific steps include: (1) Using the trained and optimized random forest model, predict the category label for the standardized test set features, where 0 = normal and 1 = perturbation.

[0054] Input is Xtest scaled This refers to the standardized test set feature matrix, where rows = test samples and columns = extracted features; the output is y. pred, That is, the predicted label array of the test set, with a length equal to the number of test samples, and element values ​​of 0 or 1.

[0055] (2) Statistically analyze the matching between the real labels on the test set and the predicted labels of the model to generate a binary classification confusion matrix.

[0056] Input is y test This is the true label array of the test set, with a length equal to the number of test samples, and element values ​​of 0 or 1; 0 = normal, 1 = perturbation; y pred That is, the model predicts the label array, and its length is the same as y. test Consistent with y, element value is 0 or 1; test The tag definitions are consistent.

[0057] The output is a confusion matrix, which is a 2x2 two-dimensional array in the format (TN, FP) and (FN, TP), where: TN represents a true negative example, indicating that the true value is 0 and the prediction value is 0, meaning that normal samples are correctly identified. FP stands for false positive, meaning that the true value is 0 and the prediction value is 1, that is, normal samples are misclassified as perturbations. FN stands for false negative, which means that the true value is 1 and the prediction value is 0, that is, the perturbation sample is misclassified as normal. TP is the true instance, indicating that the true value is 1 and the prediction value is 1, meaning that the perturbation sample is correctly identified.

[0058] The ROC curve is generated using the sklearn.metrics library in Python, based on class probabilities to calculate the false positive rate (FPR) and true positive rate (TPR) at different thresholds. The specific steps include: Using the optimized random forest model, predict the probability that each sample in the test set belongs to the perturbation class (positive class, label=1).

[0059] Input is best rf This refers to a random forest model instance that has been optimized by grid search and trained using SMOTE balancing, i.e., it has been fitted to the training data distribution; Xtest scaled This is the standardized test set feature matrix, where rows = test samples and columns = extracted features; it satisfies mean = 0 and standard deviation = 1; the output is y. prob , which is the probability array of the perturbation class, and its length is equal to the number of test samples. The element values ​​are ∈ [0,1], which represent the probability that each sample is a perturbation.

[0060] Based on the true label and perturbation class probabilities, calculate the key parameters (FPR, TPR, threshold) of the ROC curve, with the input being y. test This refers to the true label array of the test set, where the length equals the number of test samples, and each element is either 0 or 1; 0 = normal, 1 = perturbation; y prob That is, the probability array of the perturbation class, the length of which is the same as y. test Consistent, elements ∈ [0,1]; output is fpr, i.e. false positive rate array, FPR corresponding to each threshold, FPR=FP / (FP+TN); tpr, i.e. true positive rate array, TPR corresponding to each threshold, TPR=TP / (TP+FN); thresholds: threshold array, used to calculate the probability thresholds of FPR / TPR.

[0061] Furthermore, based on the visualization simulation process after adding perturbations, the timing and changes of the perturbations are shown more intuitively. A perturbation label array (1 represents perturbation, 0 represents normal) is generated to better segment the dataset and train the model. The segmentation dataset is set with a window size of 60s and a sliding interval of 5s. After segmenting the dataset, the model parameters are tuned and trained, the data is standardized, the imbalance of sample classes is handled, and the parameters are optimized by grid search. The random forest algorithm is used for training, and the training results are obtained and evaluated. The accuracy, precision, and recall are used for evaluation. The F1 score is mostly above 0.6, which can accurately identify the perturbation.

[0062] The weighing-type rain and snow gauge described in this embodiment has hardware parameters that conform to industry standard configurations: a power supply voltage of 11~14V DC, and a nominal operating power of no more than 0.7 watts (corresponding to an operating current of approximately 58 mA@12V). This power is mainly used for sensor sampling, data transmission, and basic calculations. To ensure that the deployment of the foreign object disturbance identification algorithm does not significantly increase device power consumption or affect the battery life in the field, this embodiment features a low-power-consumption design from both the architecture and model perspectives. (1) At the architecture level, a two-stage pipeline architecture combining anomaly detection and fine classification is adopted. Random forest model inference operation is only started when the slope of weight change exceeds the set threshold to avoid high power consumption operation at all times. (2) At the model level, a random forest model with no more than 80 kilobytes of parameters is selected to replace the complex deep learning model, which greatly reduces the computing power requirements and energy consumption of the inference process and adapts to the resource constraints of the embedded platform.

[0063] The total power consumption of the device after algorithm deployment does not exceed 0.9 watts (corresponding to an operating current of approximately 75 mA @ 12V), of which: The device's basic power consumption (when running without an algorithm) is 0.7 watts, mainly used for the sensor to sample once per second and transmit RS485 data once per minute; The power consumption increment of the first-level pipeline (anomaly detection stage) does not exceed 0.05 watts. This stage only calculates basic statistical characteristics such as the slope of weight change and standard deviation. The time taken for a single operation does not exceed 10 milliseconds, and the average number of triggers per day does not exceed 50. The incremental power consumption is much lower than the basic power consumption. The power consumption increment of the second-level pipeline (fine classification stage) does not exceed 0.15 watts. This stage is the inference process of the random forest model (the input features are lightweight low-dimensional feature vectors). The time for a single inference does not exceed 30 milliseconds, and the average number of triggers per day does not exceed 30. In terms of battery life, under normal scenarios with a 10Ah lithium battery and no more than 30 disturbance triggers per day, the device has a battery life of no less than 3 months, meeting the deployment requirements in the field without external power supply.

[0064] The low-power characteristic of this embodiment can be verified in the following ways: (1) Test environment: A weighing rain and snow gauge with a power supply voltage of 11~14V DC and a nominal power of 0.7W was selected, equipped with a 10Ah lithium battery, and the foreign object disturbance identification algorithm described in this embodiment was deployed to simulate three core scenarios: normal rain and snow, instantaneous disturbance, and continuous disturbance. (2) Test steps: Step 1: Test the basic power consumption of the device without deploying this algorithm, record the average operating current over 1 hour, and verify whether it meets the nominal power of 0.7 watts; Step 2: After deploying this algorithm, test the average operating current of the device in the three scenarios respectively, and calculate the power consumption increment brought by the algorithm. Step 3: Test continuously for 72 hours, record the battery voltage decay rate, and verify whether the battery life meets the requirement of no less than 3 months. (3) Verification criteria: The total power consumption of the device after algorithm superposition does not exceed 0.9 watts, the daily power consumption increment under abnormal disturbance scenarios does not exceed 0.2 watts, and the battery life is not less than 3 months.

[0065] Furthermore, through the collaborative design of a two-stage pipeline architecture and a lightweight model, this embodiment controls the power consumption increment of the foreign object disturbance identification algorithm to within 0.2 watts. Compared with the traditional all-time inference algorithm, the power consumption reduction ratio of this embodiment is no less than 40%, ensuring high-precision real-time identification while maintaining low power consumption.

[0066] Under normal circumstances, the total power consumption of the device after algorithm deployment will not exceed 0.9 watts. In extreme cases with dense disturbances and increased raw data volume, the total power consumption will not exceed 0.95 watts through mechanisms such as adaptive adjustment of anomaly detection threshold and fixed window data processing range. This is still within the power supply redundancy range of the 1500-type device and will not affect the stable operation of the device.

[0067] In summary, by utilizing the above-mentioned technical solution of the present invention, the present invention constructs a physical model-driven data simulator using Python. The simulator can generate high-precision real precipitation signals and various foreign object disturbance signals respectively. Based on the simulated data, features are extracted to train a lightweight machine learning classifier. The trained model is then deployed on the MCU of the rain and snow gauge. A two-stage pipeline architecture for fine classification triggered by anomalies is adopted to ensure high-precision real-time identification while maintaining low power consumption.

[0068] Furthermore, the present invention also provides an electronic device. For example... Figure 3 The diagram illustrates the hardware operating environment of an electronic device, which may include: a processor (e.g., CPU), memory, a user interface, a network interface, and a communication bus. The communication bus is used to enable communication between components. The user interface may include a display screen and an input unit such as a keyboard; optionally, the user interface may also include a standard wired interface or a wireless interface. The network interface may optionally include a standard wired interface or a wireless interface. The memory may be high-speed RAM or stable memory, such as disk storage. Alternatively, the memory may be a storage device independent of the aforementioned processor.

[0069] Those skilled in the art will understand that Figure 3The electronic devices shown do not constitute a limitation on electronic devices and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0070] like Figure 3 As shown, a memory, as a type of computer storage medium, may include an operating system, a network communication module, a user interface module, and device management programs. The operating system is a program that manages and controls the hardware and software resources of electronic devices, supporting the operation of electronic devices and other software or programs. Figure 3 In the electronic device shown, the user interface is mainly used to connect to the terminal and communicate with the terminal, such as receiving user signaling data sent by the terminal; the network interface is mainly used to communicate with the backend server; the processor can be used to call the program stored in the memory and execute the steps of the method or system described above.

[0071] Furthermore, the present invention also proposes a computer-readable storage medium storing a device management program, which, when executed by a processor, implements the steps of the method or system described above.

[0072] The specific embodiments of the computer-readable storage medium of the present invention are basically the same as those of the above-described methods or systems, and will not be repeated here. Furthermore, to achieve the above objectives, the present invention also provides a computer program product, comprising: a computer program, which, when executed by a processor, implements the steps of the methods or systems described above.

[0073] Those skilled in the art will recognize that the units and algorithm steps described in conjunction with the embodiments herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0074] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for online identification of foreign object disturbances in a weighing rain and snow gauge based on analog data-driven simulation, characterized in that, include: The formula for calculating the increase in output weight is based on the area of ​​the rain-collecting inlet of a weighing rain and snow gauge. Based on the formula for calculating the weight increase and the perturbation rules, a basic precipitation signal with noise perturbation and instantaneous perturbation is generated; A perturbation label array is generated based on the basic precipitation signal, and a learner is trained based on the window data filtered by the perturbation label array. The trained classifier is used as the machine learning recognition model for online perturbation identification. The machine learning recognition model is deployed into the main controller of the weighing rain and snow gauge. Based on a two-stage pipeline architecture, the machine learning recognition model is used to realize the online recognition of foreign object disturbances in the weighing rain and snow gauge.

2. The online foreign object disturbance identification method for a weighing rain and snow gauge based on analog data driven according to claim 1, characterized in that, The formula for calculating the increase in output weight based on the area of ​​the rain-collecting inlet of a weighing rain and snow gauge; Based on the formula for calculating the weight increase and the perturbation rules, a basic precipitation signal with noise and instantaneous perturbations is generated, including: The system obtains the rain-collecting area and precipitation of the weighing rain and snow gauge, outputs the calculation formula for the weight increase of the weighing rain and snow gauge, and generates a basic rainfall signal based on the weight increase calculation formula and programming technology. The time array is determined based on the basic rainfall signal, and a drift array with an initial value of zero and the same length as the time array is created. The drift value of each position in the drift array is determined by setting the starting point according to the loop traversal rule. Calculate the maximum absolute value of all elements in the drift array. If the maximum value is zero, the restricted drift array is equal to the original drift array. If the maximum value is non-zero, multiply the original drift array by the restricted drift range to obtain the restricted drift array, thus completing the noise disturbance addition process. Based on the constrained drift array, instantaneous perturbation processing is added, the perturbation data array is output, and a curve is plotted in the plotting area. Based on the curve, a basic precipitation signal with noise perturbation and instantaneous perturbation is generated.

3. The online foreign object disturbance identification method for a weighing rain and snow gauge based on analog data driven according to claim 2, characterized in that, The process of adding instantaneous perturbation processing to the constrained drift array, outputting a perturbation data array, plotting a curve within the plotting area, and generating a basic precipitation signal with noise perturbation and instantaneous perturbation based on the curve includes: The event time and increment value are obtained from the constrained drift array, and the absolute difference between each element in the time array and the event time is calculated. The index corresponding to the element with the smallest absolute difference is selected as the position index. Incremental values ​​are added to each element in the constrained drift array based on the position index to complete the instantaneous perturbation processing, obtain instantaneous perturbation data, and create a canvas based on the drawing area of ​​the data visualization library; Use the canvas to draw a curve between the time array and the instantaneous disturbance data, and set the curve label to instantaneous disturbance. At the same time, add a vertical reference line to the canvas and set the vertical reference line label to disturbance occurrence. Set the title and vertical axis labels of the plotting area as instantaneous disturbance and weight respectively. Use the plotting area to visualize the time and weight change process of the disturbance. Output the basic precipitation signal with noise disturbance and instantaneous disturbance based on the visualization results.

4. The online foreign object disturbance identification method for a weighing rain and snow gauge based on analog data driven according to claim 3, characterized in that, The process of generating a perturbation label array based on the baseline precipitation signal, training a learner based on the window data filtered by the perturbation label array, and using the trained classifier as the machine learning recognition model for online perturbation identification includes: A disturbance label array is generated based on the basic precipitation signal with noise and instantaneous disturbances. The disturbance type and the parameter set of the disturbance type are traversed. The difference between two adjacent time points in the time array is calculated based on the traversal results to obtain the sampling rate. By combining the sampling rate with the window time length and the step time, the number of samples contained in the window and the number of samples when the sliding window moves each time are calculated, thus obtaining the number of sample points in the window and the number of sample points in the step. The window's initial position is initialized by performing a cyclic sliding process using the number of window sample points and the step size sample points to obtain window data in array form. Feature data of the stored window data is extracted and stored in an empty list. By using synthetic minority class oversampling to balance the feature data, and training a random forest model based on the processed feature data, a machine learning recognition model for online identification of foreign object disturbances is obtained.

5. The online foreign object disturbance identification method for a weighing rain and snow gauge based on analog data driven according to claim 4, characterized in that, The step of extracting feature data from the storage window data and storing it in an empty list includes: The mean, standard deviation, range, and absolute median of the window data are extracted as basic statistical features, and the time index sequence of the window data is obtained. The time index sequence and the window data are then linearly fitted. The slope of the linear fitting result is determined to reflect the rate of change of weight over time. The first difference of the window data is calculated to obtain the sequence of changes in the window data. The mean and maximum value of the sequence of changes are then calculated. The mean and maximum values ​​reflect the drastic changes and single-time drastic changes in the window data. At the same time, the standard deviation of the first-order difference is calculated to determine the stability of the window data and the number of abnormal disturbances. Create an empty list, and then add the integrated basic statistical features, slope, degree of change, degree of single change, stability of change and number of abnormal disturbances to the empty list to complete the feature data addition process.

6. The online foreign object disturbance identification method for a weighing rain and snow gauge based on analog data driven according to claim 5, characterized in that, The step of balancing the feature data using synthetic minority class oversampling technology and training a random forest model based on the processed feature data to obtain a machine learning recognition model for online foreign object disturbance identification includes: After standardizing the feature data, a random seed for the synthetic minority oversampler is initialized, and the synthetic minority oversampler is used to balance the feature data and output the oversampled training feature matrix. The training feature matrix is ​​used as the test input of the random forest model. The random forest model outputs a predicted label array, and the matching between the true labels of the training feature matrix and the predicted label array is statistically analyzed to obtain the binary classification confusion matrix. Based on the generation of a binary confusion matrix, a trade-off is made between the ability of the random forest model to identify positive classes and the cost of misclassification. The random forest model is then optimized using this trade-off to obtain a machine learning recognition model for online identification of foreign object disturbances.

7. The online foreign object disturbance identification method for a weighing rain and snow gauge based on analog data driven according to claim 6, characterized in that, The binary confusion matrix is ​​a two-dimensional numerical value, in the format of true negative examples and false positive examples, and false negative examples and true examples. The true negative example indicates that the normal sample is correctly identified, and the false positive example indicates that the normal sample is misjudged as a perturbation; the false negative example indicates that the perturbation sample is misjudged as normal, and the true positive example indicates that the perturbation sample is correctly identified.

8. A foreign object disturbance online identification system for a weighing rain and snow gauge based on analog data driving, used to implement the foreign object disturbance online identification method for a weighing rain and snow gauge based on analog data driving as described in any one of claims 1-7, characterized in that, The system includes: The simulation data generation module is used to output the weight increase calculation formula based on the area of ​​the rain-collecting inlet of the weighing rain and snow gauge; and to generate a basic precipitation signal with noise and instantaneous disturbances according to the weight increase calculation formula and disturbance rules. The identification model building module is used to generate a perturbation label array based on the basic precipitation signal, and to train a learner based on the window data filtered by the perturbation label array. The trained classifier is used as the machine learning identification model for online perturbation identification. An online identification module is deployed to deploy the machine learning identification model into the main controller of the weighing rain and snow gauge. Based on a two-stage pipeline architecture, the machine learning identification model is used to realize the online identification of foreign object disturbances in the weighing rain and snow gauge.

9. An electronic device, characterized in that, The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When executed by the processor, the computer program implements the steps of the online foreign object disturbance identification method for a weighing rain and snow gauge based on analog data driven as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the online foreign object disturbance identification method for a weighing rain and snow gauge based on analog data driven as described in any one of claims 1 to 7.