An electric energy sampling data processing method, device, equipment and storage medium
Patent Information
- Application Number
- CN202611434748.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-16
- Publication Date
- 2026-10-20
AI Technical Summary
获取电能采样数据序列;
[0017]综上所述,本申请提供的方法包括以下有益技术效果:获取电能采样数据序列并计算其自相关函数,通过在自相关函数中搜索峰值来确定目标周期,将目标周期精确分解为整数部分和小数部分;将数据序列按照整数部分进行分块处理;对于每个数据块内的每个采样点,利用预测器进行数据预测得到第一预测值,并计算采样点实际值与第一预测值之间的第一预测残差,由于预测器能够利用数据间的周期相关性进行准确预测,因此得到的预测残差数值范围小且分布集中,再对该预测残差进行编码,能够显著降低编码所需的比特数,从而生成高效的残差编码码流;存储块索引、目标周期以及包含编码参数、残差编码码流和预测器信息的数据块信息,使得在后续数据访问时能够根据上述信息快速定位并解码出数据,从而在保证数据压缩率的同时,实现了对电能采样数据的高效存储与快速随机访问。
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This application relates to the field of power safety, and in particular to a method, apparatus, equipment and storage medium for processing power sampling data. Background Technology
[0002] In fields such as power system monitoring, industrial automation control, and smart grids, accurate acquisition and efficient processing of power signals are fundamental to ensuring safe equipment operation and enabling power quality analysis and load forecasting. With the widespread adoption of digital measurement technology, power sampling data is typically generated continuously at high sampling rates, resulting in an exponential increase in data volume. This places high demands on data storage capacity, transmission bandwidth, and the real-time performance of subsequent analysis.
[0003] In related technologies, power quality monitoring devices use an ADC to sample voltage / current channels at equal intervals using a fixed sampling rate (e.g., 12.8kHz, corresponding to 256 points per cycle in a 50Hz system), obtaining a 16-bit or 24-bit integer sample value sequence, which is treated as an integer sequence without internal structure. The recorded waveform data is stored in COMTRADE format (IEEE C37.111). The file stores the original sample value of each sampling point sequentially in ASCII text or binary form. Some devices use zip / zlib general lossless compression at the file level. However, when using the above method to compress the sampled data, the compression ratio is relatively low.
[0004] Therefore, how to improve the compression ratio is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0005] The purpose of this application is to provide a method, apparatus, device, and storage medium for processing electrical energy sampling data, which can improve the compression ratio.
[0006] Firstly, a method for processing electrical energy sampling data is provided, including: Acquire electrical energy sampling data sequences; The autocorrelation function is calculated based on the energy sampling data sequence, and a peak value is searched in the autocorrelation function to determine the target period, wherein the target period is decomposed into an integer part and a fractional part; The electrical energy sampling data sequence is divided into multiple data blocks according to the integer part; For each sampling point of the data block in the power sampling data sequence, a predictor is used to predict the data to obtain a first predicted value, and a first prediction residual between the sampling value of the sampling point and the first predicted value is obtained; the first prediction residual is encoded to obtain a residual encoded bitstream of all the first prediction residuals of the data block; The storage includes a block index, target period, and multiple data block information for the power sampling data sequence. The data block information includes at least encoding parameters, residual encoded bitstream, and predictor information.
[0007] In a preferred embodiment, this application can be further configured as follows: for each sampling point of a data block in the power sampling data sequence, a predictor is used to predict the data to obtain a first predicted value, and a first prediction residual between the sampled value of the sampling point and the first predicted value is obtained, including: For the first data block in the power sampling data sequence, a first-order local predictor is used to obtain the first prediction residual between the sampled value of the sampling point and the first prediction value. For each data block in the power sampling data sequence other than the first data block, a target preset predictor is used to predict each sampling point in the data block to obtain a second predicted value of the sampling point, and a second prediction residual between the sampling value of the sampling point and the second predicted value is obtained. The target preset predictor is any preset predictor among a plurality of preset predictors. The optimal predictor is selected from multiple preset predictors, with the condition of minimizing the sum of the absolute values of the prediction residuals within the data block. The second prediction residual between the sampled value of the sampling point of the optimal predictor and the second predicted value is obtained, and is used as the first prediction residual between the sampled value of the sampling point and the first predicted value.
[0008] In a preferred embodiment, this application can be further configured to: use a target preset predictor to predict each sampling point within the data block, obtain a second predicted value for the sampling point, and acquire a second prediction residual between the sampled value of the sampling point and the second predicted value, including: If the target preset predictor is a periodic predictor, for the nth sampling point, where n is an integer greater than the integer part, the first sampling point and the second sampling point are determined as reference sampling points. The first sampling point is the nth minus the integer part of the sampling points, and the second sampling point is the nth minus the integer part minus 1 sampling point. The first and second weights of the period predictor are determined based on the fractional part. The second predicted value is obtained based on the first weight, the second weight, and the value of the reference sampling point; the second prediction residual between the sampled value of the sampling point and the second predicted value is obtained.
[0009] In a preferred example, this application can be further configured to: search for peaks in the autocorrelation function to determine the target period, including: Within the search range, find the target location corresponding to the maximum value of the autocorrelation function; Parabolic interpolation is performed on the target position to obtain the peak position, and the sampled value corresponding to the peak position is used as the target period.
[0010] In a preferred embodiment, this application can be further configured to: after using the sampled value corresponding to the peak position as the target period, it also includes: Verify periodicity at multiples of the peak position; In response to the successful periodic verification, the sampled value corresponding to the peak position is taken as the final target period.
[0011] In a preferred embodiment, this application can be further configured to: encode the first prediction residual to obtain a residual-coded bitstream of all the first prediction residuals of the data block, including: Perform a signed-to-unsigned folding mapping on the first prediction residual to obtain the mapped value; Perform quotient and remainder decomposition on the mapped value; The quotient is represented by a unary code and the remainder is represented by a fixed-length binary code. The two codes are then concatenated to obtain the codeword of the first prediction residual. Based on the codewords of all first prediction residuals, the residual encoded bitstream of all first prediction residuals of the data block is obtained; The encoding parameters are target encoding parameters, which minimize the total number of bits in the residual encoded bitstream among all candidate encoding parameters.
[0012] In a preferred embodiment, this application can be further configured such that the method also includes: In response to an access request for data corresponding to the decoding cycle, the target data block where the data is located is determined based on the block index; Read the predictor identifier of the first data block, and decode the first data block according to the predictor corresponding to the predictor identifier and the residual coded bitstream corresponding to the first data block. Read the predictor identifier and encoding parameters of the second data block, calculate the prediction value according to the prediction method corresponding to the predictor identifier and the decoded data that has been decoded; decode the prediction residual encoded bitstream to obtain the prediction residual, add the prediction value to the prediction residual to obtain the decoded data of the second data block; repeat the process until the decoded data of the target data block is obtained.
[0013] Secondly, an electrical energy sampling data processing device is provided, comprising: The data acquisition module is used to acquire power sampling data sequences; The period estimation module is used to calculate the autocorrelation function based on the power sampling data sequence, and search for the peak value in the autocorrelation function to determine the target period, wherein the target period is decomposed into an integer part and a fractional part; The prediction module is used to divide the power sampling data sequence into multiple data blocks according to the integer part; For each sampling point of the data block in the power sampling data sequence, a predictor is used to predict the data to obtain a first predicted value, and a first prediction residual between the sampling value of the sampling point and the first predicted value is obtained; the first prediction residual is encoded to obtain a residual encoded bitstream of all the first prediction residuals of the data block; The storage module is used to store the block index, target period, and multiple data block information of the power sampling data sequence. The data block information includes at least encoding parameters, residual encoded bitstream, and predictor information.
[0014] Thirdly, an electrical energy sampling data processing device is provided, the electrical energy sampling data processing device including a memory and a processor, the memory storing a computer program, the processor executing the method described in any one of the first aspects when running the computer program.
[0015] Fourthly, a computer-readable storage medium is provided, wherein at least one piece of program code is stored therein, the program code being loaded and executed by a processor to implement the method as described in any of the first aspects.
[0016] Fifthly, a computer program product is provided, including a computer program or instructions that, when executed by a processor, implement the method as described in any of the first aspects.
[0017] In summary, the method provided in this application has the following beneficial technical effects: acquiring an energy sampling data sequence and calculating its autocorrelation function; determining the target period by searching for peaks in the autocorrelation function; precisely decomposing the target period into integer and fractional parts; dividing the data sequence into blocks according to the integer part; for each sampling point within each data block, using a predictor to predict the data to obtain a first predicted value, and calculating the first prediction residual between the actual value of the sampling point and the first predicted value. Since the predictor can accurately predict using the periodic correlation between data, the obtained prediction residual values have a small range and are concentrated in distribution. Encoding the prediction residual can significantly reduce the number of bits required for encoding, thereby generating an efficient residual coding stream; storing the block index, target period, and data block information containing encoding parameters, residual coding stream, and predictor information, so that the data can be quickly located and decoded based on the above information during subsequent data access, thereby achieving efficient storage and fast random access to energy sampling data while ensuring data compression rate.
[0018] In addition, this application also provides an apparatus, device, and medium, all of which have the aforementioned beneficial technical effects. Attached Figure Description
[0019] To more clearly illustrate the technical solutions of the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a schematic diagram illustrating an application scenario of an energy sampling data processing method provided in an embodiment of this application; Figure 2 This is a flowchart of a power sampling data processing method provided in an embodiment of this application; Figure 3 This is a structural block diagram of an electrical energy sampling data processing device provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of an electrical energy sampling data processing device provided in an embodiment of this application. Detailed Implementation
[0021] This specific embodiment is merely an explanation of this application and is not intended to limit it. After reading this specification, those skilled in the art can make modifications to this embodiment without contributing any inventive step, but such modifications are protected by patent law as long as they are within the scope of this application.
[0022] It should be noted that, in the optional embodiments of this application, the data related to object information, when applied to specific products or technologies, requires the permission or consent of the object. Furthermore, the collection, use, and processing of this data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. In other words, if the embodiments of this application involve data related to an object, it must be obtained with the permission and consent of the object, the permission and consent of relevant departments, and in accordance with the relevant laws, regulations, and standards of the country and region. If the embodiments involve personal information, the acquisition of all personal information requires the consent of the individual. If sensitive information is involved, the separate consent of the information subject is required. The embodiments also need to be implemented with the permission and consent of the object.
[0023] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0024] Furthermore, the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article, unless otherwise specified, generally indicates that the preceding and following related objects have an "or" relationship.
[0025] Related technologies treat sampled value sequences as integer sequences without internal structure, and their storage or compression strategies do not utilize any structural regularity within the signal. The inventors discovered the following drawbacks: Defect 1: It does not utilize the autocorrelation structure of the signal, resulting in fundamental information redundancy and a low compression ratio.
[0026] Voltage / current sampling data is not a random sequence. It is generated by an AC generator, transmitted through transformers and transmission lines, and supplied to various loads. These physical processes determine that the signal has a strong autocorrelation structure: for a time interval τ, the correlation R(τ) between signals s(t) and s(t+τ) reaches its maximum (close to 1.0) when τ equals the fundamental period T (20ms for 50Hz). This is the most common structural characteristic of the signal—it does not depend on the assumption that the waveform is "close to a sine wave." Whether the load is purely resistive (sinusoidal current) or a rectifier (pulse current), the signal repeats strictly with a period of T. The existing COMTRADE scheme treats the data as an unstructured stream, completely failing to utilize this enormous redundancy in an information-theoretical sense.
[0027] Defect 2: Compression schemes based on physical model assumptions do not have universal applicability.
[0028] Common compression approaches assume that signals can be expressed as a fundamental sine wave with a few harmonics. This assumption collapses in scenarios such as industrial rectifier loads (steady-state THD > 30%, containing 30+ effective harmonics), electric arc furnaces (continuous inter-spectral harmonics), and single-phase events (three-phase constraint failure). Any scheme that relies on what the signal should look like will fail when the signal does not look like that. A robust compression scheme should automatically discover its own patterns from the data, rather than imposing external assumptions on the data.
[0029] To enable those skilled in the art to implement this invention, the key terms appearing in this application are explained below.
[0030] PQ (Power Quality) is a general term for the quality of power supply in a power system, including indicators such as voltage / current amplitude, frequency, harmonics, interharmonics, and transients.
[0031] COMTRADE stands for IEEE C37.111 Transient Data Exchange Format, a standard file format that stores waveforms in raw sample values. The file stores the raw sample value of each sample point one by one in ASCII text or binary form.
[0032] An ADC (Analog-to-Digital Converter) is a device that converts a continuous analog voltage / current signal into discrete integer sampled values at a fixed sampling rate, such as a 12.8kHz sampling rate, 16-bit or 24-bit quantization.
[0033] THD (Total Harmonic Distortion) represents the proportion of harmonic energy to fundamental energy and is used to measure the degree of waveform distortion.
[0034] FFT (Fast Fourier Transform) represents an efficient algorithm for transforming time-domain signals to the frequency domain; IFFT (Inverse Fast Fourier Transform) is its inverse transform.
[0035] The Wiener-Khinchin theorem states that the autocorrelation function of a stationary signal and its power spectral density are Fourier transform pairs, which can be used to accelerate the calculation of autocorrelation by IFFT(|FFT(s)|²).
[0036] CMSIS-DSP stands for Digital Signal Processing Library provided by ARM, where arm_rfft_fast_f32 is a real-valued FFT function.
[0037] LSB (Least Significant Bit) represents the smallest quantization unit of an integer sample value and is used as a measure of the residual magnitude. Golomb-Rice coding is a parameterized prefix-independent entropy coding for non-negative integers, particularly suitable for residual sequences whose distribution is concentrated near zero.
[0038] The autocorrelation function represents the similarity function between a signal and itself at different time intervals τ, and it reaches a maximum at τ equal to the fundamental period T.
[0039] The target period T represents the fundamental period of the signal (in terms of sampled values) discovered by the autocorrelation structure of the data. The integer part of the target period T represents the sampled value (minimum jump distance) corresponding to a complete fundamental frequency cycle; f represents the fractional part of the target period T, satisfying 0≤f<1, which is the fractional residual.
[0040] Data blocks represent the sampling sequence according to Each sampling point is a sub-sequence unit obtained by dividing the block.
[0041] A predictor is a function that calculates the predicted value of the current sampling point based on encoded / decoded historical data. This application includes four types: periodic predictor, first-order local predictor, second-order local difference predictor, and periodic and local hybrid predictor.
[0042] The prediction residual represents the difference between the actual value and the predicted value of a sample point.
[0043] Folding mapping represents a transformation that maps signed integers to unsigned integers, such that positive and negative residuals near zero are mapped to adjacent smaller non-negative integers. Block index represents a structure that records the offset of each block of the bitstream byte for random access. PredMode represents the predictor identifier (3 bits: 0=P0, 1=P1, 2=P2, 3=P3); GolombK represents the Golomb-Rice coding parameter k (3 bits, k∈[0,7]).
[0044] In one embodiment, please refer to Figure 1 , Figure 1This diagram illustrates an application scenario for a power sampling data compression method based on blind cycle estimation and adaptive differential prediction, as provided in this application. The scenario includes a power quality monitoring device (including an ADC sampling front-end), a local or cloud-based power sampling data processing device, and a storage unit for storing the compressed data. The power quality monitoring device samples the voltage / current channels at equal intervals using a fixed sampling rate to obtain a power sampling data sequence. The power sampling data processing device executes the compression method of this application to compress and store the sequence, and performs random access decoding when playback or analysis of specific cycles is required.
[0045] This application provides a method for processing electrical energy sampling data, such as... Figure 2 As shown, the method includes the following steps.
[0046] S110, Obtain the electrical energy sampling data sequence.
[0047] The power sampling data sequence refers to the set of discrete integer sampled values arranged in chronological order, obtained by the ADC of the power quality monitoring device sampling the voltage / current channels at equal intervals with a fixed sampling rate. For example, a sequence of the form {s[0], s[1], s[2], ..., s[n]} obtained with a sampling rate of 12.8kHz and 16-bit quantization. Generally, s[n] is an integer with no remainder. The sampling rate represents the number of samples collected per second. For example, 12.8kHz corresponds to 256 points per cycle in a 50Hz system. The sampling point represents a single discrete value s[n] with index n in the sequence, where n is the position number of the sampling point. The voltage / current channel represents the measured electrical quantity being sampled.
[0048] S120. Calculate the autocorrelation function based on the power sampling data sequence, and search for the peak value in the autocorrelation function to determine the target period, wherein the target period is decomposed into an integer part and a fractional part.
[0049] Here, the autocorrelation function represents the similarity function R[k] between the power sampling data sequence s and itself at different time intervals k (in units of sampling values), and is used to present a maximum value at k equal to the target period. It can be understood that when the grid frequency is 50Hz, it can cover frequency offsets as low as 45Hz. Therefore, although the fundamental frequency is 50Hz, it may offset between 45-65Hz. This step enables the estimation of the blind period, determining the actual period as the target period.
[0050] In this embodiment, the fast calculation of the autocorrelation function can be based on the Wiener-Khinchin theorem, i.e., autocorrelation = IFFT(|FFT(s)|²), using the real number FFT (arm_rfft_fast_f32) of the CMSIS-DSP library. The 1024-point FFT takes about 0.1ms on the ARM Cortex-M7.
[0051] The search peak represents the location on the R[k] curve where the correlation value is maximized. The target period T represents the period determined by the location of the autocorrelation peak, expressed in sample values; the integer part... This represents the complete cycle sample value obtained by rounding T down, for example, when T=4.5. =4; the fractional part f represents T and... The difference, f is between 0 and 1, f = 0.5; when T = 5 =5; the decimal part f represents T and... The difference is f=0.
[0052] Specifically, first, take the first few sampling points of the signal as the input segment and calculate the normalized autocorrelation function R[k]. The number of sampling values can be customized by the user, but it is recommended to use about 4 cycles, which is sufficient within the range Kmax = fs / 45. Then, within a reasonable search range (such as k∈[fs / 65,fs / 45], which can cover frequency shifts down to 45Hz), find the position k of the maximum value of R[k]. Perform parabolic interpolation on this position to obtain a more accurate peak position. and will The corresponding sampled value is taken as the target period T; finally, T is decomposed into integer parts. = T With the decimal part f=T- and will ( f) Store the compressed file header for use by the encoder and decoder. Using CMSIS-DSP's arm_rfft_fast_f32, a 1024-point FFT on an ARM Cortex-M7 takes only about 0.1ms, allowing this step to run in real time on the embedded front end.
[0053] In one feasible approach, the autocorrelation function is calculated quickly by taking sampling points and calculating the normalized autocorrelation function: .
[0054] s[n] represents the original voltage / current value of the nth sampling point. The meaning is the average value of the signal segment calculated in this calculation. k represents the sample value of the signal shifted backward. R[k] represents the similarity between the original signal and the shifted signal when delayed by k sampling points. Theoretically, it is in the range of -1 to 1, where 0 means no relationship, -1 means the waveforms are opposite, and +1 means a perfect positive correlation. Start the peak search of the fundamental period and search for the peak on the R[k] curve (k>0). Peak search strategy: (1) Search range k∈[fs / 65,fs / 45]; (2) Find the position of the maximum value k of R[k] and obtain the accurate peak position by parabolic interpolation. .
[0055] The purpose of this step is to automatically extract the true periodic structure of the signal from the data, serving as the basis for subsequent differential prediction compression. By adopting the above technical solution, the embodiments of this application do not preset 50Hz / 60Hz, do not rely on zero-crossing detection, and do not assume waveform shape. Instead, they discover the period solely through autocorrelation structure driven by zero prior knowledge. This makes the compression efficiency depend only on the actual predictability of the signal (conditional entropy), rather than the degree of conformity between the signal and a certain ideal model, thereby achieving blind period estimation that is universally effective for all signals with a period of T.
[0056] S130. Divide the power sampling data sequence into multiple data blocks according to the integer part.
[0057] Wherein, the integer part represents the integer part of the target period T. Block processing indicates that... Each sampling point has a fixed block size, and the power sampling data sequence is sequentially divided into several continuous sub-sequence units starting from the beginning. A data block represents a single sub-sequence obtained after the block division, denoted as the i-th block. Its length is The block number i represents the order of the data block in the sequence (i=0,1,2,…), and is used for block indexing and random access.
[0058] In some embodiments, firstly Initialize the block counter i=0 for the block size; then each time start from the sequence offset i... Take out Composed of sampling points Finally, increment i until the end of the sequence.
[0059] S140. For each sampling point of the data block in the power sampling data sequence, a predictor is used to predict the data to obtain a first predicted value, and the first prediction residual between the sampling value of the sampling point and the first predicted value is obtained; the first prediction residual is encoded to obtain the residual encoded bitstream of all the first prediction residuals of the data block.
[0060] Here, the predictor represents a function that calculates the predicted value of the current sampling point based on historical sampling points, and includes four types: periodic predictor, first-order local predictor, second-order local difference predictor, and hybrid periodic and local predictor. The first predicted value represents the estimate given by the predictor for the current sampling point s[n]. The first prediction residual (denoted as e[n]) represents the difference between the actual value of the sampled point and its first predicted value, i.e., e[n] = s[n] - Its dynamic range is much smaller than that of the original signal. Encoding represents the process of converting the first prediction residual sequence into a bitstream; this application can employ Golomb-Rice encoding. The residual-encoded bitstream represents a bitstream formed by sequentially concatenating the codewords of all first prediction residuals within a data block. The encoding parameter represents the adaptive parameter k (GolombK) of the Golomb-Rice encoding, which determines the bit division of the quotient / remainder decomposition.
[0061] This step is performed after data segmentation and before storage. The data processing device first calculates a first predicted value for each sample point within each data block using a selected predictor based on historical data. Then calculate the first prediction residual e[n] = s[n] - Finally, Golomb-Rice encoding is performed on e[n] and the results are concatenated to form the residual encoded bitstream of this block. Specifically, for the i-th block, the prediction is first calculated point by point according to the selected predictor for that block. (forward The points are specially processed using a first-order local predictor (see subsequent embodiments for details), resulting in a residual sequence {e[n]}. Then, a signed-to-unsigned folding mapping, quotient-remainder decomposition, and Golomb-Rice encoding by concatenating the quotient of a unary code and the fixed-length binary remainder are performed on this sequence. Candidates k∈[0,7] are traversed to select the k that minimizes the total number of encoded bits as the current block GolombK. The codewords are then concatenated in decoding order to form the residual encoded bitstream BlockData. This step converts highly redundant sampled values into low-entropy residuals concentrated near zero, which are further compressed using entropy encoding.
[0062] The purpose of this step is to convert the sampled sequence into a low-entropy residual and compact it with high-entropy encoding to achieve lossless compression. By adopting the above technical solution, the embodiments of this application compress the prediction residual of the original signal amplitude to an extremely small range, and then achieve a high compression ratio through Golomb-Rice encoding, with lossless and accurate reconstruction throughout the process.
[0063] S150, storing the block index, target period, and multiple data block information of the power sampling data sequence. The data block information includes at least the encoding parameters, residual encoded bitstream, and predictor information.
[0064] The block index represents a structure that records the byte offset (and length) of each data block in the file, used for direct jumps during random access. The target period represents the period saved with the file header. (f) Multiple data block information represents a compressed data set organized in blocks. Each data block information includes at least: encoding parameters (GolombK, 3 bits), predictor information (PredMode, 3 bits: 0=P0, 1=P1, 2=P2, 3=P3), and residual encoded bitstream (BlockData). The file header indicates the beginning of the compressed file and stores global metadata (such as the total size of BlockIndex, etc.). The data area is 2 bytes (f is 2 bytes).
[0065] This step is performed after all data blocks have been encoded. The data processing device then writes the compression result to disk or uploads it according to the predetermined storage structure. Specifically, the device first writes the file header: BlockIndex (offset table for each block). (2 bytes, 0 indicates period not found), f (2 bytes); then write each data block sequentially: PredMode (3 bits) + GolombK (3 bits) + BlockData (this block) (A residual Golomb-Rice bitstream); after all data blocks are written, a complete compressed file is formed. This storage structure allows the decoder to locate any block using only the file header and block index, supporting random access.
[0066] The compressed data and necessary metadata are persisted to form a complete file that can be decoded and randomly accessed. By adopting the above technical solution, the embodiments of this application save the target period, block index, and prediction / coding metadata of each block together. While ensuring lossless reconstruction, subsequent random access decoding only needs to jump to the target block, without needing to decode the full text sequentially.
[0067] As can be seen, the process involves acquiring the power sampling data sequence and calculating its autocorrelation function. The target period is determined by searching for peaks within the autocorrelation function, and the target period is precisely decomposed into integer and fractional parts. The data sequence is then divided into blocks based on the integer parts. For each sampling point within each data block, a predictor is used to predict the data and obtain a first predicted value. The first prediction residual between the actual value of the sampling point and the first predicted value is calculated. Since the predictor can accurately predict using the periodic correlation between data, the resulting prediction residual values have a small range and a concentrated distribution. Encoding this prediction residual significantly reduces the number of bits required for encoding, thereby generating an efficient residual code stream. The storage blocks contain the block index, the target period, and data block information including encoding parameters, the residual code stream, and predictor information. This allows for rapid data location and decoding during subsequent data access, achieving efficient storage and fast random access to power sampling data while maintaining data compression.
[0068] In one possible implementation of this application embodiment, S120, searching for a peak in the autocorrelation function to determine the target period, includes: S120a. Find the target position corresponding to the maximum value of the autocorrelation function within the search range.
[0069] The search range represents the preset peak candidate interval, which can be set according to the actual grid frequency, from -5 to +15, typically k∈[fs / 65,fs / 45], covering the sampling point span of the fundamental period at a grid frequency offset of 45~65Hz. The maximum value represents the maximum value of the autocorrelation function R[k] within the search range. The target position represents the integer sampling point index k (rough peak position) that makes R[k] reach its maximum value.
[0070] This step is performed after the normalized autocorrelation function R[k] is calculated. Specifically, the device compares R[k] point by point within the interval k∈[fs / 65,fs / 45], and records the integer index k of the maximum value as the target position; this position corresponds to the integer approximation of the strongest periodicity of the signal.
[0071] S120b: Perform parabolic interpolation on the target position to obtain the peak position, and use the sampled value corresponding to the peak position as the target period.
[0072] After finding the position k of the maximum value of R[k], parabolic interpolation is used to obtain the position of the precision peak. ; .
[0073] As can be seen, in this embodiment, the target position corresponding to the maximum value is found within the search range of the autocorrelation function. This target position represents a rough estimate of the signal periodicity. Parabolic interpolation is performed on the target position, and a parabola is fitted using the function values of the target position and its adjacent positions. The vertex position of the parabola is used as an accurate estimate of the peak position. Since parabolic interpolation can effectively compensate for the error caused by discrete sampling, the sampled value corresponding to the peak position obtained by interpolation can be used as the target period, which can obtain a more accurate period estimate than directly searching for the maximum value.
[0074] In one possible implementation of this application embodiment, in order to improve the accuracy of cycle estimation, the following sub-steps are included after step 120b in this application embodiment.
[0075] S120c, verify periodicity at multiples of the peak position.
[0076] The multiple position indicates the peak position. At integer multiples of 2, i.e. 3· Etc.; Verify the periodic representation by checking whether these multiple positions also exhibit local peaks (i.e., the correlation is significantly greater than the neighborhood), as... This is indeed evidence of a true fundamental frequency period. The target location and peak location are the same as before, and will not be repeated here to avoid repetition.
[0077] S120d, in response to the periodic verification passing, uses the sampled value corresponding to the peak position as the final target period.
[0078] Among them, periodic verification is represented by 2. 3 At least two of the positions at equal multiples pass the local peak verification; the final target period represents T= written to the file header after verification. and its decomposition ( ,f).
[0079] If the search fails, you can expand the search scope and try again, or mark the period as not found.
[0080] As can be seen, in this embodiment, after obtaining the sampled value corresponding to the peak position as the target period through interpolation, the periodicity is further verified at multiples of the peak position, i.e., checking whether the autocorrelation function also exhibits significant peaks at these multiples. Since real periodic signals not only have strong correlations at integer multiples of the period, but this correlation also recurs stably, verifying the periodicity at multiples can effectively eliminate false peaks caused by noise or random factors. Only after the periodicity verification is passed is the sampled value corresponding to the peak position taken as the final target period. This verification mechanism ensures the stability and reliability of the determined period.
[0081] In one possible implementation of this application embodiment, S140 performs data prediction using a predictor for each sampling point of a data block in the power sampling data sequence to obtain a first predicted value, and acquires a first prediction residual between the sampled value of the sampling point and the first predicted value, including: S140a-S140d, wherein: S140a. For the first data block in the power sampling data sequence, a first-order local predictor is used to obtain the first prediction residual between the sampled value of the sampling point and the first prediction value. For the first part of the power sampling data sequence For each sampling point, a first-order local predictor is used for prediction, and the previous... For each sampling point except the first sampling point, subtract the value of the previous sampling point from the value of the sampling point. For n≥1, calculate e[n]=s[n]-s[n-1], e[0]=s[0] point by point, and use the difference as the encoded data. That is, for the first data block (s[0], s[1]…s[… ... The first segment, employing a first-order local predictor, predicts the first prediction residual. This step is performed at the very beginning of the entire sequence encoding. The first segment occupies only a very small proportion of the entire waveform, and its encoding efficiency has a negligible impact on the overall compression ratio, but it ensures the integrity and reconstructability of the sequence start point. This embodiment completes the sequence start point encoding without relying on a periodic reference, ensuring lossless encoding throughout and a negligible impact on the compression ratio.
[0082] S140b. For a data block in the power sampling data sequence, a target preset predictor is used to predict each sampling point in the data block to obtain a second predicted value of the sampling point, and a second prediction residual between the sampling value of the sampling point and the second predicted value is obtained. The target preset predictor is any preset predictor among multiple preset predictors.
[0083] Multiple predictors include at least two of the following: a periodic predictor, a first-order local predictor, a second-order local difference predictor, and a mixed periodic and local predictor.
[0084] Here, the target preset predictor represents one of the predictors actually selected for the current data block (chosen from multiple candidates). The second predicted value represents the estimated value calculated by the target preset predictor for the sampling point s[n] (paired with the second prediction residual). The second prediction residual represents the difference between s[n] and the second predicted value. Referring to Table 1, the periodic predictor (P0) represents a predictor that predicts the current point based on constant-weighted linear interpolation and the corresponding point of the previous period, applicable to steady state (any waveform). The first-order local predictor (P1) represents a predictor that predicts the current point using the value of the previous sampling point, applicable to the first value after a transient change. The second-order local difference predictor (P2) represents a predictor that predicts the current point using linear extrapolation of the previous two points (e.g., ...). =2·s[n-1]-s[n-2]), applicable to smooth segments in transient states. The periodic and local hybrid predictor (P3) represents the superposition of local trend correction on the basis of periodic prediction, applicable to scenarios where the periodic structure still exists but local trends are superimposed.
[0085] Table 1
[0086] Specifically, for the i-th block, the second predicted value is calculated point by point using each predictor from P0 to P3 according to its own formula, and the second predicted residual is obtained, resulting in four sets of candidate residual sequences for subsequent selection and comparison. For example, constant weight linear interpolation is used for P0, and constant weight linear interpolation is used for P1. =s[n-1], taking P2 =2·s[n-1]-s[n-2].
[0087] It is understandable that for the first block (i=1, which is now the second data block), s[ ]、s[ +1]…s[2 -1]) For example, if P0 / P3 is used, since for the previous +1 sampling points, since there is no complete n- -1 is the reference data. Therefore, the first prediction residual of the second data block uses P1, and the rest are calculated using P0 / P3. S140c: Select the optimal predictor from multiple preset predictors, with the condition of minimizing the sum of the absolute values of the prediction residuals within the data block.
[0088] Here, the sum of the absolute values of the prediction residuals represents the accumulation of the absolute values of the residuals of all sampling points within the block, denoted as Σ|e[n]|, which serves as an objective measure of prediction quality. The minimization condition indicates that the predictor that minimizes Σ|e[n]| is selected as the optimal one.
[0089] Selection criterion: Minimize the sum of the absolute values of the residuals within the block. .
[0090] Taking a 12.8kHz, 49.5Hz (non-integer period), 16-bit full-scale (32768) actual measurement, multiple preset predictors including: period predictor, first-order local predictor, and second-order local difference predictor, as an example, the sample-by-sample residual values of the 18-cycle dip (1.0→0.7 pu, starting at cycle 5 and recovering at cycle 11) are shown in Table 2: Table 2
[0091] The prediction algorithm changes throughout the process as follows: P0, P2, P0, P2, P0. After entering the sag state (voltage stabilizes at 0.7 pu), although the voltage amplitude differs from before the event, the cycles within the new steady state are still highly repetitive. P0 is the [number]th cycle after the sag initiation cycle. The validity is automatically restored starting from each sampling point. It points to the phase position corresponding to the new steady state. P0 fails only within one cycle of the change.
[0092] In the embodiments of this application, during local periods when transient events occur and periodic prediction temporarily fails, the system automatically and seamlessly switches to an alternative prediction strategy, so that the encoding overhead of transient data is strictly limited to the time domain range of the transient event.
[0093] S140d: Obtain the second prediction residual between the sampled value of the optimal predictor's sampling point and the second prediction value, and use it as the first prediction residual between the sampled value of the sampling point and the first prediction value.
[0094] The device uses the optimal predictor as the final predictor and can reuse the calculated results of S140a to determine the first predicted value and the first predicted residual of each point in the block, and obtain the final residual sequence {e[n]} of this block, which is then sent to the encoding stage.
[0095] As can be seen, in this embodiment, for the first data block in the power sampling data sequence, a first-order local predictor is used to determine the first predicted value of the first sampling point as 0, and the first predicted value of other sampling points is determined to be the value of the previous sampling point. The first prediction residual between the actual value and the first predicted value is obtained. Since the first data block lacks historical reference data, the first-order local prediction based on the nearest value can quickly establish the initial prediction. For data blocks other than the first data block, any predictor among multiple preset predictors is used to predict and obtain the second predicted value and the second prediction residual. Then, with the condition of minimizing the sum of the absolute values of the prediction residuals within the data block, the optimal predictor is selected from multiple preset predictors for each data block. This ensures that each data block can adopt the prediction method most suitable for its local signal characteristics, thereby making the prediction residual as small as possible. Finally, the first prediction residual under the optimal predictor is obtained for encoding, which can significantly improve the encoding efficiency and realize adaptive compression of power data blocks with different characteristics.
[0096] In one possible implementation of this application embodiment, step S140a uses a target preset predictor to predict each sampling point within the data block, obtains a second predicted value for the sampling point, and acquires a second prediction residual between the sampling value and the second predicted value. Specifically, when the target preset predictor is a periodic predictor, the step includes: If the target preset predictor is a periodic predictor, for the nth sampling point, where n is an integer greater than the integer part, the first sampling point and the second sampling point are determined as reference sampling points. The first sampling point is the nth minus the integer part of the sampling points, and the second sampling point is the nth minus the integer part minus 1 sampling point. The first and second weights of the periodic predictor are determined based on the fractional part. Based on the first weight, the second weight, and the value of the reference sampling point, the second predicted value is obtained; the second prediction residual between the sampled value of the sampling point and the second predicted value is obtained.
[0097] Wherein, the nth sampling point represents the current sampling point s[n] to be predicted; greater than Integer representation of n> Ensure that there is reference data from a complete period prior; n- Each sampling point represents a reference point s[n-] exactly one fundamental cycle (integer part) away from the current point. ]; the nth -1 sampling point represents its previous reference point s[n- -1]. Both are located on either side of the ideal reference point nT and are used for linear interpolation.
[0098] Wherein, the first weight represents the weight applied to the proximal reference point s[n- The constant weight of ] is equal to 1-f. The second weight represents the weight applied to the distant reference point s[n- The constant weights [-1] are equal to f. Constant weights mean that these two weights apply to all n ≥ [-1]. All are the same and do not change with n. Based on The second predicted value was obtained.
[0099] As can be seen, in the embodiments of this application, when the target preset predictor is a periodic predictor, the n-th... The nth sampling point and the nth sampling point -1 sampling points are determined as reference sampling points. These two reference points contain signal information near the integer multiple delay of the period. The first and second weights of the period predictor are determined based on the fractional part. Since the fractional part f reflects the slight deviation of the period from the integer sampling points, the weight allocation reflects the different contributions of the two reference points to the current predicted value. The second predicted value is obtained by weighting the first weight, the second weight, and the value of the reference sampling points. This can accurately compensate for the phase shift caused by non-integer periods, making the predicted value closer to the actual value, thereby obtaining a smaller second prediction residual and improving the prediction accuracy of power data containing non-integer period components.
[0100] In one possible implementation of this application embodiment, encoding the first prediction residual to obtain a residual-coded bitstream of all first prediction residuals of a data block includes: S140e: Perform a signed-to-unsigned folding mapping on the first prediction residual to obtain the mapped value.
[0101] Here, the signed-to-unsigned folding mapping represents the transformation that maps the residual e over the integer field to the non-negative integer field. The mapping value represents the folded non-negative integer x, which serves as the input for subsequent quotient-remainder decomposition.
[0102] S140f: Perform quotient and remainder decomposition on the mapped value.
[0103] The quotient and remainder decomposition represent division of the mapped value x by the encoding parameter k: The encoding parameter K represents the divisor order of the Golomb-Rice, K∈[0,7].
[0104] S140g, the quotient is represented by a unary code and the remainder is represented by a fixed-length binary code, and the codeword of the first prediction residual is obtained by concatenating them.
[0105] Among them, unary encoding means that the quotient q is encoded as q ones followed by a 0 as a terminator (e.g., q=2, corresponding to 110); fixed-length binary encoding means that the remainder r is represented by a fixed K bits (e.g., K=1, r=0, corresponding to 0).
[0106] Specifically, for each residual output codeword: first write q ones and 1 zero, then write k bits of remainder; for example, when e=+2 corresponds to x=4, q=2, r=0, and K=1, the codeword is 1100. The codeword has a prefix property (0 is the terminator), which facilitates bit-by-bit delimitation at the decoding end.
[0107] S140h: Based on the codewords of all first prediction residuals, obtain the residual coded bitstream of all first prediction residuals of the data block; wherein, the encoding parameter is the target encoding parameter, which makes the total number of coded bits of the residual coded bitstream the minimum among all candidate encoding parameters.
[0108] Among them, the residual encoded bitstream represents the bitstream BlockData, which is the result of concatenating all codewords in the block in the decoding order; the target encoding parameter (GolombK) represents the K value that minimizes the total number of encoded bits in the block after traversing K∈[0,7], and is written into the block header (3 bits).
[0109] This step is performed after the codewords are obtained point by point and at the end of the block. Specifically, the device first obtains each codeword using a default k encoding, then iterates through k=0…7 to calculate the total number of bits in the block, takes the smallest as the target encoding parameter GolombK, and re-encodes or reuses the previous encoding result; for example, in the example, the total number of bits of 29 bits is optimal when K=1 for 10 residuals (original 160 bits, compression ratio of about 5.5:1).
[0110] As can be seen, in this embodiment, after obtaining the first prediction residual, a signed-to-unsigned folding mapping is first performed on the first prediction residual to uniformly map the alternating positive and negative residual values to non-negative mapping values, so that subsequent encoding can be uniformly processed without additional sign bits; the mapping values are decomposed into quotient and remainder, where the selection of encoding parameters directly affects the distribution of quotient and remainder; then the quotient is represented by unary encoding and the remainder is represented by fixed-length binary encoding and concatenated to obtain the codeword of each prediction residual; since among all candidate encoding parameters, the target encoding parameter can minimize the total number of bits of the codeword of all prediction residuals in the entire data block, by selecting the target encoding parameter for encoding, the length of the residual bitstream of the data block can be optimized within the given encoding framework, minimizing storage space occupation and thus greatly improving the data compression rate.
[0111] In one possible implementation of this application embodiment, the method further includes random access decoding, specifically comprising the following sub-steps: S160. In response to the access request for the data corresponding to the decoding cycle, determine the target data block where the data is located based on the block index.
[0112] Here, the access request represents an instruction from an upper-layer application to read sampled data for a specific cycle / time period. The data corresponding to the cycle to be decoded represents the sampling interval located within a specific data block pointed to by the request. The block index represents a table recording the byte offset of each block. The target data block represents the block located by the request that contains the required data. .
[0113] S170. Read the predictor identifier of the first data block, and decode the first data block according to the predictor corresponding to the predictor identifier and the residual encoded bitstream corresponding to the first data block.
[0114] The first data block represents the starting block (sequence number 0) of the sequence to be decoded; the predictor identifier (PredMode) indicates the predictor number in the 3 bits of the block header; the decoded data represents the sequence of sampled values reconstructed from the residual bitstream. The predictor of the first data block is a first-order local predictor.
[0115] Read The PredMode and BlockData are first recovered by the inverse first-order difference process of the first segment, s[0… Then, for each point within the block, calculate the predicted value according to the prediction formula corresponding to PredMode (using the reconstructed history), add the Golomb-Rice decoding residuals, and sum them up: s[n] = +e[n], to get the decoded data of the first data block.
[0116] S180. Read the predictor identifier and encoding parameters of the second data block. Calculate the prediction value based on the prediction method corresponding to the predictor identifier and the decoded data that has been decoded. Decode the prediction residual encoded bitstream to obtain the prediction residual. Add the prediction value to the prediction residual to obtain the decoded data of the second data block. Repeat this process until the decoded data of the target data block is obtained.
[0117] Here, the second data block and subsequent blocks represent data blocks numbered 1, 2, ...; the encoding parameter (GolombK) represents the k value in the header of the subsequent blocks; the decoded data represents the sampled values reconstructed from the previous block, serving as a historical reference for the prediction of the current block; repeated execution means incrementing the block number until the target data block t is reached.
[0118] Specifically, for the i-th block (i≥1): Read PredMode i With GolombK i For each point within a block, the corresponding predictor is used to calculate (combining previously decoded history, such as constant-weight linear interpolation for P0). Golomb-Rice decoding residual e[n]; s[n] = +e[n]; Stop and output the required sample value when i reaches the target data block t. Enables random access to compressed data, eliminating the need to decode all data sequentially from the beginning to obtain the sample value of a specific cycle.
[0119] As can be seen, in this embodiment, when an access request for the data corresponding to the decoding period is received, the target data block where the target data is located is first quickly determined according to the block index, thus achieving efficient location of the stored data; the predictor identifier of the first data block is read. Since the first data block uses a first-order local predictor and its prediction does not depend on other data blocks, the decoded data of the first data block can be obtained independently by directly decoding the predictor corresponding to the predictor identifier and the residual coded bitstream, providing an initial reference for the decoding of subsequent data blocks; then the predictor identifier and encoding parameters of the second data block are read. Since the prediction of the second and subsequent data blocks depends on the decoded preceding data, the predicted value is calculated using the decoded data, and the prediction residual coded bitstream is decoded to obtain the prediction residual. The predicted value and the prediction residual are added to obtain the decoded data of the current block; this process is repeated until the target data block is decoded. The block index is used to quickly locate the data, and the dependency relationship of the preceding blocks is combined for efficient decoding to truly achieve random access.
[0120] In this embodiment, an example is provided to illustrate the process from the original sampled values to the compressed bitstream and then the recovery.
[0121] Parameters: Fundamental period T = 4.5 (sampled value) =4, f=0.5, interpolation weights w0=1-f=0.5, w1=f=0.5, block size=4 (4 sampling points per block), Golomb-Rice parameter K=1. The original 16-bit integer sampling sequence contains 15 values (obtained by ADC quantization): s=[100,180,240,180,100,140,212,209,143,120,174,211,178,131,147].
[0122] Step A (first segment encoding, first-order local predictor): [Previous] =5 points (index 0–4) are used with first-order difference. s[0]=100 is saved directly; e[1]=180-100=+80; e[2]=240-180=+60; e[3]=180-240=-60; e[4]=100-180=-80.
[0123] Step B (Periodic Predictive Coding, P0, f=0.5): For each point n=5…14, use… Calculate using 0.5·s[n-5] + 0.5·s[n-4]. For example, with n=5: [5]=0.5·s[0]+0.5·s[1]=0.5·100+0.5·180=140, e[5]=s[5]- [5]=140-140=0. All calculations: e[6]=212-210=+2; e[7]=209-210=-1; e[8]=143-140=+3; e[9]=120-120=0; e
[10] =174-176=-2; e
[11] =211-210=+1; e
[12] =178-176=+2; e
[13] =131-132=-1; e
[14] =147-147=0. The residual sequence is {0,+2,-1,+3,0,-2,+1,+2,-1,0}.
[0124] The original signal amplitude is 100–240, while the residual amplitude is only -2 to +3, resulting in a dynamic range reduction of about 100 times, which is the fundamental source of compression.
[0125] Step C (Golomb-Ricek parameter selection): The encoder iterates through K=0…7 to calculate the total number of bits for the 10 residuals in this block, and selects the K with the smallest total number of bits. Referring to Table 3, the exhaustive result shows that the optimal total of 29 bits is when K=1 (31 bits for K=0; 33 bits for K=2; and greater than 40 bits when K is between 3 and 7). Therefore, GolombK=1 (3 bits: 001) is written to the block header.
[0126] Table 3
[0127] Step D (Golomb-Rice encoding, ( ): (1) Signed → Unsigned Folding Map: (2) Decomposition of quotient and remainder: (3) Codeword concatenation: codeword=111…10||b k-1 …b0; Codeword length = bits, where For the unary part ( (a series of 1s plus a separator 0) For the fixed-length binary remainder, see Table 4.
[0128] Table 4
[0129] Final bitstream (concatenated from all codewords): The 10 residuals total 29 bits. The original data is 16 bits × 10 = 160 bits. The compression ratio of this block is approximately 160 / 29:1.
[0130] Decoding process: The decoder obtains from the compression header. , , and the first reference paragraph (Recovered through a first-order inverse difference process).
[0131] The decoder reads the bitstream bit by bit, utilizing the prefix property of the Golomb-Rice code (0 is the terminator, and the rest is fixed). (The remainder is used to determine the boundary of each codeword:) ; Demo of code-by-code decoding of the bitstream: Bitstream: 00110001111000010110011000100; When '0' is read, q=0; when K=1 bit is read, r=0, x=0, e=0; Remaining: 110001111000010110011000100; Reading '1', '1', '0', q=2; reading K=1 bit, r=0, x=4, e=+2; Remaining: 01111000010110011000100; Upon reading '0', q=0, r=1, x=1, e=-1; Remaining: 111000010110011000100; ...(and so on).
[0132] Sample-by-sample reconstruction: For each The decoder uses the exact same prediction formula as the encoder to calculate... (Note: The decoder uses the reconstructed version.) and Then add the decoded residual: ; See Table 5.
[0133] Table 5
[0134] Verification: Sampling points one by one The reconstruction error of all 15 sampling points is zero.
[0135] The following describes an apparatus provided by an embodiment of this application. The apparatus described below can be referred to in correspondence with the method described above. The apparatus of this embodiment is installed in an electrical energy sampling data processing device. Figure 3 , Figure 3 This is a structural block diagram of an apparatus according to one embodiment of this application, comprising: Data acquisition module 10 is used to acquire power sampling data sequences; The period estimation module 20 is used to calculate the autocorrelation function based on the power sampling data sequence and search for the peak value in the autocorrelation function to determine the target period, wherein the target period is decomposed into an integer part and a fractional part; The prediction module 30 is used to divide the power sampling data sequence into multiple data blocks according to the integer part; for each sampling point of the data block in the power sampling data sequence, the predictor is used to predict the data to obtain a first predicted value, and the first prediction residual between the sampling value of the sampling point and the first predicted value is obtained; the first prediction residual is encoded to obtain the residual encoded bitstream of all the first prediction residuals of the data block. The storage module 40 is used to store the block index, target period, and multiple data block information of the power sampling data sequence. The data block information includes at least the encoding parameters, residual encoded bitstream, and predictor information.
[0136] In one possible implementation, the period estimation module 20 is used for: Find the target location corresponding to the maximum value of the autocorrelation function within the search range; Parabolic interpolation is performed on the target position to obtain the peak position, and the sampled value corresponding to the peak position is used as the target period.
[0137] In one possible implementation, the period estimation module 20 is also used for: Verify periodicity at multiples of the peak position; In response to the successful periodic verification, the sampled value corresponding to the peak position is taken as the final target period.
[0138] In one possible implementation, the prediction module 30 is used for: For the first data block in the power sampling data sequence, a first-order local predictor is used to obtain the first prediction residual between the sampled value of the sampling point and the first predicted value. For each data block in the power sampling data sequence other than the first data block, the target preset predictor is used to predict each sampling point in the data block to obtain the second predicted value of the sampling point, and the second prediction residual between the sampling value of the sampling point and the second predicted value is obtained. The target preset predictor is any preset predictor among multiple preset predictors. The optimal predictor is selected from multiple preset predictors, with the condition of minimizing the sum of the absolute values of the prediction residuals within the data block. The second prediction residual between the sampled value of the optimal predictor's sampling point and the second predicted value is obtained, and this residual is used as the first prediction residual between the sampled value of the sampling point and the first predicted value.
[0139] In one possible implementation, the prediction module 30 is used for: If the target preset predictor is a periodic predictor, for the nth sampling point, where n is an integer greater than the integer part, the first sampling point and the second sampling point are determined as reference sampling points. The first sampling point is the nth minus the integer part of the sampling points, and the second sampling point is the nth minus the integer part minus 1 sampling point. The first and second weights of the periodic predictor are determined based on the fractional part. Based on the first weight, the second weight, and the value of the reference sampling point, the second predicted value is obtained; the second prediction residual between the sampled value of the sampling point and the second predicted value is obtained.
[0140] In one possible implementation, the prediction module 30 is used for: Perform a signed-to-unsigned folding mapping on the first prediction residual to obtain the mapped value; Perform quotient and remainder decomposition on the mapped values; The quotient is represented by a unary code and the remainder is represented by a fixed-length binary code. The two codes are then concatenated to obtain the codeword of the first prediction residual. Based on the codewords of all first prediction residuals, the residual encoded bitstream of all first prediction residuals of the data block is obtained; Among them, the encoding parameters are the target encoding parameters, which make the total number of bits of the residual encoded bitstream the minimum among all the candidate encoding parameters.
[0141] One possible approach also includes: The decoding module is used to respond to access requests for data corresponding to the decoding cycle by determining the target data block where the data is located based on the block index. Read the predictor identifier of the first data block, and decode the first data block according to the predictor corresponding to the predictor identifier and the residual encoded bitstream corresponding to the first data block. Read the predictor identifier and encoding parameters of the second data block. Calculate the prediction value based on the prediction method corresponding to the predictor identifier and the decoded data that has already been decoded. Decode the prediction residual encoded bitstream to obtain the prediction residual. Add the prediction value to the prediction residual to obtain the decoded data of the second data block. Repeat this process until the decoded data of the target data block is obtained.
[0142] Figure 4 A structural diagram of an energy sampling data processing device provided in an embodiment of the present invention is shown below. Figure 4 As shown, the power sampling data processing device includes: a memory 60 for storing a computer program; and a processor 61 for executing the computer program to implement the steps of the method as described in the above embodiments.
[0143] The power sampling data processing device provided in this embodiment may include, but is not limited to, smartphones, tablets, laptops, or desktop computers.
[0144] The processor 61 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 61 may be implemented using at least one hardware form selected from Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 61 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 61 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 61 may also include an Artificial Intelligence (AI) processor, which handles computational operations related to machine learning.
[0145] The memory 60 may include one or more computer-readable storage media, which may be non-transitory. The memory 60 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 60 is used to store at least the following computer program 601, which, after being loaded and executed by the processor 61, is capable of implementing the relevant steps of the method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 60 may also include an operating system 602 and data 603, etc., and the storage method may be temporary storage or permanent storage. The operating system 602 may include Windows, Unix, Linux, etc.
[0146] In some embodiments, the power sampling data processing device may further include a display screen 62, an input / output interface 63, a communication interface 64, a power supply 65, and a communication bus 66.
[0147] Those skilled in the art will understand that Figure 4 The structure shown does not constitute a limitation on the power sampling data processing device and may include more or fewer components than shown.
[0148] It is understood that if the methods in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the current technology, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods in the various embodiments of the present invention. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, magnetic disks, or optical disks, and other media capable of storing program code.
[0149] Based on this, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the method described above.
[0150] Based on this, embodiments of the present invention also provide a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps of the above-described method. It should be understood that although the steps in the flowcharts of the accompanying drawings are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least a portion of the sub-steps or stages of other steps.
[0151] The above are only some embodiments of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for processing electrical energy sampling data, characterized in that, include: Acquire electrical energy sampling data sequences; The autocorrelation function is calculated based on the energy sampling data sequence, and a peak value is searched in the autocorrelation function to determine the target period, wherein the target period is decomposed into an integer part and a fractional part; The electrical energy sampling data sequence is divided into multiple data blocks according to the integer part; For each sampling point of the data block in the power sampling data sequence, a predictor is used to predict the data to obtain a first predicted value, and a first prediction residual between the sampling value of the sampling point and the first predicted value is obtained; the first prediction residual is encoded to obtain a residual encoded bitstream of all the first prediction residuals of the data block; The storage includes a block index, target period, and multiple data block information for the power sampling data sequence. The data block information includes at least encoding parameters, residual encoded bitstream, and predictor information.
2. The method for processing electrical energy sampling data according to claim 1, characterized in that, For each sampling point in the data block of the power sampling data sequence, a predictor is used to predict the data to obtain a first predicted value, and a first prediction residual is obtained between the sampled value of the sampling point and the first predicted value, including: For the first data block in the power sampling data sequence, a first-order local predictor is used to obtain the first prediction residual between the sampled value of the sampling point and the first prediction value. For each data block in the power sampling data sequence other than the first data block, a target preset predictor is used to predict each sampling point in the data block to obtain a second predicted value of the sampling point, and a second prediction residual between the sampling value of the sampling point and the second predicted value is obtained. The target preset predictor is any preset predictor among a plurality of preset predictors. The optimal predictor is selected from multiple preset predictors, with the condition of minimizing the sum of the absolute values of the prediction residuals within the data block. The second prediction residual between the sampled value of the sampling point of the optimal predictor and the second predicted value is obtained, and is used as the first prediction residual between the sampled value of the sampling point and the first predicted value.
3. The method for processing electrical energy sampling data according to claim 2, characterized in that, The target preset predictor is used to predict each sampling point in the data block to obtain a second predicted value for the sampling point, and a second prediction residual is obtained between the sampled value of the sampling point and the second predicted value, including: If the target preset predictor is a periodic predictor, for the nth sampling point, where n is an integer greater than the integer part, the first sampling point and the second sampling point are determined as reference sampling points. The first sampling point is the nth minus the integer part of the sampling points, and the second sampling point is the nth minus the integer part minus 1 sampling point. The first and second weights of the period predictor are determined based on the fractional part. The second predicted value is obtained based on the first weight, the second weight, and the value of the reference sampling point; the second prediction residual between the sampled value of the sampling point and the second predicted value is obtained.
4. The method for processing electrical energy sampling data according to claim 1, characterized in that, Searching for peaks in the autocorrelation function to determine the target period includes: Within the search range, find the target location corresponding to the maximum value of the autocorrelation function; Parabolic interpolation is performed on the target position to obtain the peak position, and the sampled value corresponding to the peak position is used as the target period.
5. The method for processing electrical energy sampling data according to claim 4, characterized in that, After taking the sampled value corresponding to the peak position as the target period, the method further includes: Verify periodicity at multiples of the peak position; In response to the successful periodic verification, the sampled value corresponding to the peak position is taken as the final target period.
6. The method for processing electrical energy sampling data according to claim 1, characterized in that, Encoding the first prediction residual yields a residual-coded bitstream of all first prediction residuals for the data block, including: Perform a signed-to-unsigned folding mapping on the first prediction residual to obtain the mapped value; Perform quotient and remainder decomposition on the mapped value; The quotient is represented by a unary code and the remainder is represented by a fixed-length binary code. The two codes are then concatenated to obtain the codeword of the first prediction residual. Based on the codewords of all first prediction residuals, the residual encoded bitstream of all first prediction residuals of the data block is obtained; The encoding parameters are target encoding parameters, which minimize the total number of bits in the residual encoded bitstream among all candidate encoding parameters.
7. The method for processing electrical energy sampling data according to any one of claims 1 to 6, characterized in that, The method further includes: In response to an access request for data corresponding to the decoding cycle, the target data block where the data is located is determined based on the block index; Read the predictor identifier of the first data block, and decode the first data block according to the predictor corresponding to the predictor identifier and the residual coded bitstream corresponding to the first data block. Read the predictor identifier and encoding parameters of the second data block, calculate the prediction value according to the prediction method corresponding to the predictor identifier and the decoded data that has been decoded; decode the prediction residual encoded bitstream to obtain the prediction residual, add the prediction value to the prediction residual to obtain the decoded data of the second data block; repeat the process until the decoded data of the target data block is obtained.
8. An electrical energy sampling data processing device, characterized in that, include: The data acquisition module is used to acquire power sampling data sequences; The period estimation module is used to calculate the autocorrelation function based on the power sampling data sequence, and search for the peak value in the autocorrelation function to determine the target period, wherein the target period is decomposed into an integer part and a fractional part; The prediction module is used to divide the power sampling data sequence into multiple data blocks according to the integer part; for each sampling point of the data block in the power sampling data sequence, the predictor performs data prediction to obtain a first predicted value, and obtains a first prediction residual between the sampling value of the sampling point and the first predicted value; the first prediction residual is encoded to obtain a residual encoded bitstream of all the first prediction residuals of the data block. The storage module is used to store the block index, target period, and multiple data block information of the power sampling data sequence. The data block information includes at least encoding parameters, residual encoded bitstream, and predictor information.
9. An electrical energy sampling data processing device, characterized in that, The power sampling data processing device includes a memory and a processor. The memory stores a computer program, and the processor executes the power sampling data processing method according to any one of claims 1 to 7 when running the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one piece of program code, which is loaded and executed by a processor to implement the power sampling data processing method as described in any one of claims 1 to 7.