Harmonic detection method, device and equipment based on dynamic window function

By dynamically adjusting the window function parameters, the problem of poor noise resistance in harmonic detection of fixed window function is solved, and high-precision harmonic detection of complex power signals is achieved, spectrum leakage is reduced, and the accuracy of power quality evaluation is improved.

CN120594941APending Publication Date: 2025-09-05国网河北省电力有限公司营销服务中心 +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510534546.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-27
Publication Date
2025-09-05

AI Technical Summary

Technical Problem

In the prior art, the fixed window function has poor noise resistance in harmonic detection and is weak in adaptability to complex power signals, resulting in serious spectrum leakage problems and affecting the accuracy of power quality evaluation.

Method used

The harmonic detection method based on dynamic window function is adopted, and the window function parameters are dynamically adjusted according to the real-time characteristics of the time domain power signal through parameter adjustment model. The neural network model is used to learn the mapping relationship between signal characteristics and window function type, and optimize the generation of optimal window function parameters, perform window processing and Fourier transform.

Benefits of technology

Significantly reduce spectrum leakage, improve harmonic detection accuracy, improve noise resistance and adaptability of window functions, and enhance robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120594941A_ABST
    Figure CN120594941A_ABST
Patent Text Reader

Abstract

The invention provides a harmonic detection method, device and equipment based on a dynamic window function, and relates to the technical field of signal processing. The method comprises the following steps: acquiring a to-be-detected time domain power signal sequence, and determining a window function type corresponding to the time domain power signal sequence; performing framing processing on the time domain power signal sequence to obtain a plurality of framing signal sequences; inputting the framing signal sequence and the window function type into a preset parameter adjustment model, determining optimal window function parameters corresponding to the power amplitude signals at different moments, and obtaining an optimal window function parameter sequence corresponding to the framing signal sequence; and performing windowing processing and Fourier transform on the framing signal sequence based on the optimal window function parameter sequence, and determining frequency spectrum information corresponding to the framing signal sequence so as to realize harmonic detection of the time domain power signal. According to the invention, the anti-noise performance of the window function and the adaptability to complex power signals can be improved, so that spectrum leakage is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of signal processing technology, and in particular to a harmonic detection method, device and equipment based on a dynamic window function. Background Art

[0002] In the process of evaluating power quality, performing harmonic detection on the collected power signals (such as voltage signals or current signals) is an important task. The results of harmonic detection will seriously affect the evaluation results of power quality.

[0003] Related technologies typically use Fast Fourier Transform (FFT) to process collected power signals, thereby determining the corresponding spectral information and detecting harmonics in the power signals. However, collected power signals are often truncated signals of limited length, which often lead to spectrum leakage. This severely impacts the accuracy of the spectral information when using FFT for harmonic detection, and thus affects the power quality assessment results.

[0004] To address the aforementioned spectrum leakage issue, a window function can be used to perform windowing on the power signal, which can alleviate the spectrum leakage problem to a certain extent. However, the applicant has found that fixed window functions have poor noise immunity and weak adaptability to complex power signals, making them ineffective in addressing spectrum leakage and thus affecting harmonic detection accuracy. Summary of the Invention

[0005] The embodiments of the present invention provide a harmonic detection method, apparatus, and device based on a dynamic window function to solve the problem that a fixed window function has poor noise resistance and weak adaptability to complex power signals, which in turn leads to the inability to effectively avoid spectrum leakage.

[0006] In a first aspect, an embodiment of the present invention provides a harmonic detection method based on a dynamic window function, comprising:

[0007] Acquire a time-domain power signal sequence to be detected, and determine a window function type corresponding to the time-domain power signal sequence;

[0008] Performing frame processing on the time-domain power signal sequence to obtain a plurality of frame signal sequences; the frame signal sequences include power amplitude signals at different moments;

[0009] Inputting the framed signal sequence and the window function type into a preset parameter adjustment model, determining the optimal window function parameters corresponding to the power amplitude signal at different times, and obtaining the optimal window function parameter sequence corresponding to the framed signal sequence; wherein the parameter adjustment model establishes a target loss function based on the deviation between the ideal spectrum corresponding to the input data and the measured spectrum corresponding to the output data, and is trained based on the target loss function;

[0010] Based on the optimal window function parameter sequence, windowing processing and Fourier transform are performed on the frame signal sequence to determine the frequency spectrum information corresponding to the frame signal sequence, so as to achieve harmonic detection of the time domain power signal.

[0011] Optionally, the process of training the parameter adjustment model includes:

[0012] Acquire a model training data set; the model training data set includes a plurality of different frame signal sequences, a window function type corresponding to each frame signal sequence, and an ideal spectrum corresponding to each frame signal sequence;

[0013] Taking the framed signal sequence and the corresponding window function type as input data of the parameter adjustment model, and determining the measured spectrum corresponding to the framed signal sequence and the penalty regularization term according to the window function parameter sequence output by the parameter adjustment model;

[0014] determining a target loss function based on a deviation between the measured spectrum and the corresponding ideal spectrum and the penalty regularization term;

[0015] The parameter adjustment model is trained based on the objective loss function.

[0016] Optionally, adjusting the window function parameter sequence output by the model according to the parameters to determine the penalty regularization term includes:

[0017] When the window function type is a Hanning window, determining the window values ​​of the Hanning window at different times according to the window function parameter sequence;

[0018] The symmetric sum of squared differences of the Hanning window is calculated according to the window value, and the symmetric sum of squared differences is used as the penalty regularization term.

[0019] Optionally, adjusting the window function parameter sequence output by the model according to the parameters to determine the penalty regularization term includes:

[0020] When the window function type is a Gaussian window, the standard deviation offset of the Gaussian window is calculated according to the window function parameter sequence, and the standard deviation offset is used as the penalty regularization term.

[0021] Optionally, adjusting the window function parameter sequence output by the model according to the parameters to determine the penalty regularization term includes:

[0022] When the window function type is a Blackman window, determining a measured spectrum corresponding to the current frame signal sequence according to the window function parameter sequence;

[0023] According to the measured spectrum, sidelobe energy is calculated, and the sidelobe energy is used as the penalty regularization term.

[0024] Optionally, determining a target loss function based on a deviation between the measured spectrum and the corresponding ideal spectrum and the penalty regularization term includes:

[0025] according to determining a deviation between the measured spectrum and a corresponding ideal spectrum;

[0026] in, represents the deviation between the measured spectrum and the corresponding ideal spectrum, K represents the number of frequency points, and X pred (k) represents the measured spectrum amplitude corresponding to the kth frequency point in the measured spectrum, X true (k) represents the ideal spectrum amplitude corresponding to the kth frequency point in the ideal spectrum;

[0027] A weighted sum is performed on the deviation and the penalty regularization term to determine the target loss function.

[0028] Optionally, obtaining a model training data set includes:

[0029] Obtain a periodic time-domain power signal sequence that completely covers the fundamental wave period;

[0030] Asynchronously truncating and adding noise to the periodic time-domain power signal sequence to obtain at least one frame signal sequence, and respectively obtaining a window function type corresponding to each frame signal sequence;

[0031] Performing Fourier transform on the periodic time-domain power signal to obtain an ideal frequency spectrum corresponding to each frame signal sequence.

[0032] Optionally, the performing frame processing on the time-domain power signal sequence to obtain a plurality of frame signal sequences includes:

[0033] Obtaining the fundamental frequency and sampling rate of the time-domain power signal sequence;

[0034] Determining a frame length based on a ratio of the fundamental frequency to the sampling rate, and determining a frame shift based on the frame length;

[0035] The time-domain power signal sequence is framed according to the frame length and the frame shift to obtain a plurality of framed signal sequences.

[0036] In a second aspect, an embodiment of the present invention provides a harmonic detection device based on a dynamic window function, comprising:

[0037] an acquisition module, configured to acquire a time-domain power signal sequence to be detected and determine a window function type corresponding to the time-domain power signal sequence;

[0038] Processing module for:

[0039] Performing frame processing on the time-domain power signal sequence to obtain a plurality of frame signal sequences; the frame signal sequences include power amplitude signals at different moments;

[0040] Inputting the framed signal sequence and the window function type into a preset parameter adjustment model, determining the optimal window function parameters corresponding to the power amplitude signal at different times, and obtaining the optimal window function parameter sequence corresponding to the framed signal sequence; wherein the parameter adjustment model establishes a target loss function based on the deviation between the ideal spectrum corresponding to the input data and the measured spectrum corresponding to the output data, and is trained based on the target loss function;

[0041] A detection module is used to perform windowing processing and Fourier transform on the frame signal sequence based on the optimal window function parameter sequence, determine the spectrum information corresponding to the frame signal sequence, and realize harmonic detection of the time domain power signal.

[0042] In a third aspect, an embodiment of the present invention provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method in the first aspect or any possible implementation of the first aspect is implemented.

[0043] In an embodiment of the present invention, when performing harmonic detection on a time-domain power signal sequence, a parameter adjustment model can be used to dynamically adjust the window function parameters according to the real-time characteristics of the time-domain power signal sequence, thereby achieving dynamic optimization of the window function. The parameter adjustment model establishes a target loss function based on the deviation between the ideal spectrum corresponding to the input data and the measured spectrum corresponding to the output data for training. The trained parameter adjustment model can deeply explore the feature differences between the ideal spectrum and the input data with spectrum leakage, thereby optimizing and generating the optimal window function parameters. The dynamically optimized window function has better anti-noise performance, and is more adaptable and robust to the time-domain power signal sequence. It can significantly reduce the spectrum leakage phenomenon, thereby improving the accuracy of harmonic detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 is an implementation diagram of a harmonic detection method based on a dynamic window function provided by an embodiment of the present invention;

[0045] Figure 2 This is a flowchart of the training process of the parameter adjustment model provided by an embodiment of the present invention;

[0046] Figure 3 is a signal schematic diagram of a periodic time-domain power signal sequence covering a complete cycle provided by an embodiment of the present invention;

[0047] Figure 4 is a spectrum diagram of an ideal spectrum corresponding to a periodic time-domain power signal sequence provided by an embodiment of the present invention;

[0048] Figure 5 1 is a signal diagram of a frame signal sequence after asynchronous truncation and noise addition provided by an embodiment of the present invention;

[0049] Figure 6 1 is a schematic structural diagram of a harmonic detection device based on a dynamic window function provided by an embodiment of the present invention;

[0050] Figure 7 is a schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0051] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0052] During harmonic detection of power signals, given that most collected power signals are truncated signals of limited length, they are prone to spectrum leakage. Therefore, most related technologies pre-window the collected power signals to reduce spectrum leakage. However, the applicant has discovered that fixed window functions have poor noise immunity and are less adaptable to complex power signals, resulting in certain limitations and poor effectiveness in addressing spectrum leakage.

[0053] In order to better solve the spectrum leakage problem and improve the accuracy of harmonic detection, the embodiment of the present invention uses a parameter adjustment model to deeply explore the characteristic differences between the ideal spectrum and the input data with spectrum leakage, so as to optimize and generate the optimal window function parameters based on the input data with spectrum leakage, so that the window function can be dynamically adjusted according to the real-time characteristics of the time domain signal sequence, thereby improving the noise resistance of the window function, making the window function more adaptable and robust to the time domain power signal sequence, thereby significantly reducing the spectrum leakage phenomenon and improving the accuracy of harmonic detection.

[0054] See also Figure 1 , which shows a flow chart of an implementation of a harmonic detection method based on a dynamic window function provided by an embodiment of the present invention, as detailed below:

[0055] Step 101: Acquire a time-domain power signal sequence to be detected, and determine a window function type corresponding to the time-domain power signal sequence.

[0056] Here, the time-domain signal sequence can be a voltage signal sequence or a current signal sequence. Voltage or current signals in the power system can be collected using a voltage transformer or a current transformer, and harmonic detection can be performed on the voltage or current signal sequence to determine the spectrum information therein, thereby achieving power quality assessment of the power system.

[0057] Before dynamically adjusting the window function parameters, the embodiment of the present invention may determine the window function type corresponding to the time domain power signal sequence in advance based on the time domain power signal sequence, and then optimize and generate the optimal window function parameters based on the window function type.

[0058] Specifically, the time-domain power signal sequence to be detected can be subjected to time-domain feature extraction, frequency-domain feature extraction, and joint time-frequency domain feature extraction. Time-domain features primarily include kurtosis, root mean square value, and crest factor. Frequency-domain features primarily include center frequency, frequency bandwidth, and signal-to-noise ratio. Time-frequency domain features primarily include short-term energy distribution entropy and marginal spectral energy distribution.

[0059] The aforementioned time-domain, frequency-domain, and joint time-frequency-domain characteristics all influence the selection of window function types. Specifically, for time-domain characteristics, a larger kurtosis value indicates a high number of impulsive components in the signal. If the signal has high kurtosis, a Blackman window may be more suitable, as it can better handle complex signal components and reduce the impact of spectral leakage on impulsive signal analysis. For signals with lower kurtosis and more stationary signals, a Hanning window may be more appropriate. The RMS value reflects the signal's energy level. When the signal energy is concentrated and stationary, a Hanning window may be a better choice; if the signal energy is dispersed and accompanied by noise, a Gaussian window may be more suitable. The crest factor reflects the shape of the signal waveform. Different waveform shapes may require different window functions for optimal analysis. For example, a regular waveform may be more suitable for a Hanning window, while an irregular waveform may require a Blackman window or a Gaussian window.

[0060] Regarding the center frequency in the frequency domain, if the signal's center frequency is relatively single and distinct, a Hanning window can better highlight that frequency component. However, for signals with unclear center frequencies and a wide spectral distribution, a Gaussian window or Blackman window may be more appropriate. Regarding frequency bandwidth, for signals with narrow bandwidths, a Hanning window is sufficient for analysis; for signals with wider bandwidths, a Blackman window, which offers better sidelobe suppression, or a Gaussian window with smoothing properties may be required. Regarding signal-to-noise ratio, a high signal-to-noise ratio indicates good signal quality, and a Hanning window may be sufficient for analysis; for signals with low signal-to-noise ratios, a Gaussian window, which effectively suppresses noise, may be sufficient.

[0061] For time-frequency joint features, a large short-term energy distribution entropy indicates a dispersed signal energy distribution, and a Gaussian window or Blackman window may be needed for processing. A small short-term energy distribution entropy indicates a relatively concentrated signal energy, and a Hanning window may be more appropriate. Analyzing the marginal spectral energy distribution reveals the energy distribution of the signal at different frequencies. Different window functions can be selected based on the concentration and complexity of the energy distribution.

[0062] The above-mentioned time-domain features, frequency-domain features, and combined time-frequency-domain features can comprehensively reflect the signal characteristics of the above-mentioned time-domain power signal sequence and influence the selection of the window function. Based on this, the embodiment of the present invention pre-establishes a labeled dataset and uses the labeled dataset to train a neural network model, allowing the neural network model to learn the mapping relationship between the above-mentioned time-domain features, frequency-domain features, and combined time-frequency-domain features and the window function type.

[0063] The labeled dataset contains time-domain features, frequency-domain features, and joint time-frequency-domain features corresponding to different time-domain signal sequences, as well as the most suitable window function types for different time-domain signal sequences. The most suitable window function types can be determined through manual labeling. The neural network model is trained using signal features as input and window function type labels as output. The neural network model automatically learns the complex mapping relationship between signal features and window function types through structures such as convolutional layers, pooling layers, and fully connected layers.

[0064] In a trained neural network model, the final layer uses the softmax activation function. This function outputs probabilities for different window function types. These probabilities reflect the model's probability of selecting each window function based on the input signal characteristics. For example, the output might be [0.7, 0.2, 0.1], representing the probabilities of selecting the Hanning window, Gaussian window, and Blackman window, respectively.

[0065] This embodiment of the present invention inputs the aforementioned signal characteristics of the time-domain power signal sequence to be detected into a pre-trained neural network model to determine the window function probability distribution result output by the neural network model. Here, the window function probability distribution result includes different window function types and the probability values ​​corresponding to each window function type. This embodiment of the present invention determines the window function type corresponding to the maximum probability value as the window function type corresponding to the time-domain power signal sequence.

[0066] Step 102 : performing frame processing on the time-domain power signal sequence to obtain a plurality of frame signal sequences; the frame signal sequences include power amplitude signals at different moments.

[0067] Here, considering that most time-domain power signal sequences are non-stationary signals, if the entire signal sequence is directly subjected to a global Fourier transform, the time information will be lost and the dynamic changes of the signal cannot be reflected. Therefore, the present application pre-frames the time-domain power signal sequence, thereby dividing the long-term time-domain power signal sequence signal into a short-term frame signal sequence. Each frame signal sequence can be approximately regarded as a "quasi-stationary" signal, so that the Fourier transform of each frame signal sequence can be performed separately, thereby determining the spectrum information corresponding to each frame signal sequence, and finally realizing the harmonic detection of the entire time-domain power signal sequence.

[0068] Optionally, when the time domain power signal sequence is framed, the fundamental frequency and sampling rate of the time domain power signal sequence can be obtained in advance; then, based on the ratio of the fundamental frequency and the sampling rate, the frame length is determined, and based on the frame length, the frame shift is determined; then, according to the frame length and frame shift, the time domain power signal sequence is framed to obtain multiple framed signal sequences.

[0069] Among them, according to The frame length can be determined. Where N represents the frame length, f represents the sampling rate, and F represents the fundamental frequency. Here, the frame length refers to the total number of sampling points contained in each frame signal sequence, with each moment corresponding to one sampling point.

[0070] Furthermore, in order to achieve a more efficient Fourier transform, we can also determine the integer powers of 2 that are greater than and determines the minimum value as the frame length.

[0071] For example, if the sampling rate is 10kHz and the fundamental frequency is 50Hz, then On this basis, the minimum value greater than 200 is determined to be 256 from all integer powers of 2, that is, the frame length is determined to be 256.

[0072] Based on the determined frame length, the frame shift can be determined according to the preset overlap ratio. The product of the frame length and the overlap ratio is the frame shift. For example, when the frame length is 256 and the overlap ratio is 50%, the frame shift is 128.

[0073] Based on the determination of the frame length and frame shift, the time domain power signal sequence is framed, wherein the k'th frame signal sequence can be expressed as:

[0074]

[0075] Among them, x k' (n) represents the power amplitude signal corresponding to the nth sampling point in the k'th frame signal sequence, x(k'M+n) represents the power amplitude signal corresponding to the k'M+nth sampling point in the time domain signal sequence, M represents the frame shift, represents the total number of frames, and T represents the total number of sampling points in the time domain signal sequence, that is, the total length of the signal.

[0076] Step 103: Input the frame signal sequence and the window function type into a preset parameter adjustment model to determine the optimal window function parameters corresponding to the power amplitude signal at different times, and obtain the optimal window function parameter sequence corresponding to the frame signal sequence.

[0077] The parameter adjustment model can output the optimal window function parameters at different times according to the power amplitude signal and the window function type at different times, thereby realizing dynamic optimization of the window function over time and real-time specific time domain signals.

[0078] Here, the parameter adjustment model establishes a target loss function based on the deviation between the ideal spectrum corresponding to the input data and the measured spectrum corresponding to the output data, and is trained according to the target loss function.

[0079] The ideal spectrum corresponding to the input data refers to the ideal spectrum corresponding to different framed signal sequences. The measured spectrum corresponding to the output data refers to the measured spectrum obtained by windowing different framed signal sequences with the corresponding window function and then performing Fourier transform.

[0080] By establishing a loss function based on the deviation between the above-mentioned ideal spectrum and the measured spectrum and performing model training, the parameter adjustment model can continuously learn the deviation between the ideal spectrum and the measured spectrum and the mapping relationship between the window function parameters during the model training process, so as to minimize the deviation between the measured spectrum corresponding to the optimal window function output by the model and the ideal spectrum.

[0081] Exemplarily, the parameter adjustment model can be a long short-term memory network model (Long Short-Term Memory, LSTM). The parameter adjustment model includes: an input layer, a hidden layer, and a conditional output layer. Among them, the input layer is used to receive a frame signal sequence and a window function type. Here, the window function type can be encoded in the form of a one-hot vector to form a window function type code, which is input into the parameter adjustment model. Exemplarily, the window function type code corresponding to the Hanning window can be [1,0,0], the window function type code corresponding to the Gaussian window can be [0,1,0], and the window function type code corresponding to the Blackman window can be [0,0,1].

[0082] The hidden layer can use three layers of LSTM units (128 units per layer), with Xavier initialization of model parameters. The gating unit uses a sigmoid activation function, and the state update uses a tanh activation function. The gating mechanism (input gate, forget gate, and output gate) captures long-term signal dependencies, laying the foundation for generating optimal window function parameters.

[0083] The conditional output layer includes branches corresponding to different window function types, and dynamically activates the corresponding parameter branch according to the window function type encoding to output the window function parameters of the corresponding window function type.

[0084] Exemplarily, the conditional output layer may include a Hanning window branch, a Gaussian window branch, and a Blackman window branch. The Hanning window branch is used to output the window function parameters in the Hanning window, i.e., the window width adjustment factor, according to the output result of the hidden layer. Here, the output result of the Hanning window branch can be constrained to [-1, 1] by the tanh activation function to meet the window function parameter constraints of the Hanning window. The Gaussian window branch is used to output the window function parameters in the Gaussian window, i.e., the standard deviation scaling factor, according to the output result of the hidden layer. Here, the output result of the Gaussian window branch can be constrained to [0.5, 2.0] by the sigmoid activation function to meet the window function parameter constraints of the Gaussian window. The Blackman window branch is used to output the window function parameters in the Blackman window, i.e., the window function coefficient combination, according to the output result of the hidden layer. Here, the output result of the Blackman window branch can be normalized by the softmax activation function to meet the window function parameter constraints of the Blackman window.

[0085] Specifically, the LSTM unit mainly includes input gate, forget gate, output gate and memory unit.

[0086] (1) The input gate calculation formula can be expressed as: t =σ(W xi ·x t +W hi ·h t-1 +W ci ⊙c t-1 +b i );

[0087] Among them, i t represents the input gate activation value at time t, ⊙ represents element-by-element multiplication, σ(·) represents the sigmoid activation function, and W xi Represents the input data x t The weight matrix to the input gate, W hi Indicates the hidden state h at time t-1 t-1 The weight matrix to the input gate, W ci Represents the memory unit c at time t-1 t-1 The weight matrix to the input gate, c t-1 represents the memory unit at time t-1, b i represents the bias vector, x t represents the input data at time t, h t-1 represents the hidden state at time t-1.

[0088] The input gate determines how much of the current input data is stored in the memory cell.

[0089] (2) The calculation formula of the forget gate can be expressed as:

[0090] f t =σ(W xf ·x t +W hf ·h t-1 +W cf ⊙c t-1 +b f );

[0091] Among them, f t Represents the forget gate activation value at time t, W xf Represents the input signal x t To the weight matrix of the forget gate, W hf Indicates the hidden state h at time t-1 t-1 To the weight matrix of the forget gate, W cf Represents the memory unit c at time t-1 t-1 To the weight matrix of the forget gate, b f A bias vector that adjusts the forget gate activation threshold.

[0092] The function of the forget gate is to decide which information in the memory unit at the previous moment should be retained or forgotten. The meaning of the weight matrix and bias vector is similar to that of the input gate.

[0093] (3) The calculation formula of candidate memory units can be expressed as:

[0094] in, represents the candidate memory unit at time t, tanh(·) represents the hyperbolic tangent activation function, W xc Represents the input signal x t To the weight matrix of the memory unit, W hc Indicates the hidden state h at time t-1 t-1 to the weight matrix of the memory unit, b c Represents the bias vector generated by adjusting the candidate memory unit.

[0095] Here, the candidate memory unit only depends on the input data x at time t t and the hidden state h at time t-1 t-1 .

[0096] (4) The calculation formula for memory unit update can be expressed as:

[0097] Among them, c t Represents the memory unit at time t.

[0098] The memory unit first partially forgets the memory unit at the previous moment according to the forget gate, and then updates it based on the new information determined by the input gate.

[0099] (5) The output gate calculation formula can be expressed as: t =σ(W xo ·x t +W ho ·h t-1 +W co ⊙c t +b o );

[0100] Among them, t Represents the output value of the output gate at time t, W xo Represents the input data x t The weight matrix to the output gate, W ho Indicates the hidden state h at the previous moment t-1 The weight matrix to the output gate, W co Represents memory unit c t The weight matrix to the output gate, b o A bias vector that adjusts the output gate activation threshold.

[0101] (5) The final hidden state formula can be expressed as: h t =o t ⊙tanh(c t );

[0102] Among them, h t represents the hidden state at time t, o t represents the output gate activation value at time t, c t Represents the memory unit at time t.

[0103] The hidden state at time t is carried forward to the next time step and serves as one of the model's output features, subsequently used to generate optimized window function parameters. When constructing the hidden layer of the LSTM model, these formulas are used to calculate the state update and output of each LSTM unit to capture long-term dependencies and dynamic changes in the signal.

[0104] Step 104 : Based on the optimal window function parameter sequence, perform windowing processing and Fourier transform on the frame signal sequence to determine the spectrum information corresponding to the frame signal sequence, so as to achieve harmonic detection of the time domain power signal.

[0105] Embodiments of the present invention utilize a parameter adjustment model to determine optimal window function parameter sequences corresponding to different framed signal sequences. Based on the optimal window function parameter sequences, window functions corresponding to the power amplitude signals at each sampling point in the framed signal sequence are determined. Windowing is performed on each power amplitude signal in the framed signal sequence based on each window function, and a Fourier transform is performed on the windowed signal sequence to determine the spectral information corresponding to each framed signal sequence, thereby completing harmonic detection.

[0106] Specifically, a discrete Fourier transform can be used to perform Fourier transform on a frame signal sequence with a frame length of N to determine the spectrum information. The specific formula is:

[0107] Wherein, X(k) represents the spectrum amplitude of the kth frequency point in the frequency domain signal, x(n) represents the power amplitude signal of the nth sampling point in the frame signal sequence, and k represents the frequency point index.

[0108] Compared with the prior art, the embodiment of the present invention establishes a target loss function based on the deviation between the ideal spectrum corresponding to the input data and the measured spectrum corresponding to the output data, and trains a parameter adjustment model based on the target loss function. The parameter adjustment model can deeply explore the characteristic differences between the ideal spectrum and the input signal with spectrum leakage, and generate optimal window function parameters based on the characteristic differences, so as to achieve the purpose of dynamically optimizing and adjusting the window function parameters according to the real-time signal characteristics, increase the noise resistance of the window function, and improve the adaptability and robustness of the window function to the time domain power signal sequence, thereby significantly reducing the spectrum leakage phenomenon and improving the harmonic detection accuracy.

[0109] The following is a detailed introduction to the training process of the parameter adjustment model:

[0110] Optional, see Figure 2 , you can follow the steps below when training parameter adjustment model:

[0111] Step 201 : Acquire a model training data set; the model training data set includes a plurality of different frame signal sequences, a window function type corresponding to each frame signal sequence, and an ideal spectrum corresponding to each frame signal sequence.

[0112] Optionally, when obtaining the model training data set, a periodic time domain power signal sequence that completely covers the fundamental wave period can be obtained, and the above periodic time domain power signal sequence can be asynchronously truncated and noise added to obtain at least one frame signal sequence, and the window function type corresponding to each frame signal sequence can be obtained respectively; then, the periodic time domain power signal is Fourier transformed to obtain the ideal spectrum corresponding to each frame signal sequence.

[0113] Here, the above-mentioned periodic time-domain power signal sequence covering a complete cycle can be a noise-free, strictly periodic synthetic signal to ensure that the signal completely covers the fundamental wave period in the time domain (e.g., a 50 Hz fundamental wave corresponds to a 20 ms period). The above-mentioned periodic time-domain power signal sequence is directly subjected to Fourier transform, and its periodic characteristics can be used to avoid spectrum leakage, and the obtained spectrum is the ideal spectrum. For example, see Figure 3 and Figure 4 , the periodic time-domain power signal sequence covering a complete cycle can be expressed as Figure 3 As shown, the ideal spectrum corresponding to the periodic time-domain power signal sequence can be expressed as Figure 4 shown.

[0114] By performing asynchronous truncation and noise addition operations on the above periodic time-domain power signal sequence, a framed signal sequence with spectrum leakage can be obtained. Here, in order to expand the training data set, multiple combinations of truncation and noise can be applied to the same periodic time-domain power signal sequence to obtain multiple framed signal sequences to improve the generalization ability of the model. For example, see Figure 5 , the frame signal sequence after asynchronous truncation and noise addition can be expressed as Figure 5 shown.

[0115] Here, when determining the window function type corresponding to each frame signal sequence, reference may be made to the above-mentioned specific method for determining the window function type corresponding to the time domain signal sequence, which will not be described in detail here.

[0116] The ideal spectrum corresponding to each frame signal sequence is used as label data, and each frame signal sequence and the corresponding window function type are used as input data, providing the model with rich learning materials, enabling it to fully learn the characteristic patterns of spectrum leakage and the standard form of the ideal spectrum, continuously update the window function parameters, and realize dynamic update of the window function parameters.

[0117] Step 202: Using the framed signal sequence and the corresponding window function type as input data of the parameter adjustment model, and determining the measured spectrum corresponding to the framed signal sequence and the penalty regularization term according to the window function parameter sequence output by the parameter adjustment model;

[0118] Here, a dynamic window function corresponding to the framed signal sequence can be determined based on the window function parameter sequence output by the parameter adjustment model. The framed signal sequence is windowed and Fourier transformed according to the dynamic window function to determine the measured spectrum corresponding to the framed signal sequence.

[0119] In addition, the embodiment of the present invention further provides a penalty regularization term for penalizing the output result of the parameter adjustment model to ensure the dynamic performance of the dynamic window function.

[0120] Step 203: determining a target loss function based on the deviation between the measured spectrum and the corresponding ideal spectrum and a penalty regularization term;

[0121] Optionally, you can determining the deviation between a measured spectrum and a corresponding ideal spectrum;

[0122] in, Indicates the deviation between the measured spectrum and the corresponding ideal spectrum, K represents the number of frequency points, X pred (k) represents the measured spectrum amplitude corresponding to the kth frequency point in the measured spectrum, X true (k) represents the ideal spectrum amplitude corresponding to the kth frequency point in the ideal spectrum.

[0123] Based on the above deviation, the deviation and penalty regularization term are weighted and summed to determine the target loss function. The specific formula is: Determine the loss function;

[0124] in, represents the loss function, represents the deviation between the measured spectrum and the corresponding ideal spectrum, λ represents the weight coefficient, represents the penalty regularization term.

[0125] It should be noted that the weight coefficient has different values ​​for different window function types. The value of the weight coefficient can be determined according to the actual situation. For example, the weight coefficient corresponding to the Hanning window can be 0.1, the weight coefficient corresponding to the Gaussian window can be 0.05, and the weight coefficient corresponding to the Blackman window can be 0.2.

[0126] This embodiment of the present invention uses the weighted sum of the mean squared error of the spectral amplitude and the penalty regularization term as the loss function. This accurately measures the difference between the spectrum obtained by applying the model-generated window function to the signal and the ideal spectrum, as well as the rationality of the generated window function. By minimizing this loss function, the model is guided to continuously adjust its parameters, optimizing the generated window function and effectively reducing spectral leakage.

[0127] Step 204: Adjust the model parameters based on the target loss function training.

[0128] During model training, the framed signal sequence and the corresponding window function type are input into the parameter adjustment model to obtain the window function parameter sequence output by the parameter adjustment model, and the target loss function is calculated accordingly. If the target loss function is greater than a set threshold, the model parameters are adjusted, and the step of inputting the framed power signal sequence and the corresponding window function type into the parameter adjustment model to obtain the window function parameter sequence output by the parameter adjustment model is skipped until the loss function is less than the set threshold, thereby obtaining a trained parameter adjustment model.

[0129] Next, for different window function types, the methods for determining the penalty regularization term are introduced respectively.

[0130] When the window function type is a Hanning window, the embodiment of the present invention improves the window function formula of the Hanning window and determines that the improved window function formula is:

[0131] Among them, w(n) represents the window value corresponding to the nth sampling point in the current frame signal sequence, n represents the sampling point index, α n It represents the window width adjustment factor corresponding to the nth sampling point in the current frame signal sequence, and N represents the total number of sampling points in the current frame signal sequence, that is, the frame length.

[0132] Here, the window function parameter sequence includes window width adjustment factors corresponding to different sampling points. The window width adjustment factors are used to adjust the symmetry of the Hanning window, thereby controlling the balance between the mainlobe width and sidelobe attenuation, thereby improving the window performance of the Hanning window.

[0133] When determining the penalty regularization term, the embodiment of the present invention can determine the window values ​​of the Hanning window at different times according to the window function parameter sequence; then, based on the window value, calculate the symmetry difference square sum of the Hanning window, and use the symmetry difference square sum as the penalty regularization term.

[0134] The specific formula is: in, represents the penalty regularization term, and w(N-1-n) represents the window value corresponding to the n-th sampling point in the current frame signal sequence.

[0135] An asymmetric Hanning window can cause the mainlobe energy to shift to one side, making spectral leakage more pronounced in one direction, potentially masking the true signal or generating spurious frequency components. Therefore, in this embodiment of the present invention, a penalty regularization term is provided to penalize the asymmetry of the Hanning window.

[0136] When the window function type is Gaussian window, the window function formula of Gaussian window is:

[0137] Where w(n) represents the window value corresponding to the nth sampling point in the current frame signal sequence, n represents the sampling point index, σ n It represents the standard deviation proportional factor corresponding to the nth sampling point in the current frame signal sequence, and N represents the total number of sampling points in the current frame signal sequence.

[0138] The window function parameter sequence contains the standard deviation scaling factors corresponding to different sampling points. The embodiment of the present invention can calculate the standard deviation offset of the Gaussian window based on the window function parameter sequence and use the standard deviation offset as a penalty regularization term. The specific formula can be expressed as:

[0139] in, represents the penalty regularization term, σ target Represents the symmetry reference value, that is, the fixed symmetry parameter of the basic Gaussian window.

[0140] If the Gaussian window is asymmetric in the time domain (e.g., one side attenuates faster), its main lobe in the frequency domain will shift, and the sidelobe distribution will become uneven, resulting in the masking of weak low-frequency signals or the introduction of false high-frequency components, thereby affecting the accuracy of spectrum analysis. Therefore, embodiments of the present invention provide a penalty regularization term to penalize the asymmetry of the Gaussian window. Here, the standard deviation shift of the Gaussian window can reflect the symmetry of the Gaussian window.

[0141] When the window function type is Blackman window, the window function formula of the Blackman window can be expressed as:

[0142] Among them, w(n) represents the window value corresponding to the nth sampling point in the current frame signal sequence, n represents the sampling point index, and a 0,n 、a 1,n and a 2,n They represent the window coefficients corresponding to the nth sampling point in the current frame signal sequence, and N represents the total number of sampling points in the current frame signal sequence.

[0143] The window function parameter sequence includes window coefficients corresponding to different sampling points. In an embodiment of the present invention, based on the determination of the window function parameter sequence, the measured spectrum corresponding to the current framed signal sequence is determined according to the window function parameter sequence; sidelobe energy is calculated based on the measured spectrum, and the sidelobe energy is used as a penalty regularization term.

[0144] Specifically, based on determining the window coefficients of the Blackman window corresponding to each sampling point, the window value of the Blackman window corresponding to each sampling point can be determined. Based on the window value, the framed signal sequence can be windowed, and the windowed framed signal sequence can be Fourier transformed to determine the measured spectrum corresponding to the framed signal sequence.

[0145] After determining the measured spectrum, the sidelobe energy can be calculated based on the measured spectrum and used as a penalty regularization term. The specific formula can be expressed as:

[0146] in, represents the penalty regularization term, X pred (k) represents the measured spectrum amplitude corresponding to the kth frequency point in the current frame signal sequence, and K1 and K2 represent the lower limit and upper limit of the sidelobe frequency in the measured spectrum, respectively.

[0147] For the Blackman window, high sidelobe energy means that more energy in the spectrum of the framed signal sequence will leak into adjacent frequency components. Especially in the presence of strong interfering signals, high sidelobes can lead to the detection of spurious frequency components. Therefore, this embodiment of the present invention provides a penalty regularization term to penalize the sidelobe energy of the Blackman window, thereby further reducing the energy in these non-mainlobe regions and improving the accuracy of spectrum analysis.

[0148] The harmonic detection method based on dynamic window functions provided by the embodiments of the present invention has significant advantages in the field of harmonic detection in power systems. Compared with traditional harmonic detection methods, it has many innovations and breakthroughs:

[0149] In terms of harmonic detection accuracy, the parameter adjustment model in the embodiments of the present invention can dynamically generate optimal window function parameters based closely on the real-time characteristics of the time-domain signal. This dynamic adjustment mechanism effectively reduces spectrum leakage and significantly improves the accuracy of harmonic detection. High-precision harmonic detection results provide more accurate data support for power quality assessment and control of power systems, making power system operating status monitoring more precise, helping to promptly identify potential problems and take effective measures to adjust them, thereby ensuring the stable and reliable operation of the power system.

[0150] From the perspective of adaptability and robustness, the fixed window function used in traditional harmonic detection methods has significant limitations when processing complex power system signals. This invention overcomes this limitation by dynamically adjusting the window function through a parameter adjustment model, demonstrating greater adaptability and robustness to complex and changing power system signals. Whether dealing with non-periodic signals or complex situations with multiple interference factors, this method can more effectively handle them, ensuring the accuracy and reliability of harmonic detection results and providing strong support for the stable operation of power systems under complex operating conditions.

[0151] In terms of noise resistance, traditional methods are susceptible to interference in harmonic detection results in noisy environments, resulting in reduced accuracy. The dynamic window function in the embodiments of the present invention can, to a certain extent, resist noise interference on harmonic detection. Even in complex electromagnetic environments, it can operate stably and output accurate results, greatly improving system reliability and reducing the risk of misjudgment and misoperation caused by noise interference, thus safeguarding the reliable operation of the power system.

[0152] Furthermore, the harmonic detection method provided by the embodiments of the present invention can be easily integrated into existing power system monitoring and analysis equipment, eliminating the need for large-scale modifications to existing equipment and effectively reducing application costs. This scalability enables the harmonic detection method provided by the present invention to be quickly applied to actual power systems, promoting the intelligent development of power systems, providing more reliable data support for power quality assessment and control of power systems, and helping the power industry develop in a more efficient and intelligent direction.

[0153] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0154] The following are device embodiments of the present invention. For details not fully described therein, reference may be made to the corresponding method embodiments described above.

[0155] Figure 6 A schematic diagram of the structure of a harmonic detection device based on a dynamic window function provided by an embodiment of the present invention is shown. For ease of explanation, only the parts related to the embodiment of the present invention are shown, which are described in detail as follows:

[0156] like Figure 6 As shown, the harmonic detection device 6 based on the dynamic window function includes: an acquisition module 61 , a processing module 62 and a detection module 63 .

[0157] An acquisition module 61 is configured to acquire a time-domain power signal sequence to be detected and determine a window function type corresponding to the time-domain power signal sequence;

[0158] The processing module 62 is configured to:

[0159] Performing frame processing on the time domain power signal sequence to obtain multiple frame signal sequences; the frame signal sequences include power amplitude signals at different times;

[0160] The framed signal sequence and window function type are input into a preset parameter adjustment model to determine the optimal window function parameters corresponding to the power amplitude signal at different times, thereby obtaining the optimal window function parameter sequence corresponding to the framed signal sequence. The parameter adjustment model establishes a target loss function based on the deviation between the ideal spectrum corresponding to the input data and the measured spectrum corresponding to the output data, and is trained based on the target loss function.

[0161] The detection module 63 is configured to perform windowing and Fourier transform on the frame signal sequence based on the optimal window function parameter sequence, and determine the spectrum information corresponding to the frame signal sequence to achieve harmonic detection of the time domain power signal.

[0162] In a possible implementation, the processing module 62 is further configured to:

[0163] Obtain a model training data set; the model training data set includes a plurality of different frame signal sequences, a window function type corresponding to each frame signal sequence, and an ideal spectrum corresponding to each frame signal sequence;

[0164] The framed signal sequence and the corresponding window function type are used as the input data of the parameter adjustment model, the window function parameter sequence output by the parameter adjustment model is output, and the measured spectrum corresponding to the framed signal sequence and the penalty regularization term are determined;

[0165] Determine the target loss function based on the deviation between the measured spectrum and the corresponding ideal spectrum, as well as the penalty regularization term;

[0166] The model is adjusted by training parameters based on the target loss function.

[0167] In a possible implementation, the processing module 62 is specifically configured to:

[0168] Adjust the window function parameter sequence of the model output according to the parameters and determine the penalty regularization term, including:

[0169] When the window function type is Hanning window, the window value of Hanning window at different time is determined according to the window function parameter sequence;

[0170] According to the window value, the symmetric sum of squared differences of the Hanning window is calculated and used as a penalty regularization term.

[0171] In a possible implementation, the processing module 62 is specifically configured to:

[0172] When the window function type is Gaussian window, the standard deviation offset of the Gaussian window is calculated according to the window function parameter sequence, and the standard deviation offset is used as the penalty regularization term.

[0173] In a possible implementation, the processing module 62 is specifically configured to:

[0174] When the window function type is Blackman window, the measured spectrum corresponding to the current frame signal sequence is determined according to the window function parameter sequence;

[0175] According to the measured spectrum, the sidelobe energy is calculated and used as a penalty regularization term.

[0176] In a possible implementation, the processing module 62 is specifically configured to:

[0177] according to determining the deviation between a measured spectrum and a corresponding ideal spectrum;

[0178] in, Indicates the deviation between the measured spectrum and the corresponding ideal spectrum, K represents the number of frequency points, X pred (k) represents the measured spectrum amplitude corresponding to the kth frequency point in the measured spectrum, X true (k) represents the ideal spectrum amplitude corresponding to the kth frequency point in the ideal spectrum;

[0179] The bias and penalty regularization terms are weighted summed to determine the target loss function.

[0180] In a possible implementation, the processing module 62 is specifically configured to:

[0181] Obtain a periodic time-domain power signal sequence that completely covers the fundamental wave period;

[0182] Asynchronously truncating and adding noise to the periodic time-domain power signal sequence to obtain at least one frame signal sequence, and respectively obtaining a window function type corresponding to each frame signal sequence;

[0183] Perform Fourier transform on the periodic time-domain power signal to obtain the ideal spectrum corresponding to each frame signal sequence.

[0184] In a possible implementation, the processing module 62 is specifically configured to:

[0185] Obtain the fundamental frequency and sampling rate of the time domain power signal sequence;

[0186] Determine the frame length based on the ratio of the fundamental frequency and the sampling rate, and determine the frame shift based on the frame length;

[0187] The time domain power signal sequence is framed according to the frame length and the frame shift to obtain multiple framed signal sequences.

[0188] This device embodiment can be used to implement the above method embodiment. Its technical principles and implementation effects are the same as those of the above method embodiment, and will not be repeated here.

[0189] Figure 7 Schematic diagram of an electronic device provided by an embodiment of the present invention. Figure 7 As shown, the electronic device 7 of this embodiment includes a processor 70 and a memory 71. The memory 71 stores a computer program 72. When the processor 70 executes the computer program 72, the steps of the above-described method embodiments are implemented. Alternatively, when the processor 70 executes the computer program 72, the functions of the modules / units in the above-described device embodiments are implemented.

[0190] Exemplarily, the computer program 72 may be divided into one or more modules / units, which are stored in the memory 71 and executed by the processor 70 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, and the instruction segments are used to describe the execution process of the computer program 72 in the electronic device 7.

[0191] The electronic device 7 may include, but is not limited to, a processor 70 and a memory 71. Those skilled in the art will appreciate that Figure 7 It is only an example of the electronic device 7 and does not constitute a limitation of the electronic device 7. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 7 may also include input and output devices, network access devices, buses, etc.

[0192] For the sake of convenience and brevity, the division of the above functional modules / units is only used as an example. In actual applications, the above functions can be assigned to different functional modules / units as needed. The above modules / units can be implemented in the form of hardware, software, or a combination of hardware and software.

[0193] In the above embodiments, the descriptions of each embodiment have their own focus. For parts not described or recorded in detail in one embodiment, please refer to the relevant descriptions of other embodiments. Unless otherwise specified or there is a logical conflict, the terms and / or descriptions between different embodiments are consistent and can be referenced to each other. The technical features of different embodiments can be combined to form new embodiments based on their inherent logical relationships.

[0194] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.

Claims

1. A harmonic detection method based on a dynamic window function, characterized in that: include: Acquire a time-domain power signal sequence to be detected, and determine a window function type corresponding to the time-domain power signal sequence; Performing frame processing on the time-domain power signal sequence to obtain a plurality of frame signal sequences; the frame signal sequences include power amplitude signals at different moments; Inputting the framed signal sequence and the window function type into a preset parameter adjustment model, determining the optimal window function parameters corresponding to the power amplitude signal at different times, and obtaining the optimal window function parameter sequence corresponding to the framed signal sequence; wherein the parameter adjustment model establishes a target loss function based on the deviation between the ideal spectrum corresponding to the input data and the measured spectrum corresponding to the output data, and is trained based on the target loss function; Based on the optimal window function parameter sequence, windowing processing and Fourier transform are performed on the frame signal sequence to determine the frequency spectrum information corresponding to the frame signal sequence, so as to achieve harmonic detection of the time domain power signal.

2. The harmonic detection method based on dynamic window function according to claim 1, characterized in that: The process of training the parameter adjustment model includes: Acquire a model training data set; the model training data set includes a plurality of different frame signal sequences, a window function type corresponding to each frame signal sequence, and an ideal spectrum corresponding to each frame signal sequence; Taking the framed signal sequence and the corresponding window function type as input data of the parameter adjustment model, and determining the measured spectrum corresponding to the framed signal sequence and the penalty regularization term according to the window function parameter sequence output by the parameter adjustment model; determining a target loss function based on a deviation between the measured spectrum and the corresponding ideal spectrum and the penalty regularization term; The parameter adjustment model is trained based on the objective loss function.

3. The harmonic detection method based on dynamic window function according to claim 2, characterized in that: Adjust the window function parameter sequence of the model output according to the parameters to determine the penalty regularization term, including: When the window function type is a Hanning window, determining the window values ​​of the Hanning window at different times according to the window function parameter sequence; The symmetric sum of squared differences of the Hanning window is calculated according to the window value, and the symmetric sum of squared differences is used as the penalty regularization term.

4. The harmonic detection method based on dynamic window function according to claim 2, characterized in that: Adjust the window function parameter sequence of the model output according to the parameters to determine the penalty regularization term, including: When the window function type is a Gaussian window, the standard deviation offset of the Gaussian window is calculated according to the window function parameter sequence, and the standard deviation offset is used as the penalty regularization term.

5. The harmonic detection method based on dynamic window function according to claim 2, characterized in that: Adjust the window function parameter sequence of the model output according to the parameters to determine the penalty regularization term, including: When the window function type is a Blackman window, determining a measured spectrum corresponding to the current frame signal sequence according to the window function parameter sequence; According to the measured spectrum, sidelobe energy is calculated, and the sidelobe energy is used as the penalty regularization term.

6. The harmonic detection method based on dynamic window function according to any one of claims 2 to 5, characterized in that: The determining of a target loss function based on the deviation between the measured spectrum and the corresponding ideal spectrum and the penalty regularization term includes: according to determining a deviation between the measured spectrum and a corresponding ideal spectrum; in, represents the deviation between the measured spectrum and the corresponding ideal spectrum, K represents the number of frequency points, and X pred (k) represents the measured spectrum amplitude corresponding to the kth frequency point in the measured spectrum, X true (k) represents the ideal spectrum amplitude corresponding to the kth frequency point in the ideal spectrum; A weighted sum is performed on the deviation and the penalty regularization term to determine the target loss function.

7. The harmonic detection method based on dynamic window function according to any one of claims 2 to 5, characterized in that: The obtaining of the model training data set comprises: Obtain a periodic time-domain power signal sequence that completely covers the fundamental wave period; Asynchronously truncating and adding noise to the periodic time-domain power signal sequence to obtain at least one frame signal sequence, and respectively obtaining a window function type corresponding to each frame signal sequence; Performing Fourier transform on the periodic time-domain power signal to obtain an ideal frequency spectrum corresponding to each frame signal sequence.

8. The harmonic detection method based on dynamic window function according to any one of claims 1 to 5, characterized in that: The framing process is performed on the time domain power signal sequence to obtain a plurality of frame signal sequences, including: Obtaining the fundamental frequency and sampling rate of the time-domain power signal sequence; Determining a frame length based on a ratio of the fundamental frequency to the sampling rate, and determining a frame shift based on the frame length; The time-domain power signal sequence is framed according to the frame length and the frame shift to obtain a plurality of framed signal sequences.

9. A harmonic detection device based on a dynamic window function, characterized in that: include: an acquisition module, configured to acquire a time-domain power signal sequence to be detected and determine a window function type corresponding to the time-domain power signal sequence; Processing module for: Performing frame processing on the time-domain power signal sequence to obtain a plurality of frame signal sequences; the frame signal sequences include power amplitude signals at different moments; Inputting the framed signal sequence and the window function type into a preset parameter adjustment model, determining the optimal window function parameters corresponding to the power amplitude signal at different times, and obtaining the optimal window function parameter sequence corresponding to the framed signal sequence; wherein the parameter adjustment model establishes a target loss function based on the deviation between the ideal spectrum corresponding to the input data and the measured spectrum corresponding to the output data, and is trained based on the target loss function; A detection module is used to perform windowing processing and Fourier transform on the frame signal sequence based on the optimal window function parameter sequence, determine the spectrum information corresponding to the frame signal sequence, and realize harmonic detection of the time domain power signal.

10. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.