Peak-to-peak value calculation method and apparatus
By combining the extreme value identification sliding window and the peak-to-peak value filtering sliding window with the quartile method, the problems of low efficiency and insufficient accuracy of peak-to-peak value calculation in the existing technology are solved, and efficient and accurate peak-to-peak value calculation is realized in industrial control systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING GUODIAN ZHISHEN CONTROL TONGDY
- Filing Date
- 2026-03-13
- Publication Date
- 2026-06-16
AI Technical Summary
Existing peak-to-peak value calculation methods are difficult to achieve efficient and high-precision calculations when faced with noise and impulse interference in industrial control systems. In particular, traditional methods involve large computational loads and cannot meet the real-time requirements of high-frequency sampling.
A method combining extreme value identification sliding window and peak-to-peak value filtering sliding window with quartiles is adopted. The extreme value identification sliding window quickly identifies extreme values and filters out impulse noise. The peak-to-peak value filtering sliding window and the same array are sorted. Abnormal peak-to-peak values are corrected based on quartiles, reducing computational complexity.
It achieves efficient and accurate peak-to-peak value calculation under noise and sudden interference, reduces computational complexity, adapts to signals with different frequencies and noise levels, and meets the high precision requirements of industrial control systems.
Smart Images

Figure CN122220698A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial control system controller technology, and in particular to a peak-to-peak value calculation method and apparatus. Background Technology
[0002] Because industrial control systems are subject to varying degrees of interference in the field, the controller requires high accuracy in the peak-to-peak value of the signal and needs to perform rapid peak-to-peak value calculation.
[0003] However, current peak-to-peak value calculation methods mainly include: Fixed-window extremum method: finding the maximum and minimum values within a fixed data window, and using the difference as the peak-to-peak value. This method is simple to implement, but it cannot effectively handle noise and impulse interference, and is prone to abrupt changes in values. Traditional Hampshire filtering method: identifying and replacing outliers based on the median and absolute median difference. This method has strong anti-interference capabilities, but it is computationally intensive, especially the median sorting and absolute median difference calculation, which are time-consuming and difficult to meet the real-time requirements of high-frequency sampling. Summary of the Invention
[0004] In view of this, the present invention provides a peak-to-peak value calculation method and apparatus, which achieves high efficiency and high accuracy in calculating peak-to-peak values.
[0005] According to one aspect of the present invention, a peak-to-peak value calculation method is provided, the method comprising: Obtain a preset extreme value recognition sliding window; For a signal sequence, identify whether the signal at the center sampling point of the current extreme value identification sliding window is an extreme value. If so, determine its extreme value type, store the identified extreme values and their corresponding extreme value types in the extreme value sequence in chronological order, and calculate the peak-to-peak value sequence based on the extreme value sequence. Obtain a preset peak-to-peak value filtering sliding window and a preset array of the same size as the peak-to-peak value filtering sliding window; For the peak-to-peak sequence, based on the array, sort the peak-to-peak values of the current peak-to-peak filtering sliding window to obtain the current ordered array, determine the quartiles of the current ordered array, and determine whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal based on the quartiles. If so, correct the latest peak-to-peak value based on the current ordered array and the quartiles to obtain the corrected latest peak-to-peak value.
[0006] Preferably, the extreme value identification sliding window includes an odd number of sampling points.
[0007] Preferably, the peak-to-peak filtering sliding window includes an odd number of peak-to-peak values.
[0008] Preferably, the step of identifying whether the signal at the center sampling point of the current extreme value identification sliding window is an extreme value, and if so, determining its extreme value type, includes: Identify whether the signal at the center sampling point of the current extreme value identification sliding window is a maximum value; if so, determine that its extreme value type is a peak value. Identify whether the signal at the center sampling point of the current extreme value identification sliding window is a minimum value. If so, determine that its extreme value type is a valley value.
[0009] Preferably, the step of calculating the peak-to-peak value sequence based on the extreme value sequence includes: Monitor whether an event of extreme value type jump occurs in the extreme value sequence. If so, calculate the absolute value of the difference between the current extreme value and the previous extreme value as the peak-to-peak value. All the peak values are arranged in chronological order to form a peak-to-peak sequence.
[0010] Preferably, determining the quartiles of the current ordered array, and judging whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal based on the quartiles, if so, correcting the latest peak-to-peak value based on the current ordered array and the quartiles to obtain the corrected latest peak-to-peak value, includes: Determine the first quartile, the second quartile, and the third quartile of the current ordered array, wherein the quartiles include the first quartile, the second quartile, and the third quartile; Calculate the absolute value of the difference between the third quartile and the first quartile to obtain the interquartile range; Based on the interquartile range, determine whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal. If so, correct the latest peak-to-peak value based on the current ordered array and the second quartile to obtain the corrected latest peak-to-peak value.
[0011] Preferably, the step of determining whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal based on the interquartile range, and if so, correcting the latest peak-to-peak value based on the current ordered array and the second quartile to obtain the corrected latest peak-to-peak value, includes: The target value is obtained by multiplying the interquartile range by a preset constant. If the current ordered array is arranged in ascending order, the first quartile is subtracted from the target value to obtain the low boundary value, and the third quartile is added to the target value to obtain the high boundary value. If the current ordered array is arranged in descending order, the third quartile is subtracted from the target value to obtain the low boundary value, and the first quartile is added to the target value to obtain the high boundary value. If the latest peak value is less than or equal to the low boundary value, or greater than or equal to the high boundary value, then the latest peak value is abnormal. The second quartile is used to replace the latest peak value to obtain the corrected latest peak value.
[0012] According to another aspect of the present invention, a peak-to-peak value calculation device is provided, the device comprising: The first acquisition module is used to acquire a preset extreme value recognition sliding window; The calculation module is used to identify whether the signal at the center sampling point of the current extreme value identification sliding window is an extreme value in the signal sequence. If it is, the extreme value type is determined, and the identified extreme values and their corresponding extreme value types are stored in the extreme value sequence in chronological order. The peak-to-peak value sequence is calculated based on the extreme value sequence. The second acquisition module is used to acquire a preset peak-to-peak value filtering sliding window and a preset array of the same size as the peak-to-peak value filtering sliding window; The determination module is used to sort the peak-to-peak values of the current peak-to-peak filtering sliding window based on the array to obtain a current ordered array, determine the quartiles of the current ordered array, and determine whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal based on the quartiles. If so, the latest peak-to-peak value is corrected based on the current ordered array and the quartiles to obtain the corrected latest peak-to-peak value.
[0013] According to another aspect of the present invention, a storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the above-described peak-to-peak value calculation method.
[0014] According to another aspect of the present invention, a computer device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor executes the program to implement the above-described peak-to-peak value calculation method.
[0015] By employing the above technical solution, the present invention provides a peak-to-peak value calculation method and apparatus. Through this invention, since signal interference comes in two forms—impulse noise, which does not affect the accuracy of extreme value identification, and strong pulse or large-amplitude abrupt changes—which do affect the accuracy of extreme value identification, the extreme value identification sliding window quickly and efficiently outputs extreme values. The identified extreme values filter out impulse noise, but abrupt changes may still exist. By using a peak-to-peak value filtering sliding window and an array of the same size, abnormal peak-to-peak values are accurately identified. These abnormal peak-to-peak values are corrected based on quartiles, reducing computational complexity. Furthermore, it exhibits strong adaptability; the size of both the extreme value identification sliding window and the peak-to-peak value filtering sliding window is adjustable, enabling it to adapt to signals of different frequencies and noise levels.
[0016] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0017] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of this application. In the drawings: Figure 1 A flowchart illustrating a peak-to-peak value calculation method provided by an embodiment of the present invention is shown; Figure 2 A flowchart illustrating another peak-to-peak value calculation method provided by an embodiment of the present invention is shown; Figure 3 A schematic diagram of the structure of a peak-to-peak value calculation device provided in an embodiment of the present invention is shown; Figure 4 A schematic diagram of another peak-to-peak value calculation device provided in an embodiment of the present invention is shown. Detailed Implementation
[0018] The present invention will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.
[0019] This embodiment provides a method for calculating peak-to-peak value, such as... Figure 1 As shown, the method includes: 101. Obtain the preset extreme value recognition sliding window.
[0020] It should be noted that the application scenario of this invention is a distributed control system, aiming to improve the processing performance of the data acquisition module in a distributed control system card. A distributed control system is an automated control system widely used in the field of industrial control, characterized by multiple controllers distributed in various locations working together to complete control tasks and communicating through a high-speed data network. It is suitable for large-scale, complex industrial process control, such as in the chemical, power, and metallurgical industries.
[0021] In this embodiment, a sliding window is used: a fixed-size window slides sequentially over the data sequence, processing only the data within the window each time, and when the latest data enters the window, the oldest data is removed.
[0022] The extreme value identification sliding window is used to sequentially slide across a signal sequence to identify extreme values.
[0023] The preset extreme value recognition sliding window refers to the size of the preset extreme value recognition sliding window. Preferably, in order to ensure that the complete signal cycle is included, and to avoid the window being too large and causing a decrease in calculation speed, the size of the extreme value recognition sliding window is greater than the number of sampling points of one signal cycle and less than the number of sampling points of two signal cycles.
[0024] A sampling point includes a sampling time and the signal corresponding to that sampling time. A sampling point includes a sampling time and the signal corresponding to that sampling time.
[0025] 102. For a signal sequence, identify whether the signal at the center sampling point of the current extreme value identification sliding window is an extreme value. If so, determine its extreme value type, store the identified extreme values and their corresponding extreme value types in the extreme value sequence in chronological order, and calculate the peak-to-peak value sequence based on the extreme value sequence.
[0026] In this embodiment, since it is necessary to identify whether the signal at the center sampling point of the current extreme value identification sliding window is an extreme value, the number of sampling points included in the extreme value identification sliding window needs to be odd. Extreme value types include peak values and valley values.
[0027] The center sampling point refers to the sampling point located at the center of the current extreme value recognition sliding window. The size of the extreme value recognition sliding window is M sampling points, and the sampling point index starts from 0. The center sampling point of the current extreme value recognition sliding window is sampling point (M-1) / 2. For example, if M is 5, the current extreme value recognition sliding window includes: sampling point 0, sampling point 1, sampling point 2, sampling point 3, sampling point 4, and sampling point 5. The center sampling point is sampling point 2.
[0028] When determining whether the signal at the center sampling point is an extreme value, the signal at the center sampling point is compared with the signals of all other sampling points within the current extreme value identification sliding window (all other sampling points are all sampling points within the current extreme value identification sliding window excluding the center sampling point). If the signal at the center sampling point is smaller than the signals of all other sampling points, it is a valley value; if the signal at the center sampling point is larger than the signals of all other sampling points, it is a peak value; if the signal at the center sampling point is neither smaller nor larger than the signals of all other sampling points, then the signal at the center sampling point is not an extreme value.
[0029] Peak-to-peak value (PVP) is the sum of the peak value and the trough value within a signal cycle. PVP reflects the strength or state of an industrial signal.
[0030] 103. Obtain a preset peak-to-peak value filtering sliding window and a preset array of the same size as the peak-to-peak value filtering sliding window.
[0031] In this embodiment, the peak-to-peak filtering sliding window is used to slide sequentially on the peak-to-peak sequence to determine whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal.
[0032] The preset peak-to-peak value filtering sliding window refers to the size of the preset peak-to-peak value filtering sliding window. The number of peaks and peaks included in the peak-to-peak value filtering sliding window can be odd or even, and is not limited here. In order to sort the peak-to-peak value sequence within the peak-to-peak value filtering sliding window, an array with the same size as the peak-to-peak value filtering sliding window is maintained.
[0033] It should be noted that this array is an ordered array, and incremental updates are achieved through bubble sort, thus efficiently obtaining the peak value.
[0034] 104. For the peak-to-peak sequence, based on the array, sort the peak-to-peak values of the current peak-to-peak filtering sliding window to obtain the current ordered array, determine the quartiles of the current ordered array, and determine whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal based on the quartiles. If so, correct the latest peak-to-peak value based on the current ordered array and the quartiles to obtain the corrected latest peak-to-peak value.
[0035] In this embodiment, the current ordered array is obtained by sorting the peak-to-peak values of the current peak-to-peak filtering sliding window. It can be sorted from largest to smallest peak-to-peak value or from smallest to largest peak-to-peak value; there is no limitation here.
[0036] If a new peak value is to be added to the previous ordered array of the current ordered array, that is, the latest peak value, the earliest peak value to enter the previous ordered array (named the oldest peak value) is removed, resulting in the previous ordered array with the oldest peak value removed. Then, the latest peak value is sorted by peak value size in the previous ordered array with the oldest peak value removed, resulting in the current ordered array.
[0037] For example, if the previous sorted array is [3(t2), 5(t1), 8(t3)] and the latest peak value is 7, then the current sorted array is [3(t2), 7(t4), 8(t3)].
[0038] Quartiles: The dividing points that divide a set of data, sorted by size, into four equal parts. The first quartile is the 25th percentile, the second quartile is the 50th percentile, and the third quartile is the 75th percentile.
[0039] The quartiles are used to determine whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal. If it is abnormal (abnormal means that the latest peak-to-peak value of the current peak-to-peak filtering sliding window is an outlier or a sudden change value, which will cause the calculated peak-to-peak value to fluctuate drastically), it is also used to correct the latest peak-to-peak value.
[0040] It's important to note that the traditional Hanpour filter is a robust outlier filtering method based on the median and absolute median difference. It considers data points whose deviation from the median exceeds a certain threshold as outliers and replaces them with the median. However, the absolute median difference is a robust statistic that measures the degree of data dispersion. It is calculated as the median of the absolute values of the deviations of all data points from the median. Because its calculation involves solving for the median twice, it is computationally time-consuming. Therefore, to reduce computational complexity, the quartile method is used.
[0041] This invention provides a peak-to-peak value calculation method and apparatus. The technical solution addresses two types of signal interference: impulse noise, which does not affect the accuracy of extreme value identification, and strong impulse or large-amplitude abrupt changes, which do affect the accuracy of extreme value identification. By using an extreme value identification sliding window, extreme values are output quickly and efficiently. While impulse noise is filtered out, abrupt changes may still exist. Through a peak-to-peak value filtering sliding window and an array of the same size, abnormal peak-to-peak values are accurately identified. These abnormal peak-to-peak values are corrected based on quartiles, reducing computational complexity. Furthermore, the invention exhibits strong adaptability; the sizes of both the extreme value identification sliding window and the peak-to-peak value filtering sliding window are adjustable, enabling adaptation to signals of different frequencies and noise levels.
[0042] Furthermore, as a refinement and extension of the specific implementation methods described above, and to fully illustrate the specific implementation process in this embodiment, another peak-to-peak value calculation method is provided, such as... Figure 2 As shown, the method includes: 201. Obtain the preset extreme value recognition sliding window.
[0043] In this embodiment, the extreme value identification sliding window includes an odd number of sampling points.
[0044] 202. For a signal sequence, identify whether the signal at the center sampling point of the current extreme value identification sliding window is an extreme value. If so, determine its extreme value type and store the identified extreme value and its corresponding extreme value type into the extreme value sequence in chronological order.
[0045] In this embodiment, identifying whether the signal at the center sampling point of the current extreme value identification sliding window is an extreme value, and if so, determining its extreme value type, includes: identifying whether the signal at the center sampling point of the current extreme value identification sliding window is a maximum value, and if so, determining its extreme value type as a peak value; identifying whether the signal at the center sampling point of the current extreme value identification sliding window is a minimum value, and if so, determining its extreme value type as a valley value.
[0046] 203. Calculate the peak-to-peak value sequence based on the extreme value sequence.
[0047] In this embodiment, the step of calculating the peak-to-peak value sequence based on the extreme value sequence includes: monitoring whether an event of extreme value type jump occurs in the extreme value sequence; if so, calculating the absolute value of the difference between the current extreme value and the previous extreme value as the peak-to-peak value; and constructing a peak-to-peak value sequence by arranging all the peak-to-peak values in chronological order.
[0048] Among them, extreme value type jump refers to the extreme value type of the current extreme value being a peak value and the extreme value type of the previous extreme value being a valley value, or the extreme value type of the current extreme value being a valley value and the extreme value type of the previous extreme value being a peak value.
[0049] It should be noted that since the calculation of peak-to-peak values depends on the correctness of peak and valley values, the peak-to-peak value sequence calculated in steps 201-203 of the embodiment can only suppress interference that does not affect the determination of peak and valley values, but cannot suppress interference that is greater than the true peak value and less than the true valley value. Such interference will cause the calculated peak-to-peak value to be abrupt. Therefore, the purpose of steps 204-208 of the subsequent embodiment is to identify whether the latest peak-to-peak value in the peak-to-peak value sequence is abnormal. If it is abnormal, it is corrected to obtain the corrected peak-to-peak value.
[0050] 204. Obtain a preset peak-to-peak value filtering sliding window and a preset array of the same size as the peak-to-peak value filtering sliding window.
[0051] It should be noted that the number of peak-to-peak values included in the peak-to-peak filtering sliding window can be odd or even. However, in subsequent calculations based on the peak-to-peak filtering sliding window, the computational workload is smaller when the number of peak-to-peak values is odd compared to when it is even. Therefore, we assume here that the number of peak-to-peak values included in the peak-to-peak filtering sliding window is odd, i.e., 2k+1 (for example, 2k+1 is 7). In subsequent calculations, we will use the assumption that the number of peak-to-peak values included in the peak-to-peak filtering sliding window is odd. The size of the array, which is also the number of peak-to-peak values included in the array, is also 2k+1.
[0052] 205. Based on the array, sort the peak-to-peak values of the current peak-to-peak filtering sliding window to obtain the current ordered array.
[0053] In this embodiment, the peak-to-peak value of the current peak-to-peak filtering sliding window is set as follows:
[0054] in, It is the first peak value of the current peak-to-peak filtering sliding window (index is 1). It is the second peak value of the current peak-to-peak filtering sliding window (index is 2). It is the latest peak-to-peak value (index n) of the current peak-to-peak filtering sliding window. It should be noted that the peak-to-peak value sequence and the peak-to-peak value of the current peak-to-peak filtering sliding window are both sorted in chronological order.
[0055] Since the peak-to-peak values of the current peak-to-peak filtering sliding window are not sorted (the sorting here is not chronological order, but peak-to-peak value size), in order to identify whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal, the peak-to-peak values of the current peak-to-peak filtering sliding window are sorted in the array according to the peak-to-peak value size to obtain the current ordered array. It can be sorted by peak-to-peak value from smallest to largest, or by peak-to-peak value from largest to smallest. In the subsequent calculations, sorting by peak-to-peak value from smallest to largest will be explained.
[0056] 206. Determine the first quartile, the second quartile, and the third quartile of the current ordered array, wherein the quartiles include the first quartile, the second quartile, and the third quartile.
[0057] In this embodiment, the first quartile is the peak-to-peak value of the current ordered array at the first quartile (25th percentile), the second quartile is the peak-to-peak value of the current ordered array at the second quartile (50th percentile), and the third quartile is the peak-to-peak value of the current ordered array at the third quartile (75th percentile).
[0058] Specifically: In the current sorted array with index 1, the first quartile of the current sorted array is: 0.25. (2k+1+1), the second quartile of the current sorted array is: 0.5 (2k+1+1), the third quartile of the current sorted array is: 0.75 (2k+1+1).
[0059] For example, in the current sorted array, sorted from smallest to largest, with indices starting from 1: [2,4,6,8,10,12,14], 2k+1=7, the first quartile is 2, the corresponding peak value is 4, the second quartile is 4, the corresponding peak value is 8, and the third quartile is 6, the corresponding peak value is 12.
[0060] If the first, second, or third quartile is not an integer, then linear interpolation is used. The linear interpolation method will not be elaborated here.
[0061] 207. Calculate the absolute value of the difference between the third quartile and the first quartile to obtain the interquartile range.
[0062] Interquartile range: Represents the range of the middle 50% of the data.
[0063] 208. Determine whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal based on the interquartile range. If so, correct the latest peak-to-peak value based on the current ordered array and the second quartile to obtain the corrected latest peak-to-peak value.
[0064] In this embodiment, determining whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal based on the interquartile range (IQAR) and if so, correcting the latest peak-to-peak value based on the current ordered array and the second IQAR to obtain the corrected latest peak-to-peak value includes: calculating the product of the IQAR and a preset constant to obtain a target value; if the current ordered array is arranged in ascending order, calculating the first IQAR minus the target value to obtain a low boundary value, and calculating the third IQAR plus the target value to obtain a high boundary value; if the current ordered array is arranged in descending order, calculating the third IQAR minus the target value to obtain a low boundary value, and calculating the first IQAR plus the target value to obtain a high boundary value; if the latest peak-to-peak value is less than or equal to the low boundary value, or greater than or equal to the high boundary value, then the latest peak-to-peak value is abnormal, and the second IQAR is used to replace the latest peak-to-peak value to obtain the corrected latest peak-to-peak value.
[0065] The preset constant is, for example, 3.
[0066] If the latest peak value is greater than the low boundary value and less than the high boundary value, then the latest peak value is not abnormal; that is, the latest peak value is a true peak value.
[0067] This invention provides a peak-to-peak value calculation method and apparatus. The technical solution addresses two types of signal interference: impulse noise, which does not affect the accuracy of extreme value identification, and strong impulse or large-amplitude abrupt changes, which do affect the accuracy of extreme value identification. By using an extreme value identification sliding window, extreme values are output quickly and efficiently. While impulse noise is filtered out, abrupt changes may still exist. Through a peak-to-peak value filtering sliding window and an array of the same size, abnormal peak-to-peak values are accurately identified. These abnormal peak-to-peak values are corrected based on quartiles, reducing computational complexity. Furthermore, the invention exhibits strong adaptability; the sizes of both the extreme value identification sliding window and the peak-to-peak value filtering sliding window are adjustable, enabling adaptation to signals of different frequencies and noise levels.
[0068] Furthermore, as Figure 1 and Figure 2 To provide a specific implementation of the method shown, this embodiment of the invention provides a peak-to-peak value calculation device, such as... Figure 3 As shown, the device includes: a first acquisition module 31, a calculation module 32, a second acquisition module 33, and a determination module 34; The first acquisition module 31 is used to acquire a preset extreme value recognition sliding window; The calculation module 32 is used to identify whether the signal at the center sampling point of the current extreme value identification sliding window is an extreme value in the signal sequence. If so, it determines the extreme value type, stores the identified extreme values and their corresponding extreme value types in the extreme value sequence in chronological order, and calculates the peak-to-peak value sequence based on the extreme value sequence. The second acquisition module 33 is used to acquire a preset peak-to-peak value filtering sliding window and a preset array of the same size as the peak-to-peak value filtering sliding window; The determining module 34 is used to sort the peak-to-peak values of the current peak-to-peak filtering sliding window based on the array to obtain a current ordered array, determine the quartiles of the current ordered array, and determine whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal based on the quartiles. If so, the latest peak-to-peak value is corrected based on the current ordered array and the quartiles to obtain the corrected latest peak-to-peak value.
[0069] Correspondingly, the first acquisition module 31 is specifically used to ensure that the number of sampling points included in the extreme value identification sliding window is odd.
[0070] Correspondingly, the second acquisition module 33 is specifically used to ensure that the number of peaks and peaks included in the peak-to-peak filtering sliding window is odd.
[0071] Accordingly, in order to identify whether the signal at the center sampling point of the current extreme value recognition sliding window is an extreme value, and if so, to determine its extreme value type, the calculation module 32 is specifically used to identify whether the signal at the center sampling point of the current extreme value recognition sliding window is a maximum value, and if so, to determine that its extreme value type is a peak value; and to identify whether the signal at the center sampling point of the current extreme value recognition sliding window is a minimum value, and if so, to determine that its extreme value type is a valley value.
[0072] Accordingly, in order to calculate the peak-to-peak value sequence based on the extreme value sequence, the calculation module 32 is specifically used to monitor whether an event of extreme value type jump occurs in the extreme value sequence. If so, the absolute value of the difference between the current extreme value and the previous extreme value is calculated as the peak-to-peak value; and all the peak-to-peak values are arranged in chronological order to form a peak-to-peak value sequence.
[0073] Accordingly, in order to determine the quartiles of the current ordered array, the latest peak value of the current peak-to-peak filtering sliding window is judged to be abnormal based on the quartiles. If so, the latest peak value is corrected based on the current ordered array and the quartiles to obtain the corrected latest peak value. The determining module 34 specifically includes: a determining unit 341 and a judging unit 342. The determining unit 341 is specifically used to determine the first quartile, the second quartile, and the third quartile of the current ordered array, wherein the quartiles include the first quartile, the second quartile, and the third quartile; and to calculate the absolute value of the difference between the third quartile and the first quartile to obtain the interquartile range. The judgment unit 342 is specifically used to determine whether the latest peak value of the current peak-to-peak filtering sliding window is abnormal based on the interquartile range. If so, the latest peak value is corrected based on the current ordered array and the second quartile to obtain the corrected latest peak value.
[0074] Accordingly, in order to determine whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal based on the interquartile range, if so, the latest peak-to-peak value is corrected based on the current ordered array and the second quartile to obtain the corrected latest peak-to-peak value. The judgment unit 342 is specifically used to calculate the product of the interquartile range and a preset constant to obtain the target value. If the current ordered array is arranged in ascending order, the first quartile is subtracted from the target value to obtain the low boundary value, and the third quartile is added to the target value to obtain the high boundary value. If the current ordered array is arranged in descending order, the third quartile is subtracted from the target value to obtain the low boundary value, and the first quartile is added to the target value to obtain the high boundary value. If the latest peak-to-peak value is less than or equal to the low boundary value, or greater than or equal to the high boundary value, the latest peak-to-peak value is abnormal, and the second quartile is used to replace the latest peak-to-peak value to obtain the corrected latest peak-to-peak value.
[0075] It should be noted that other corresponding descriptions of the functional units involved in the peak-to-peak value calculation device provided in this embodiment can be found in [reference]. Figures 1 to 2 The corresponding description will not be repeated here.
[0076] Based on the above, Figures 1 to 2 Accordingly, this embodiment also provides a storage medium, which may be volatile or non-volatile, storing a computer program that, when executed by a processor, implements the above-described method. Figures 1 to 2 The peak-to-peak value calculation method is shown.
[0077] Based on this understanding, the technical solution of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, portable hard drive, etc.) and includes several instructions to cause a computer device (such as a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present invention.
[0078] Based on the above, Figures 1 to 2 The method shown and Figure 3 , Figure 4 To achieve the above objectives, the present application also provides a computer device, specifically a personal computer, server, network device, etc., as shown in the illustrated embodiment. This computer device includes a storage medium and a processor; the storage medium stores a computer program; the processor executes the computer program to achieve the above-described objectives. Figure 1 and Figure 2 The peak-to-peak value calculation method is shown.
[0079] Optionally, the computer device may also include a user interface, a network interface, a camera, radio frequency (RF) circuitry, sensors, audio circuitry, a Wi-Fi module, etc. The user interface may include a display screen, input units such as a keyboard, etc., and optional user interfaces may also include USB interfaces, card reader interfaces, etc. The network interface may optionally include standard wired interfaces, wireless interfaces (such as Wi-Fi interfaces), etc.
[0080] Those skilled in the art will understand that the computer device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or combine certain components, or have different component arrangements.
[0081] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the aforementioned computer device, supporting the operation of information processing programs and other software and / or programs. The network communication module is used to enable communication between the various components within the non-volatile storage medium, as well as communication with other hardware and software in the information processing entity device.
[0082] Through the above description of the embodiments, those skilled in the art can clearly understand that the present invention can be implemented by means of software plus necessary general-purpose hardware platform, or it can be implemented by hardware.
[0083] This invention provides a peak-to-peak value calculation method and apparatus. The technical solution addresses two types of signal interference: impulse noise, which does not affect the accuracy of extreme value identification, and strong impulse or large-amplitude abrupt changes, which do affect the accuracy of extreme value identification. By using an extreme value identification sliding window, extreme values are output quickly and efficiently. While impulse noise is filtered out, abrupt changes may still exist. Through a peak-to-peak value filtering sliding window and an array of the same size, abnormal peak-to-peak values are accurately identified. These abnormal peak-to-peak values are corrected based on quartiles, reducing computational complexity. Furthermore, the invention exhibits strong adaptability; the sizes of both the extreme value identification sliding window and the peak-to-peak value filtering sliding window are adjustable, enabling adaptation to signals of different frequencies and noise levels.
[0084] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of a preferred embodiment, and the modules or processes shown in the drawings are not necessarily essential for implementing the present invention. Those skilled in the art will understand that the modules in the apparatus of the embodiment can be distributed within the apparatus of the embodiment as described, or they can be located in one or more apparatuses different from this embodiment, with corresponding changes. The modules of the above-described embodiment can be combined into one module, or further divided into multiple sub-modules.
[0085] The serial numbers used above are for descriptive purposes only and do not represent the superiority or inferiority of the implementation scenarios. The above disclosures are merely a few specific implementation scenarios of the present invention; however, the present invention is not limited thereto, and any variations conceived by those skilled in the art should fall within the protection scope of the present invention.
Claims
1. A method for calculating peak-to-peak value, characterized in that, The method includes: Obtain a preset extreme value recognition sliding window; For a signal sequence, identify whether the signal at the center sampling point of the current extreme value identification sliding window is an extreme value. If so, determine its extreme value type, store the identified extreme values and their corresponding extreme value types in the extreme value sequence in chronological order, and calculate the peak-to-peak value sequence based on the extreme value sequence. Obtain a preset peak-to-peak value filtering sliding window and a preset array of the same size as the peak-to-peak value filtering sliding window; For the peak-to-peak sequence, based on the array, sort the peak-to-peak values of the current peak-to-peak filtering sliding window to obtain the current ordered array, determine the quartiles of the current ordered array, and determine whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal based on the quartiles. If so, correct the latest peak-to-peak value based on the current ordered array and the quartiles to obtain the corrected latest peak-to-peak value.
2. The method according to claim 1, characterized in that, The extreme value identification sliding window includes an odd number of sampling points.
3. The method according to claim 1, characterized in that, The peak-to-peak filtering sliding window includes an odd number of peak-to-peak values.
4. The method according to claim 1, characterized in that, The process involves identifying whether the signal at the center sampling point of the current extreme value identification sliding window is an extreme value. If so, the extreme value type is determined, including: Identify whether the signal at the center sampling point of the current extreme value identification sliding window is a maximum value; if so, determine that its extreme value type is a peak value. Identify whether the signal at the center sampling point of the current extreme value identification sliding window is a minimum value. If so, determine that its extreme value type is a valley value.
5. The method according to claim 1 or 4, characterized in that, The step of calculating the peak-to-peak value sequence based on the extreme value sequence includes: Monitor whether an event of extreme value type jump occurs in the extreme value sequence. If so, calculate the absolute value of the difference between the current extreme value and the previous extreme value as the peak-to-peak value. All the peak values are arranged in chronological order to form a peak-to-peak sequence.
6. The method according to claim 1, characterized in that, The process of determining the quartiles of the current ordered array, and judging whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal based on the quartiles, and if so, correcting the latest peak-to-peak value based on the current ordered array and the quartiles to obtain the corrected latest peak-to-peak value, includes: Determine the first quartile, the second quartile, and the third quartile of the current ordered array, wherein the quartiles include the first quartile, the second quartile, and the third quartile; Calculate the absolute value of the difference between the third quartile and the first quartile to obtain the interquartile range; Based on the interquartile range, determine whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal. If so, correct the latest peak-to-peak value based on the current ordered array and the second quartile to obtain the corrected latest peak-to-peak value.
7. The method according to claim 6, characterized in that, The step of determining whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal based on the quartile interval, and if so, correcting the latest peak-to-peak value based on the current ordered array and the second quartile to obtain the corrected latest peak-to-peak value, includes: The target value is obtained by multiplying the interquartile range by a preset constant. If the current ordered array is arranged in ascending order, the first quartile is subtracted from the target value to obtain the low boundary value, and the third quartile is added to the target value to obtain the high boundary value. If the current ordered array is arranged in descending order, the third quartile is subtracted from the target value to obtain the low boundary value, and the first quartile is added to the target value to obtain the high boundary value. If the latest peak value is less than or equal to the low boundary value, or greater than or equal to the high boundary value, then the latest peak value is abnormal. The second quartile is used to replace the latest peak value to obtain the corrected latest peak value.
8. A peak-to-peak value calculation device, characterized in that, The device includes: The first acquisition module is used to acquire a preset extreme value recognition sliding window; The calculation module is used to identify whether the signal at the center sampling point of the current extreme value identification sliding window is an extreme value in the signal sequence. If it is, the extreme value type is determined, and the identified extreme values and their corresponding extreme value types are stored in the extreme value sequence in chronological order. The peak-to-peak value sequence is calculated based on the extreme value sequence. The second acquisition module is used to acquire a preset peak-to-peak value filtering sliding window and a preset array of the same size as the peak-to-peak value filtering sliding window; The determination module is used to sort the peak-to-peak values of the current peak-to-peak filtering sliding window based on the array to obtain a current ordered array, determine the quartiles of the current ordered array, and determine whether the latest peak-to-peak value of the current peak-to-peak filtering sliding window is abnormal based on the quartiles. If so, the latest peak-to-peak value is corrected based on the current ordered array and the quartiles to obtain the corrected latest peak-to-peak value.
9. A storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the peak-to-peak value calculation method as described in any one of claims 1 to 7.
10. A computer device comprising a memory, a processor, and a computer program stored on a storage medium and executable on the processor, characterized in that, When the processor executes the program, it implements the peak-to-peak value calculation method according to any one of claims 1 to 7.