Harmonic extraction system and method based on frequency domain convolution
Patent Information
- Application Number
- CN202611381590.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-08
- Publication Date
- 2026-10-13
AI Technical Summary
上述改进方案均在离散频率栅格的框架内操作,未能改变频谱的离散化表示方式,因而无法从根源上消除泄漏与混叠
[0049]1.本发明通过隐式神经频谱网络拟合连续频谱函数,以时域重构误差和频谱稀疏性约束反向优化频谱表示,避免传统FFT离散频率栅格造成的频谱泄漏和谱峰偏移,使间谐波及密集谐波的频率、幅值和相位提取更加准确。
Smart Images

Figure CN122901519A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power quality analysis technology for power systems, and specifically to a harmonic extraction system and method based on frequency domain convolution. Background Technology
[0002] The large-scale grid connection of new energy sources has made the grid harmonic environment increasingly complex. When distributed power sources such as wind power and photovoltaics are connected to the grid via inverter clusters, the differences in switching frequencies and modulation methods of each inverter inject not only conventional integer harmonics but also a large number of interharmonics. The slightly different switching frequencies of multiple inverters result in a dense distribution of interharmonic frequencies across the spectrum, interleaving with integer harmonics to form a complex and dense spectrum. Accurately extracting the frequency, amplitude, and phase of each harmonic component in this dense spectrum is a prerequisite for subsequent processes such as generating compensation current for active power filters and power quality monitoring and assessment.
[0003] However, frequency domain harmonic extraction methods based on Fast Fourier Transform (FFT) face structural difficulties when processing the aforementioned dense spectrum. FFT discretizes the continuous spectrum onto equally spaced frequency grids, with the grid spacing determined by the sampling frequency and the number of data points. Integer harmonics may fall precisely on the grid points under synchronized sampling conditions, but interharmonic frequencies almost always fall between two grid points, and their energy leaks along the sidelobes of the window function to multiple grid points on both sides. This leakage not only distorts the amplitude and frequency extraction of the interharmonics themselves but also superimposes the leaked energy onto neighboring integer harmonic components, causing the spectra of the two types of harmonics to overlap.
[0004] In existing technologies, window function optimization schemes reduce leakage amplitude by suppressing sidelobes. However, there is an inherent contradiction between sidelobe attenuation and main lobe width. Suppressing sidelobes while widening the main lobe reduces the resolution of dense frequency components, causing further aliasing of adjacent harmonics due to main lobe overlap. Zero-filling schemes only interpolate the spectrum without introducing new frequency information, leaving the leakage mode unchanged. While deep learning-based improvements introduce nonlinear modeling capabilities, their input remains a discrete FFT spectrum, and the upper limit of model accuracy is limited by the grid discretization error of the input spectrum itself and the degree of leakage and aliasing. All of the above improvements operate within the framework of a discrete frequency grid and fail to change the discretization representation of the spectrum, thus failing to eliminate leakage and aliasing at their root.
[0005] Therefore, there is an urgent need for a new harmonic extraction method that can overcome the structural limitations of discrete frequency grids, achieve accurate positioning and separation of harmonic components in the continuous frequency domain, and meet the real-time requirements of online processing in power systems. Summary of the Invention
[0006] To address the shortcomings of existing technologies, the present invention aims to provide a harmonic extraction system and method based on frequency domain convolution. By constructing a continuous spectral function parameterized by a neural network to replace the traditional discrete FFT spectrum, spectral leakage caused by frequency grid discretization is eliminated at the representation level. Gradient optimization on the continuous spectral function enables accurate peak localization without being limited by traditional frequency resolution. Furthermore, the neurally parameterized frequency domain convolution kernel adaptively separates each harmonic component on the continuous spectrum. At the same time, a two-stage hot-start acceleration strategy of meta-learning and sliding window is adopted to reduce the computational overhead of online fitting, meeting the engineering requirements of real-time processing in power systems.
[0007] To achieve the above objectives, the present invention provides the following technical solution:
[0008] A harmonic extraction method based on frequency domain convolution, the method comprising:
[0009] The collected power grid signals are preprocessed and segmented to obtain multiple signal segments;
[0010] An implicit neural spectrum network is constructed with frequency values as input and complex spectral values at that frequency as output. The parameters of the implicit neural spectrum network are optimized with the time-domain reconstruction error of the multiple signal segments as the optimization target to obtain the continuous spectrum function corresponding to each signal segment.
[0011] The precise frequency of each harmonic component is located on the continuous spectrum function, and the amplitude and phase of each harmonic component are obtained based on the complex values of the spectrum at the precise frequency.
[0012] Based on the precise frequency of each harmonic component, a convolutional kernel network with frequency offset as input and convolution weight as output is constructed and trained for each harmonic component. The continuous spectrum function is multiplied point by point in the frequency domain with the output of each trained convolutional kernel network to obtain the continuous spectrum after separation of each harmonic component.
[0013] An inverse Fourier transform is performed on the continuous spectrum after the separation of each harmonic component to reconstruct the time-domain waveform of each harmonic component, and a parameter table is generated based on the precise frequency, amplitude and phase.
[0014] Furthermore, the implicit neural spectral network includes an input layer, a hidden layer, and an output layer, wherein:
[0015] The input layer uses sinusoidal position coding to map scalar frequency values to a high-dimensional space. The sinusoidal position coding includes multiple frequency scale parameters. The ratio between adjacent frequency scale parameters is a fixed common ratio. The minimum frequency scale parameter is determined according to the reciprocal of the sampling frequency, and the maximum frequency scale parameter is determined according to half of the sampling frequency.
[0016] The hidden layer uses a sinusoidal activation function;
[0017] The output layer employs a linear mapping to output the real and imaginary parts of the complex value of the spectrum.
[0018] Furthermore, the implicit neural spectral network is parameter optimized using the temporal reconstruction error of the multiple signal segments as the optimization objective, including:
[0019] Multiple integration nodes are set on the frequency range of the continuous spectrum function. The time-domain signal is reconstructed by numerical integration of the complex spectrum values at each integration node. The mean square error between the reconstructed time-domain signal and the corresponding signal segment is calculated as the time-domain reconstruction error.
[0020] Calculate the power spectrum value at each integration node, and perform smooth binarization on each power spectrum value using the Sigmoid function. Use the mean of the smooth binarization result as a constraint on the spectral sparsity.
[0021] The weighted sum of the temporal reconstruction error and the spectral sparsity constraint is used as the parameter optimization objective of the implicit neural spectral network.
[0022] Furthermore, the parameter optimization employs a two-stage hot-start acceleration strategy, including:
[0023] In the offline phase, a training task set containing different harmonics is constructed, and the general initialization parameters of the implicit neural spectrum network are obtained by training through a meta-learning algorithm. The training task set covers the operating conditions of fundamental frequency fluctuation, integer harmonics of different orders and amplitudes, interharmonics of different frequencies and amplitudes, and the total number of different harmonic components.
[0024] During the online phase, the parameters of the multiple signal segments are optimized sequentially in a sliding window order. The parameter optimization of the first signal segment starts with the general initialization parameters, and the parameter optimization of the remaining signal segments starts with the parameters of the previous signal segment after convergence.
[0025] Furthermore, the precise frequency positioning of each harmonic component on the continuous spectrum function includes two steps: coarse positioning and fine positioning, wherein:
[0026] The coarse positioning is to uniformly sample the continuous spectrum function at a preset interval and calculate the power spectrum value of each sampling point, and take the local maxima points where the power spectrum value exceeds the preset power threshold as candidate spectral peaks.
[0027] The precise positioning involves calculating the derivative of the power spectrum with respect to frequency in the neighborhood centered on each candidate spectral peak, updating the frequency value iteratively through gradient ascent, stopping the iteration when the absolute value of the derivative is less than a preset convergence threshold, and using the converged frequency value as the precise frequency of the harmonic component.
[0028] Furthermore, the method also includes classifying each harmonic component into harmonic types, the classification including:
[0029] The precise frequency corresponding to the harmonic component with the largest power spectral value among all harmonic components is taken as the fundamental frequency.
[0030] For each harmonic component, calculate the ratio of its precise frequency to the fundamental frequency, and then round the ratio to obtain an integer value.
[0031] Calculate the absolute value of the difference between the ratio and the integer value. When the absolute value is less than a preset classification threshold, classify the harmonic component as an integer harmonic and use the integer value as the harmonic number of the harmonic component. When the absolute value is greater than or equal to the preset classification threshold, classify the harmonic component as an interharmonic.
[0032] Write the harmonic type, harmonic order, and precise frequency of interharmonics for each harmonic component into the parameter table.
[0033] Furthermore, a convolutional kernel network is constructed for each harmonic component. This convolutional kernel network is a fully connected feedforward network, comprising an input layer, a hidden layer, and an output layer connected sequentially, wherein:
[0034] The input layer uses sinusoidal position coding to map the scalar frequency offset into a high-dimensional vector with a preset coding dimension.
[0035] The hidden layer has two layers, and the number of neurons in each layer is the same as the encoding dimension. Each layer receives the output of the previous layer in sequence and uses a sinusoidal activation function.
[0036] The output layer is a single neuron, and a linear mapping is used to map the output of the last hidden layer to scalar convolution weights.
[0037] Furthermore, the optimization objectives for training convolutional kernel networks include passband constraints, stopband constraints, and smoothness constraints, among which:
[0038] The passband constraint is that the output of the convolutional kernel network is equal to 1 at a frequency offset of zero.
[0039] The stopband constraint is to constrain the output of the convolutional kernel network to approach zero at frequency offsets of other harmonic components relative to the current harmonic component.
[0040] The smoothing constraint is to calculate the derivative of the output value of the convolutional kernel network with respect to the frequency shift, and then regularize the derivative.
[0041] Furthermore, in the process of obtaining multiple signal segments, no window function weighting is applied to each signal segment, and the complete time-domain information of each signal segment is directly used for parameter optimization of the implicit neural spectrum network.
[0042] A harmonic extraction system based on frequency domain convolution is provided for implementing the aforementioned harmonic extraction method based on frequency domain convolution. The system includes:
[0043] The signal preprocessing module is used to preprocess and segment the acquired power grid signals to obtain multiple signal segments;
[0044] The spectrum fitting module is used to construct an implicit neural spectrum network. It optimizes the parameters of the implicit neural spectrum network with the time-domain reconstruction error of the multiple signal segments as the optimization target, and obtains the continuous spectrum function corresponding to each signal segment.
[0045] The spectral positioning module is used to locate the precise frequency of each harmonic component on the continuous spectral function, and to obtain the amplitude and phase of each harmonic component based on the complex spectral values at the precise frequency.
[0046] The frequency domain convolution separation module is used to construct and train a convolution kernel network for each harmonic component based on the precise frequency of each harmonic component, and multiply the continuous spectrum function with the output of each trained convolution kernel network point by point in the frequency domain to obtain the continuous spectrum after separation of each harmonic component.
[0047] The time-domain reconstruction and output module is used to perform inverse Fourier transform on the continuous spectrum after the separation of each harmonic component, reconstruct the time-domain waveform of each harmonic component, and generate a parameter table based on the precise frequency, amplitude and phase.
[0048] Compared with the prior art, the beneficial effects of the present invention are:
[0049] 1. This invention fits a continuous spectral function using an implicit neural spectral network and optimizes the spectral representation in reverse by constraining time-domain reconstruction error and spectral sparsity. This avoids spectral leakage and peak shift caused by the traditional FFT discrete frequency grid, making the extraction of frequency, amplitude and phase of interharmonics and dense harmonics more accurate.
[0050] 2. This invention locates precise spectral peaks on a continuous spectral function through gradient optimization, and constructs a frequency domain convolutional kernel network for each harmonic component for adaptive separation, which can reduce the aliasing effect between adjacent harmonics; at the same time, it combines two-stage hot start to accelerate parameter optimization, reducing the overhead of online fitting iteration, and meeting the requirements of real-time power quality monitoring and compensation control. Attached Figure Description
[0051] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0052] Figure 1 A schematic diagram illustrating an application scenario of the harmonic extraction system based on frequency domain convolution provided in an embodiment of the present invention;
[0053] Figure 2 A schematic flowchart of the harmonic extraction method based on frequency domain convolution provided in an embodiment of the present invention;
[0054] Figure 3 This is a schematic diagram of the harmonic extraction system based on frequency domain convolution provided in an embodiment of the present invention. Detailed Implementation
[0055] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0056] Example 1
[0057] Please see Figure 1 This invention provides a harmonic extraction system and method based on frequency domain convolution, which can be applied to scenarios such as new energy grid connection, centralized access of power electronic loads, and online monitoring of power quality. Figure 1 In this system, multiple grid connection points are set on the main grid bus. Distributed grid-connected power supply units, nonlinear loads, and signal acquisition branches are connected to the main grid bus through their corresponding grid connection points. The distributed grid-connected power supply units include photovoltaic arrays, photovoltaic inverters, and wind power converters or other new energy converters. The nonlinear loads include rectifiers or power electronic loads. Voltage transformers and current transformers collect voltage and current signals from their corresponding grid connection points on the main grid bus and send the collected signals to a data acquisition unit. The data acquisition unit inputs the collected voltage and current signals into a harmonic extraction system based on frequency domain convolution. The harmonic extraction results output by the harmonic extraction system based on frequency domain convolution can be provided to a power quality monitoring platform for index evaluation or to an active power filter or compensation controller to generate compensation reference quantities.
[0058] In the aforementioned application scenarios, harmonic problems do not originate solely from fixed-frequency disturbances in a single device, but rather from the combined effects of multiple converters, inverters, and nonlinear loads. Especially when power electronic devices such as wind power, photovoltaics, and energy storage are operating in parallel, differences in switching frequencies, modulation methods, control parameters, and operating conditions among these devices result in the grid signal containing not only conventional integer harmonics but also a large number of interharmonics whose frequencies are not integer multiples of the fundamental frequency. These interharmonics are often distributed near integer harmonics or between multiple harmonic components, with small frequency intervals, and their amplitudes may dynamically fluctuate with changes in grid-connected power, load status, and control strategies, thus forming a dense, interlaced, and time-varying spectral structure.
[0059] Commonly used harmonic extraction methods in this field are typically based on Fast Fourier Transform (FFT). They obtain spectral results by windowing, zero-padding, or increasing the number of sampling points on the sampled signal, and then identify spectral peaks and estimate harmonic parameters on a discrete frequency grid. This approach yields relatively stable detection results when integer harmonics dominate and their frequencies are synchronized with the sampling window. However, in interharmonic or dense harmonic scenarios, the detected frequency usually does not fall precisely on the discrete frequency grid, and harmonic energy diffuses to adjacent frequency points, causing spectral leakage. When the interval between adjacent harmonics is small, the main lobes and side lobes of different components further overlap, leading to peak position shifts, amplitude estimation distortion, and unstable phase extraction. Even when using window functions to suppress side lobes, the widening of the main lobe reduces frequency resolution. While zero-padding increases the number of displayed frequency points, it essentially only interpolates the existing discrete spectrum and does not address the limitation of the original frequency information.
[0060] Based on the above understanding, this embodiment does not continue post-processing on the discrete FFT spectrum, but transforms the harmonic extraction problem of the power grid signal into a problem of spectral function fitting, peak search, and component separation in the continuous frequency domain. Specifically, after the acquired signal is preprocessed and segmented by sliding window, instead of using a fixed frequency grid as the sole basis for harmonic parameter estimation, an implicit neural spectral network with frequency values as input and corresponding complex spectral values as output is used to construct a continuous spectral function that can be queried at any frequency position. Subsequently, the precise frequency of each harmonic component is determined on this continuous spectral function through coarse peak localization and gradient fine localization, and the amplitude and phase are obtained based on the complex spectral values at the precise frequency. Furthermore, to address the problem of dense harmonics being close to each other and causing separation difficulties, this embodiment constructs a frequency domain convolution kernel adapted to the frequency position of each harmonic component, allowing the target harmonic frequency to pass through while suppressing other located harmonic frequencies, thereby completing the adaptive separation of each component in the continuous frequency domain.
[0061] Therefore, the technical concept of this embodiment originates from the practical difficulties in online power system monitoring, such as continuously changing frequencies, densely interwoven harmonic components, and the inaccuracy of traditional discrete spectra. Its core lies in transforming the harmonic spectrum from a discrete grid representation to a continuously differentiable representation, and performing parameter estimation and frequency domain separation on a continuous frequency axis. This method can avoid the positioning errors caused by interharmonics falling into grid gaps, and can provide more accurate harmonic frequency, amplitude, phase, and component waveforms for subsequent active filter compensation, power quality assessment, and interharmonic-specific analysis.
[0062] Please see Figure 2 The present invention provides an embodiment of a harmonic extraction method based on frequency domain convolution, the specific steps of which are as follows:
[0063] S1: The collected power grid signals are preprocessed and segmented to obtain multiple signal segments.
[0064] In this embodiment, the grid signal can be a voltage signal, current signal, or a combination thereof collected from the grid connection point, bus side, or load access point. The signal source can be a voltage transformer, current transformer, Hall sensor, sampling resistor, or other acquisition device that meets the accuracy requirements of power quality analysis. Those skilled in the art will understand that the specific type of acquired signal, sampling frequency, and number of sampling channels can be configured according to the actual grid connection scenario, the detection object, and compensation control requirements, as long as it can reflect the minimum operating state of the grid to be analyzed. This application does not impose further limitations.
[0065] After obtaining the original sampled signal, it is first subjected to conventional preprocessing such as anti-aliasing low-pass filtering, outlier sampling point removal, amplitude normalization, or range conversion to reduce the impact of sampling noise, range drift, and high-frequency aliasing components on subsequent spectrum fitting. For sampled signals containing DC bias, mean removal processing can also be performed before or after segmentation to ensure that subsequent spectrum modeling mainly revolves around the AC component, avoiding the formation of excessively strong spectral peaks in the low-frequency region by the DC component, which would affect the identification of weak interharmonics.
[0066] Subsequently, the preprocessed power grid signal is segmented using a sliding window according to a preset window length and step length. The window length can be determined based on the fundamental period, the lowest frequency to be detected, and the online processing delay requirements. For example, a single signal segment can cover multiple fundamental periods to ensure that each signal segment contains sufficient periodic information. Overlapping regions can be set between adjacent signal segments to maintain the temporal continuity of adjacent detection results. Unlike traditional FFT harmonic analysis, in this embodiment, after segmentation, it is not necessary to apply weighting functions such as Hanning windows, Hamming windows, or Blackman windows to the signal segments. Instead, the complete time-domain sampled values of the signal segments are retained. The reason for this approach is that this embodiment does not directly extract harmonics by reading spectral lines on a discrete frequency grid. Instead, it performs inverse fitting of the time-domain signal using a subsequent continuous frequency spectrum function. If an additional window function is introduced, although it can reduce the sidelobes of the traditional discrete spectrum, it will also change the original time-domain amplitude relationship and widen the main lobe, which is not conducive to the differentiation of dense harmonic components. Therefore, this step, through low-distortion preprocessing and complete segmentation, provides an input basis that is closer to the real power grid waveform for subsequent continuous frequency domain modeling.
[0067] S2: Construct an implicit neural spectrum network with frequency as input and complex spectral values at that frequency as output. Optimize the parameters of the implicit neural spectrum network with the time-domain reconstruction error of the multiple signal segments as the optimization objective to obtain the continuous spectrum function corresponding to each signal segment.
[0068] In this embodiment, an implicit neural spectral network is constructed for each signal segment. This network receives continuous frequency values as input and outputs a complex spectral value at that frequency location. This complex spectral value can be represented by its real and imaginary parts. In other words, the network learns not discrete spectral values at fixed FFT points, but a continuous spectral function that can be queried at any position within a frequency range. The frequency range of this continuous spectral function can be determined based on the sampling frequency and the actual harmonic analysis range, for example, a single-sided frequency range between zero frequency and the Nyquist frequency.
[0069] To enable the network to distinguish harmonic components with small adjacent distances, sinusoidal position encoding can be applied to the input scalar frequency values, mapping the one-dimensional frequency values to a high-dimensional feature space. The hidden layers can employ sinusoidal activation functions or other nonlinear functions suitable for representing periodic signals, while the output layer uses a linear mapping to provide the real and imaginary parts of the spectrum. Those skilled in the art will understand that parameters such as the number of network layers, neurons, encoding dimension, optimizer type, and learning rate can be adjusted according to the computing platform and real-time requirements, as long as the network has the ability to represent sharp spectral peaks and differences between adjacent peaks.
[0070] In the parameter optimization process, instead of using the FFT spectrum as a supervision label, the constraint is based on the Fourier transform relationship between the spectrum and the time-domain signal. Specifically, several integration nodes are set within a continuous frequency range, the network output spectrum value at each integration node is read, and the time-domain waveform of the corresponding signal segment is reconstructed through numerical integration. Then, the error between the reconstructed waveform and the actual sampled waveform is calculated as the time-domain reconstruction error. Thus, the optimization process of network parameters essentially involves deducing the continuous spectral function that can explain the signal from the original time-domain sampled signal, avoiding the rasterization error introduced by performing discrete FFT followed by post-processing.
[0071] Furthermore, considering that power grid harmonic signals are typically formed by the superposition of a finite number of integer harmonics and interharmonics, and their spectrum exhibits sparse characteristics, spectral sparsity constraints can be incorporated into the optimization objective. This allows energy to be more concentrated near a few spectral peaks, suppressing noise floor and spurious diffuse spectra. Through the combined effect of time-domain reconstruction error and spectral sparsity constraints, the resulting continuous spectral function maintains consistency with the original sampled signal while forming a clear spectral structure that facilitates peak identification, thus alleviating the leakage and aliasing problems caused by traditional discrete frequency grids at the representation level.
[0072] S3: Locate the precise frequency of each harmonic component on the continuous spectrum function, and obtain the amplitude and phase of each harmonic component based on the complex values of the spectrum at the precise frequency.
[0073] In this embodiment, after fitting the continuous spectrum function, dense sampling is first performed on the continuous spectrum function at preset frequency intervals. The power spectrum value corresponding to each sampling frequency position is calculated, and candidate spectral peaks are obtained by judging local maxima, power threshold, or noise floor adaptive threshold. These candidate spectral peaks are used to provide the approximate frequency positions of harmonic components, and their function is similar to the initial search value, rather than the final frequency estimation result. Therefore, the sampling interval for coarse positioning can be determined according to the computational load and the density of spectral peaks, as long as the main spectral peaks are not missed.
[0074] After the candidate spectral peaks are determined, fine localization is performed within their neighborhood based on a continuous spectral function, centered on each candidate peak. Since the spectral function expressed by the implicit neural spectral network is continuous and differentiable on the frequency axis, the derivative of the power spectrum with respect to frequency can be calculated. Gradient ascent, Newton iteration, or other one-dimensional extremum search methods can then be used to gradually move the frequency value to a local maximum position in the power spectrum. Compared to traditional FFT, which can only read peaks on a discrete frequency grid, the fine localization process in this embodiment searches for the true spectral peak position on a continuous frequency axis. Therefore, it is not directly limited by a fixed frequency resolution, making it particularly suitable for situations where interharmonics fall between two traditional FFT frequency points or where adjacent harmonic components are closely spaced.
[0075] After obtaining the precise frequencies of each harmonic component, the real and imaginary parts of the continuous spectrum function output are directly read at these precise frequencies, and the amplitude and phase of the corresponding harmonic component are calculated accordingly. For single-sided spectrum representations, amplitude correction can be performed based on the conversion relationship between single-sided and double-sided spectra; for phase results, normalization can be performed according to the phase interval required for power quality analysis or compensation control. If necessary, the low-frequency peak with the highest power can be taken as the fundamental frequency, and it can be divided into integer harmonics or interharmonics based on the ratio of each component frequency to the fundamental frequency. Through this step, a parameter basis containing precise frequency, amplitude, phase, and harmonic type can be obtained, providing a reliable basis for subsequent frequency domain separation and time domain reconstruction.
[0076] S4: Based on the precise frequency of each harmonic component, construct and train a convolutional kernel network for each harmonic component with frequency offset as input and convolution weight as output. Multiply the continuous spectrum function with the output of each trained convolutional kernel network point by point in the frequency domain to obtain the continuous spectrum after separation of each harmonic component.
[0077] In this embodiment, after obtaining the precise frequencies of each harmonic component, the spectrum is not directly truncated using a fixed-bandwidth filter. Instead, a convolutional kernel network is constructed for each harmonic component. The convolutional kernel network takes a frequency offset as input, that is, the offset of the current frequency position relative to the precise frequency of the target harmonic, and outputs the convolution weights corresponding to that frequency position. The advantage of using a frequency offset as input is that the center of the convolutional kernel always moves with the precise frequency of the target harmonic, rather than being limited to a preset integer frequency point or a fixed filter center frequency. This allows it to adapt to fluctuations in the fundamental frequency, drift in interharmonic frequencies, and changes in the spacing between different components.
[0078] The training of convolutional kernel networks can be carried out around three objectives: passband preservation, stopband suppression, and smooth transitions. For the frequency offset position corresponding to the target harmonic, the convolution weights approach one to ensure that the amplitude and phase of the target harmonic are not significantly weakened after separation. For the frequency offset positions corresponding to other located harmonic components, the convolution weights approach zero to suppress leakage of adjacent harmonics or other interfering components. At the same time, a smoothing constraint is applied to the gradient of the convolution weights as a function of frequency to avoid unnecessary violent oscillations in the frequency domain and reduce the introduction of new pseudo-frequency components during the separation process.
[0079] After training, the continuous spectral function is multiplied point-by-point in the frequency domain with the output of the convolution kernel corresponding to each target harmonic to obtain the continuous spectrum after separation of the target harmonic component. Since the multiplication operation occurs on the continuous spectral representation, the convolution kernel can form an adaptive weight distribution within the target spectral peak and its neighborhood, eliminating the need for pre-setting fixed passband widths and stopband boundaries as in traditional digital filters. For dense harmonic scenarios, if two spectral peaks are close together, the convolution kernel can automatically form a narrower or asymmetric suppression region based on their actual precise frequencies; if the peaks are far apart, it can maintain smoother transmission characteristics. Therefore, it is possible to reduce the mixing of adjacent components while preserving the target harmonic information, improving the separation reliability when integer harmonics and interharmonics are interleaved.
[0080] In practical implementation, a completeness check can be performed on the continuous spectrum after the components are separated. For example, the residual between the superposition result of all separated spectra and the original continuous spectrum function can be calculated. When the residual energy exceeds a preset ratio, peak detection can be re-executed, candidate peak thresholds can be adjusted, or the corresponding convolution kernel can be retrained to reduce the impact of missed peaks and over-separation on the results. This processing is a verification measure in engineering implementation, and its specific threshold can be set according to the detection accuracy and real-time requirements.
[0081] S5: Perform an inverse Fourier transform on the continuous spectrum after the separation of each harmonic component to reconstruct the time-domain waveform of each harmonic component, and generate a parameter table based on the precise frequency, amplitude and phase.
[0082] In this embodiment, an inverse Fourier transform is performed on the continuous spectrum after each harmonic component is separated to obtain the waveform of the corresponding harmonic component in the time domain. The inverse transform can be implemented using numerical integration, that is, several integration nodes are selected within a preset frequency range, and the reconstructed values at each time step are calculated based on the real and imaginary parts of the separated spectrum and the corresponding sine and cosine basis functions. For multiple consecutive signal segments obtained by sliding window processing, linear gradation, weighted averaging, or other smooth fusion methods can be used to splice them in the overlapping areas of adjacent signal segments to avoid abrupt changes between the reconstructed waveforms of each segment.
[0083] The reconstructed harmonic components' time-domain waveforms can be output by numbering according to harmonic order, interharmonic frequency, or energy magnitude. For active power filtering compensation scenarios, the time-domain waveforms of specific harmonic orders or designated interharmonics can be used as the basis for generating reference quantities for compensation current or compensation voltage. For power quality assessment scenarios, the component waveforms can be used to calculate indicators such as total harmonic distortion rate, harmonic content, interharmonic energy distribution, and frequency drift characteristics.
[0084] Simultaneously, a parameter table is generated based on the precise frequency, amplitude, and phase obtained from the aforementioned steps. This parameter table may include fields such as harmonic sequence number, precise frequency, amplitude, phase, harmonic type, integer harmonic order, interharmonic identifier, corresponding signal segment timestamp, and confidence level information. Those skilled in the art will understand that the parameter table fields can be added or removed according to subsequent power quality analysis, grid connection assessment, or compensation control interface requirements, as long as they reflect the basic frequency domain parameters of each harmonic component. Through the combined output of the time-domain waveform and the parameter table, this embodiment not only provides harmonic parameters for monitoring and evaluation but also component waveforms for real-time control, thereby completing a closed-loop process from continuous spectrum fitting, precise positioning, frequency domain separation to engineering output.
[0085] Preferably, in the process of obtaining multiple signal segments, no window function weighting is applied to each signal segment, and the complete time-domain information of each signal segment is directly used for parameter optimization of the implicit neural spectrum network.
[0086] For example, the acquired power grid signal, after being subjected to anti-aliasing low-pass filtering, removal of DC components, and amplitude range conversion, is truncated into multiple signal segments according to a fixed number of sampling points. Each signal segment retains its original sampling order, sampling amplitude, and sampling time interval, without being multiplied by edge attenuation weights such as Hanning window, Hamming window, or Blackman window. The length of the signal segment can be determined based on the fundamental period and the lowest frequency to be detected. For example, in a 50Hz power grid, a single signal segment preferably covers no less than 5 fundamental periods; when the sampling frequency is 10kHz, the signal segment length can be more than 1000 sampling points, corresponding to a time length of no less than 100ms. Adjacent signal segments can be set with an overlap rate of 50% to 75% to maintain time continuity; the higher the overlap rate, the smoother the harmonic state changes in adjacent signal segments, but the computational load increases accordingly. Those skilled in the art can select specific window lengths and overlap rates according to real-time requirements, processor computing power, and harmonic change rates, as long as each signal segment contains sufficient sampling information to characterize the fundamental wave and major harmonics.
[0087] The main purpose of applying a window function in traditional frequency domain analysis is to reduce sidelobe leakage caused by endpoint truncation when a finite-length signal is processed by Discrete Fourier Transform. However, the window function itself alters the amplitude contribution at both ends of the signal segment and introduces mainlobe widening in the frequency domain. In scenarios with dense distributions of integer harmonics and interharmonics, mainlobe widening makes adjacent spectral peaks more likely to overlap, and weak interharmonics may even be covered by the broadened mainlobe of neighboring strong integer harmonics, thereby reducing spectral line distinguishability. Therefore, in this embodiment, instead of pre-changing the amplitude structure of the signal segment through a window function, the complete time-domain sampled values are used as the constraint object for spectrum fitting, allowing the implicit neural spectrum network to directly learn the continuous spectrum function that can reconstruct the signal segment. In other words, the windowing process to suppress discrete spectral leakage is replaced by a continuous spectrum fitting process, preserving the amplitude information, phase continuity, and transient perturbation information at the signal endpoints without being weakened by edge attenuation weights.
[0088] Furthermore, when the complete time-domain information is incorporated into parameter optimization, each sampling point participates in the time-domain reconstruction error calculation according to its actual sampling time, and no artificial weights related to the window function are set between sampling points. For sampling segments with high noise, conventional preprocessing methods such as amplitude normalization, outlier limiting, or median filtering can be used to improve fitting stability. However, such processing does not change the relative time position of each sampling point within the signal segment, nor does it perform gradual weighting at the beginning and end of the signal segment. If short-term impulse noise exists in the actual acquisition environment, isolated abnormal sampling points can be removed before segmentation based on the amplitude mutation threshold. For example, points exceeding three times the standard deviation of the mean of several adjacent sampling points can be replaced with the neighborhood median. If the overall signal amplitude varies greatly with operating conditions, a single segment of signal can be normalized according to the rated voltage, current, or root mean square value of that segment, and restored to the actual dimensions when outputting harmonic parameters. The above processing method can reduce the interference of non-harmonic noise on network fitting, and avoid the amplitude attenuation and main lobe broadening caused by window function, thus making it more suitable for subsequent accurate peak localization and dense harmonic separation on continuous frequency axis.
[0089] Preferably, the implicit neural spectral network includes an input layer, a hidden layer, and an output layer, wherein:
[0090] The input layer employs sinusoidal position coding to map scalar frequency values to a high-dimensional space. The sinusoidal position coding includes multiple frequency scale parameters, with a fixed common ratio between adjacent frequency scale parameters. The minimum frequency scale parameter is determined based on the reciprocal of the sampling frequency, and the maximum frequency scale parameter is determined based on half of the sampling frequency. The hidden layer employs a sinusoidal activation function. The output layer employs a linear mapping to output the real and imaginary parts of the complex spectral values.
[0091] For example, the scalar frequency value input to the implicit neural spectral network is the query frequency point, whose value range can be limited to between zero frequency and the Nyquist frequency, where the Nyquist frequency is half of the sampling frequency. To avoid the input value spanning too large a range at different sampling frequencies from affecting network convergence, the query frequency value can be normalized first. For example, zero frequency can be mapped to 0, Nyquist frequency to 1, and intermediate frequencies can be mapped linearly to the range between 0 and 1. The normalized frequency values still maintain the relative positional relationship on the original frequency axis, only changing the numerical scale, which facilitates training and inference using a uniform range of network parameters.
[0092] Furthermore, sinusoidal position coding is used to expand a single frequency value into multiple sets of sinusoidal and cosine responses. Each set of responses corresponds to a frequency scale parameter, which determines the rate of change of the sinusoidal and cosine responses along the frequency axis. A smaller frequency scale parameter corresponds to a smoother change in the coded response, characterizing the overall change over a wider frequency band; a larger frequency scale parameter corresponds to a denser change in the coded response, enhancing the ability to distinguish between adjacent spectral peaks and local frequency shifts. The number of frequency scale parameters can be determined based on the harmonic density and computational resources, for example, 64 or 128 sets. Let the number of frequency scale parameters be M, and the minimum frequency scale parameter be... The maximum frequency scale parameter is Then the first Frequency scale parameters It can be represented as:
[0093]
[0094] in, , The common ratio is fixed. This is used to ensure that the encoding can cover the overall changes within the analyzed frequency band. The frequency is determined based on the Nyquist frequency and the target minimum frequency resolution interval. For example, when the sampling frequency is 10 kHz, the analysis frequency range is 0 to 5 kHz, and the target minimum frequency resolution interval is 10 Hz, the frequency value can be normalized to the Nyquist frequency and taken as... =1, =5000 / 10=500; If the number of frequency scale parameters M is 64, then the common ratio is fixed. =(500 / 1)^(1 / 63), approximately 1.10, thus yielding 64 frequency scale parameters that increase proportionally from low to high scale.
[0095] The reason for using a sinusoidal activation function in the hidden layer is that the harmonic signal of the power grid is essentially formed by the superposition of multiple periodic components, and its spectral changes also have obvious oscillations and peak structures. If a conventional piecewise linear activation function is used, a large number of layers or a wide network is usually required to approximate sharp spectral peaks; while the sinusoidal activation function can directly express periodic changes and has higher expression efficiency for narrow-band spectral peaks, dense spectral lines, and subtle fluctuations near interharmonics. The number and width of the hidden layer can be determined according to the computing platform, for example, set to 3 to 5 layers, with each layer containing 128 to 256 neurons; when the number of harmonic components is small and real-time requirements are high, a smaller width can be selected; when the interharmonics are dense and there are many weak components, the width of the hidden layer can be appropriately increased to enhance the ability to express spectral details. The network weights can be initialized with a uniform distribution suitable for sinusoidal activation to prevent the output of each layer from saturating prematurely in the early stage of training, thereby maintaining stable gradient updates.
[0096] The output layer uses a linear mapping to obtain two consecutive values, which are used as the real and imaginary parts of the complex spectrum at that frequency location, respectively. If the frequency... The real and imaginary parts at the point are respectively and Then the complex value of the spectrum at that frequency ,in The imaginary unit satisfies Power spectral density Spectral modulus phase , among which | | represents the modulus of the complex number. This is the arctangent function. Harmonic amplitudes can be calculated from the spectral magnitudes using the chosen one-sided spectrum or numerical integration normalization method. Under commonly used one-sided amplitude spectrum representations, the amplitudes of non-DC, non-Nyquist frequency components can be calculated as follows: Corrections are made. Linear output also allows the network to freely adjust the magnitude and sign of the complex spectral values during training based on the temporal reconstruction error, avoiding the compression of strong harmonic amplitudes or the submergence of weak interharmonics due to the amplitude limiting of the activation function at the output end, thereby ensuring that the continuous spectral function has a relatively complete amplitude and phase expression capability.
[0097] Preferably, the implicit neural spectral network is optimized using the temporal reconstruction error of the multiple signal segments as the optimization target, including:
[0098] S2.1: Set multiple integration nodes in the frequency range of the continuous spectrum function, reconstruct the time-domain signal by numerical integration of the complex spectrum values at each integration node, and calculate the mean square error between the reconstructed time-domain signal and the corresponding signal segment as the time-domain reconstruction error.
[0099] S2.2: Calculate the power spectrum value at each integration node, perform smooth binarization on each power spectrum value using the Sigmoid function, and use the mean of the smooth binarization result as the spectral sparsity constraint.
[0100] S2.3: The weighted sum of the temporal reconstruction error and the spectral sparsity constraint is used as the parameter optimization target of the implicit neural spectral network.
[0101] For example, the frequency range of the continuous spectrum function can be determined according to the sampling frequency, typically a single-sided frequency range between zero frequency and the Nyquist frequency. Integrator nodes are discrete frequency sampling locations used for approximate continuous integration within this frequency range; their number determines the numerical accuracy and computational complexity of the time-domain reconstruction. For a power grid signal with a sampling frequency of 10 kHz and an analysis frequency range of 0 to 5 kHz, 2048 to 4096 integrator nodes can be set. When the interharmonics to be identified are dense or the interval between adjacent spectral peaks is small, the number of integrator nodes can be appropriately increased to improve the fineness of the continuous spectrum function being read and constrained. The integrator nodes are preferably arranged at equal intervals to ensure consistent reconstruction accuracy across the entire analysis frequency band. If it is known that interharmonics are denser in a certain frequency band, local densification nodes can be added within that band, but the numerical integration weights corresponding to the densification nodes should be adjusted synchronously to avoid excessive influence of local frequency bands on the reconstruction results.
[0102] When reconstructing a time-domain signal using numerical integration, the implicit neural spectral network outputs the real and imaginary parts of the complex spectral values at each integration node. For any sampling time, the real part at each integration node is multiplied by the corresponding cosine basis function, and the imaginary part is multiplied by the corresponding sine basis function. These multiplications are then accumulated according to the numerical integration weights to obtain the reconstructed sample value at that sampling time. In other words, the reconstructed sample value is obtained by superimposing the contributions of the spectral components at each integration node at that sampling time. This process can be implemented using composite trapezoidal integrals, Simpson integrals, or other conventional numerical integration methods. In engineering implementation, composite trapezoidal integrals have the advantages of low computational cost and convenient parallel implementation, making them suitable for embedded GPU, DSP, or FPGA acceleration platforms. The time-domain reconstruction error is represented by the mean square error between the reconstructed amplitude and the original sampled amplitude. Its physical meaning is the interpretation deviation of the continuous spectral function for the current signal segment; the smaller the error, the closer the time-domain waveform obtained by the inverse transform of the continuous spectral function is to the true sampled waveform.
[0103] Furthermore, spectral sparsity constraints are used to ensure that the continuous spectral function conforms to the actual characteristics of the power grid harmonic spectrum. The power spectral value can be determined by the sum of the squares of the real and imaginary parts of the complex value of the spectrum at the corresponding integration node, which physically represents the energy intensity at that frequency. When performing sigmoid smoothing binarization on the power spectral value, a power threshold and temperature parameters need to be set. The power threshold is used to distinguish between effective spectral lines and noise floor, and its value can be determined based on the target minimum detectable harmonic content and the sampling noise level. For example, when it is necessary to retain weak harmonics with amplitudes of approximately 2% to 4.5% of the dominant component, since power is related to the square of the amplitude, the power threshold can be taken as 0.05% to 0.2% of the total power of that signal segment; when the noise floor is high, the power threshold should be higher than the noise floor statistics to avoid noise frequencies being misjudged as effective spectral lines. Temperature parameters are used to control the steepness of the binarization transition range. They can be determined based on the power threshold, and are usually taken as one-tenth to one-fifth of the power threshold, so that the frequency points near the power threshold still retain continuous and differentiable transition results, which facilitates stable gradient optimization.
[0104] The spectral sparsity constraint is the average of the smoothed binarization results of each integration node, which means penalizing the "percentage of effective energy points" within the frequency range. If the continuous spectral function generates diffuse energy over a wide frequency band, the smoothed binarization results of many integration nodes will approach 1, increasing the spectral sparsity constraint; if the spectral energy is concentrated near a finite number of spectral peaks, most integration nodes will approach 0, decreasing the spectral sparsity constraint. This constraint does not directly specify the exact number of harmonic components, but rather guides the network to form a small number of clear spectral peaks through soft constraints, avoiding the generation of a large number of false small spectral peaks in noisy frequency bands to reduce time-domain reconstruction errors.
[0105] The parameter optimization objective is obtained by weighting the temporal reconstruction error and the spectral sparsity constraint. The temporal reconstruction error ensures that the continuous spectral function accurately reconstructs the sampled signal, while the spectral sparsity constraint suppresses diffuse spectra that do not conform to the physical characteristics of harmonics. Weighting coefficients adjust the priority of these two factors, and their values can be determined based on the order of magnitude of the two types of loss terms in the early stages of training, ensuring that the spectral sparsity constraint has a constraining effect on the optimization objective. For example, the contribution of the spectral sparsity constraint to the initial optimization objective can be controlled between 1% and 10%, corresponding to a weighting coefficient typically between 0.01 and 0.1. Parameter updates can employ conventional optimization algorithms such as Adam, RMSProp, or stochastic gradient descent with momentum. The initial learning rate can be determined based on the stability of the loss descent, for example, starting from around 0.001. If the loss oscillates, the learning rate is reduced; if the loss descent is too slow, the learning rate is increased within a range that does not cause oscillations. The stopping condition can be determined based on the online processing latency and accuracy requirements. For example, when the relative decrease in the parameter optimization target of several adjacent iterations is less than a preset ratio, it indicates that the accuracy improvement brought by continuing iteration is already small, and optimization can be stopped. The preset ratio can be one ten-thousandth, or optimization can be stopped when the preset maximum number of iterations is reached.
[0106] Preferably, the parameter optimization employs a two-stage hot-start acceleration strategy, including:
[0107] A1: In the offline phase, a training task set containing different harmonics is constructed, and the general initialization parameters of the implicit neural spectrum network are obtained by training through a meta-learning algorithm. The training task set covers the operating conditions of fundamental frequency fluctuation, integer harmonics of different orders and amplitudes, interharmonics of different frequencies and amplitudes, and the total number of different harmonic components.
[0108] A2: During the online phase, the parameters of the multiple signal segments are optimized sequentially in a sliding window order. The parameter optimization of the first signal segment starts with the general initialization parameters, and the parameter optimization of the remaining signal segments starts with the parameters of the previous signal segment after optimization convergence.
[0109] In this embodiment, a two-stage hot-start acceleration strategy is used to reduce the iterative overhead of online fitting of continuous spectral functions. If each signal segment is optimized starting from random parameters, the implicit neural spectral network needs to relearn the frequency axis representation ability and spectral peak structure within the current signal segment, which can easily lead to too many convergence steps and local convergence instability when weak interharmonics are present. To address this, a set of general initialization parameters suitable for power grid harmonic scenarios is first trained offline, enabling the implicit neural spectral network to have the basic ability to represent integer harmonics, interharmonics, and frequency drift spectral peaks before starting online fitting. Then, in the online stage, the similarity between adjacent sliding window signals is utilized, and the converged parameters of the previous signal segment are used as the starting point of the current signal segment, so that the current signal segment only needs to be slightly modified for newly sampled content and minor changes in operating conditions.
[0110] For example, the training task set can consist of simulated signals, historical measured signals, or a combination of both. The simulated signals are generated according to the sampling frequency of the target sampling system; for example, a sampling frequency of 10kHz makes the Nyquist frequency reach 5kHz, which can cover the analysis requirements of higher-order harmonics and interharmonics in a 50Hz power grid. The single-segment length is 100ms to 200ms, based on the fact that this time length corresponds to 5 to 10 fundamental frequency cycles of a 50Hz power grid, preserving sufficient periodic information without causing excessive online processing delay. The fundamental frequency is randomly selected within the range of 49.5Hz to 50.5Hz to cover small frequency fluctuations during normal power grid operation. Integer harmonic orders are covered from the 2nd to the 50th, to cover common low- to high-order harmonics in power quality analysis; the amplitude is taken from 0.1% to 40% of the fundamental amplitude to simultaneously cover weak harmonics and strong distortion conditions. Interharmonic frequencies are randomly selected between zero and the Nyquist frequency, avoiding positions that completely overlap with already generated integer harmonics; interharmonic amplitudes are set to 0.05% to 10% of the fundamental amplitude to cover weak interharmonic detection and more significant interharmonic disturbances. The total number of harmonic components in each training task is set to 5 to 30, based on covering different spectral configurations from sparse to dense spectral lines. The signal-to-noise ratio of the training signal is randomly varied between 30 dB and 60 dB to cover common scenarios in field sampling, ranging from strong to low noise.
[0111] Furthermore, the meta-learning algorithm can be implemented using model-independent meta-learning methods or other gradient-based meta-training methods capable of learning initialization parameters. Each training task corresponds to a signal with different harmonic compositions. First, a small number of gradient updates are performed on the training task using the current initialization parameters to obtain temporary adaptation parameters. Then, the temporal reconstruction error and spectral sparsity constraints of the temporary adaptation parameters on the same task or similar task data are evaluated, and the initialization parameters are adjusted in reverse based on the evaluation results. After repeatedly executing this process, the resulting general initialization parameters are not optimal parameters for a specific fixed harmonic combination, but rather starting parameters with rapid adaptation capabilities. In engineering implementation, the number of inner-layer updates for each task is set to 3 to 5 times. This is because inner-layer updates are only used to verify the rapid adaptation capability of the initialization parameters; too few updates are insufficient to reflect the adaptation effect, while too many updates increase offline training overhead and weaken the training objective of rapid adaptation. The number of outer-layer training iterations is set to the order of thousands. This is because the training task set contains different combinations of frequencies, amplitudes, phases, and harmonic quantities, requiring multiple rounds of task sampling to ensure that the initialization parameters stably decrease towards the optimization objective on the verification task.
[0112] In the online phase, the acquired signals are processed segment by segment according to the sliding window time sequence. The first signal segment lacks adjacent historical segments as a reference, and is optimized by loading general initialization parameters. Starting from the second signal segment, due to the 50% to 75% overlap between adjacent signal segments, the preceding and following signal segments share some sampled data, and the fundamental frequency, main harmonic positions, and amplitudes are generally continuous. The proportion of the overlap area is determined based on the rate of change of harmonic states and the amount of online computation. 50% overlap ensures basic continuity between adjacent signal segments, while 75% overlap improves tracking smoothness under rapidly changing operating conditions but increases the number of calculations. For example, the first signal segment allows 30 to 50 gradient updates, while subsequent signal segments are limited to 10 to 15 gradient updates. This is because the first signal segment starts from the general initialization parameters and needs to complete the initial adaptation to the current operating condition's spectral structure, thus allowing for a larger number of updates; subsequent signal segments start from the convergence parameters of the previous signal segment, only needing to correct for newly added data in the sliding window and minor changes in operating conditions, thus reducing the number of updates. The number of updates can be determined based on the online processing delay and convergence curve, that is, under the premise of meeting the single-segment processing time limit, the parameter optimization target is made to enter a state of gradual decline. Through this processing method, the online computation load can be reduced while maintaining the accuracy of continuous spectrum fitting, making continuous frequency domain harmonic extraction more suitable for real-time power quality analysis and compensation control scenarios.
[0113] Preferably, the step of locating the spectral peak on the continuous spectrum function and solving for the precise frequency of each harmonic component through gradient optimization includes two steps: coarse location and fine location, wherein:
[0114] S3.1: The coarse positioning is to uniformly sample the continuous spectrum function at a preset interval and calculate the power spectrum value of each sampling point, and take the local maxima points where the power spectrum value exceeds the preset power threshold as candidate spectral peaks.
[0115] Specifically, while continuous spectrum functions can output complex spectral values at any frequency, directly performing extremum searches across all possible locations within the complete frequency range introduces a large amount of iterative computation and is susceptible to interference from low noise levels or minor local fluctuations. Coarse localization employs a uniform sampling method, first transforming the continuous frequency range into a dense set of candidate observation points, and then selecting locations with spectral peak characteristics from these observation points. The preset interval is not equivalent to the frequency resolution of a traditional FFT, but rather a query step size used to scan the continuous spectrum function; its value is determined based on the target minimum adjacent frequency interval and parallel computing capabilities. To ensure that the vicinity of the true spectral peak contains at least multiple scan points, the preset interval can be one-fifth to one-tenth of the target minimum adjacent frequency interval. For example, when the signal segment length is 100ms, the frequency interval of a traditional FFT is usually 10Hz. If the goal is to distinguish dense interharmonics with an interval of about 0.5Hz to 1Hz, the preset interval for coarse positioning can be 0.05Hz to 0.2Hz, so that there are multiple candidate observation points near each target spectral peak, reducing the probability of missing detection when the spectral peak falls between adjacent scanning points.
[0116] In this embodiment, the power spectrum value of each sampling point is determined by the real and imaginary parts of the complex value of the spectrum at that frequency position. Specifically, it can be the sum of the squares of the real and imaginary parts, with units corresponding to the square of the input signal amplitude. The power spectrum value represents the energy intensity at that frequency position and is not directly output as the harmonic amplitude. A preset power threshold is used to distinguish between effective spectral peaks and noise floor, and can be determined by a fixed percentage threshold, an adaptive noise threshold, or a combination of both. For example, first, the maximum value of the power spectrum value and the estimated noise floor value are calculated across the entire frequency range. The estimated noise floor value can be the median of the lower percentile interval in the power spectrum value sequence. The lower percentile interval is used to avoid the influence of strong harmonic spectral peaks on noise estimation; for example, the median of the lower 60% of the data in the entire power spectrum value is taken. This proportion can exclude the main spectral peaks while retaining a sufficient number of background frequency points for statistics. Then, the dispersion of the lower percentile interval is calculated as the noise fluctuation amount. The preset power threshold can be the larger of 0.1% of the maximum power spectrum value and the noise floor estimate plus six times the noise fluctuation amount. Among them, 0.1% of the maximum power spectral value corresponds to an amplitude of approximately 3.2% of the maximum spectral peak amplitude, which is used to retain weaker harmonics; the noise floor estimate plus six times the noise fluctuation amount is used to make the candidate spectral peaks significantly higher than the background noise fluctuations, reducing the number of noise points that are misjudged as spectral peaks.
[0117] Furthermore, the determination of local maxima can be accomplished by combining neighbor point comparison and neighborhood preservation conditions. Specifically, the power spectrum value of a sampling frequency point can be compared with several sampling frequency points to its left and right. When the power spectrum value of this point is higher than all or most of the power spectrum values in its left and right neighborhoods, and is higher than a preset power threshold, it is marked as a candidate spectral peak. The neighborhood width can be determined according to a preset interval. For example, when the preset interval is 0.1Hz, 2 to 5 sampling points on each side can be taken as the local comparison neighborhood. For strong harmonics with wide spectral peaks, it can be appropriately expanded to 10 sampling points on each side to avoid multiple small fluctuations in the same main lobe being repeatedly marked. If multiple candidate spectral peaks appear in the same frequency neighborhood, a candidate spectral peak merging rule can be adopted: multiple candidate spectral peaks with a frequency distance less than a preset merging distance can be grouped into the same candidate group. The preset merging distance is determined based on the scanning interval and the minimum adjacent frequency interval of the target. It can be 3 to 10 times the preset interval for coarse positioning, allowing multiple candidate points generated by local fluctuations near the same spectral peak to be merged. Alternatively, it can be one-third of the estimated minimum adjacent harmonic interval, making the merging range smaller than the actual adjacent harmonic interval, avoiding the erroneous merging of two adjacent but actually independent harmonic components. Within the same candidate group, the frequency point with the largest power spectral value is retained as the candidate spectral peak center. Through threshold screening, neighborhood determination, and candidate peak merging, the coarse positioning result is compressed from densely sampled points into a limited number of candidate spectral peaks, providing a stable initial value for fine positioning.
[0118] S3.2: The precise positioning is as follows: for each candidate spectral peak, calculate the derivative of the power spectrum with respect to frequency in the neighborhood centered on the candidate spectral peak, update the frequency value through gradient ascent iteration, stop the iteration when the absolute value of the derivative is less than a preset convergence threshold, and take the converged frequency value as the precise frequency of the harmonic component.
[0119] Specifically, the candidate spectral peaks obtained from coarse localization are still limited by a preset interval, and their frequency positions are only scan points close to the true spectral peaks, and cannot be directly used as the final harmonic frequencies. Since the continuous spectrum function is expressed in the form of a neural network, when the frequency value is used as the network input, the relationship between the power spectrum and frequency can be obtained through automatic differentiation; on hardware platforms without an automatic differentiation framework, the central difference approximates the derivative in the neighborhood of the candidate spectral peak. The derivative represents the rate of change of the power spectrum along the increasing direction of the frequency axis. When the derivative is positive, it indicates that the power spectrum is still rising along the increasing direction of frequency; when the derivative is negative, it indicates that the current frequency has passed the local peak; when the derivative is close to zero and the power spectrum in the neighborhood shows a decreasing shape to both sides, it can be considered that the current frequency position is close to a local maximum. Fine localization utilizes this differentiable property to transform spectral peak localization from "scan point selection" to "solving local extrema on the continuous frequency axis".
[0120] In this embodiment, the candidate spectral peak frequency is used as the initial frequency value, and a search neighborhood is set for it. The half-width of the search neighborhood is determined based on the coarse positioning preset interval and the distance between adjacent candidate spectral peaks, and can be 2 to 5 times the coarse positioning preset interval. This is because expanding the search neighborhood to more than 2 times the preset interval can cover scanning errors and continuous spectrum fitting errors, while limiting the search neighborhood to within 5 times the preset interval can avoid the search range being too wide and attracting neighboring spectral peaks. For example, when the coarse positioning preset interval is 0.1Hz, the half-width of the search neighborhood can be 0.2Hz to 0.5Hz; when the distance between adjacent candidate spectral peaks is less than the above default neighborhood width, the search neighborhood boundary is limited to within the midpoint of adjacent candidate spectral peaks to prevent the fine positioning process of two adjacent spectral peaks from crossing each other. During gradient ascent iteration, the current frequency value is updated according to the direction of the power spectrum derivative, and the step size can be a fixed small step size or an adaptive step size. The fixed step size is determined based on the pre-set interval for coarse positioning, the target frequency output accuracy, and the search neighborhood width, and can be between 0.0001Hz and 0.01Hz. This is because 0.0001Hz meets the accuracy requirements for frequency fine-tuning after precise positioning, and 0.01Hz typically does not exceed one-tenth of the pre-set interval for coarse positioning (0.1Hz), thus preventing a single update from crossing the peak or jumping out of the local spectral peak region. The adaptive step size compares whether the power spectrum value increases after each update. If it increases, the step size is maintained; if it decreases, the step size is halved and the frequency is reverted to the previous value, ensuring that the iteration process always approaches the local peak.
[0121] Furthermore, the stopping conditions for fine positioning can be jointly limited by the absolute value of the derivative, the frequency update amount, the power spectrum change amount, and the maximum number of iterations. The preset convergence threshold for the absolute value of the derivative can be set according to the power spectrum normalization. For example, after normalizing the power spectrum to the maximum power spectrum value across the entire frequency band, the threshold for the absolute value of the derivative can be taken as one part per million to one part per ten million per hertz; the threshold for the frequency update amount can be taken as 0.0001 Hz to 0.001 Hz, based on the fact that this range is significantly smaller than the preset interval for coarse positioning and lower than the resolution required for general harmonic frequency parameter output; the threshold for the power spectrum change amount can be taken as the relative change in the power spectrum between two consecutive iterations being less than one part per hundred thousand. When any of the above stability conditions are met and the power spectrum in the small neighborhood on both sides of the current frequency point is not higher than the current power spectrum, the iteration stops, and the current frequency value is recorded as the precise frequency of that harmonic component. If convergence is not achieved after reaching the maximum number of iterations (e.g., 20 to 50 iterations), the point with the largest power spectral value among the visited frequency points in the neighborhood can be retained as the precise frequency, and this component can be marked with a lower confidence level. If multiple candidate spectral peaks eventually converge to the same frequency neighborhood (e.g., the distance between them is less than 0.01 Hz or less than one-tenth of the preset interval), this distance is significantly smaller than the coarse positioning scanning interval and the target minimum adjacent harmonic interval. This usually indicates that multiple candidate points originate from local fluctuations near the same spectral peak, rather than two independent harmonic components. In this case, they are merged into the same harmonic component, and the convergence result with the larger power spectral value is retained. After the precise frequency is determined, the complex spectral values can be read again at this frequency location to calculate the amplitude and phase, so that the harmonic parameters are no longer limited by the coarse positioning sampling interval. This is especially suitable for power grid signals where interharmonics are located between traditional FFT frequency points or where dense harmonics are distributed adjacently.
[0122] Preferably, the method further includes classifying each harmonic component into harmonic types, the classification including:
[0123] B1: The precise frequency corresponding to the harmonic component with the largest power spectral value among all harmonic components is taken as the fundamental frequency.
[0124] B2: For each harmonic component, calculate the ratio of its precise frequency to the fundamental frequency, and round the ratio to obtain an integer value.
[0125] B3: Calculate the absolute value of the difference between the ratio and the integer value. When the absolute value is less than the preset classification threshold, classify the harmonic component as an integer harmonic and use the integer value as the harmonic number of the harmonic component. When the absolute value is greater than or equal to the preset classification threshold, classify the harmonic component as an interharmonic.
[0126] B4: Write the harmonic type, harmonic order, and precise frequency of interharmonics for each harmonic component into the parameter table.
[0127] For example, the harmonic components participating in the classification are a set of effective components whose spectral peaks have been precisely located. Each effective component has at least a precise frequency, a complex spectral value, a power spectral value, an amplitude, and a phase. Since the DC component has been removed from the original signal, residual components near zero frequency are not considered as fundamental frequency candidates. For 50Hz or 60Hz power frequency scenarios, the effective fundamental frequency range can be set according to the rated power frequency, for example, 45Hz to 55Hz for a 50Hz power grid and 54Hz to 66Hz for a 60Hz power grid. If the power frequency type is not predetermined, the low-frequency main component with the largest power spectral value can be selected as the fundamental frequency from all effective components. If the rated power frequency is known, it is preferable to select the effective component with the largest power spectral value within the effective fundamental frequency range as the fundamental frequency, and record its precise frequency as the frequency reference for subsequent classification. This processing can avoid broadband noise, DC residuals, or high-frequency strong interference being mistakenly identified as the fundamental frequency, while retaining the ability of the fundamental frequency to shift slightly with the actual operation of the power grid, for example, using 49.92Hz instead of a fixed 50Hz as the fundamental frequency of the current signal segment.
[0128] Furthermore, when classifying any effective component, the precise frequency of the effective component is divided by the fundamental frequency to obtain a dimensionless frequency ratio. This frequency ratio represents the harmonic relationship of the effective component relative to the fundamental frequency. For example, a frequency ratio close to 5 indicates that the effective component may be the 5th harmonic; a frequency ratio of 5.36 indicates that it does not conform to an integer harmonic relationship and is more likely to be an interharmonic. The rounding operation can be performed by rounding to the nearest integer to obtain an integer value, which is used as a candidate harmonic order. For low-frequency components with a frequency ratio less than 1, they can be marked as subsynchronous interharmonics or low-frequency interharmonics depending on the detection object, and should not be forcibly classified as integer harmonics. For components with a frequency ratio greater than the preset maximum harmonic order, such as exceeding 50 or exceeding the maximum number of harmonics of actual concern, they can be written into the parameter table but marked as exceeding the conventional evaluation range so that the power quality evaluation process can call them as needed.
[0129] Preferably, a preset classification threshold is used to determine the degree of deviation between the frequency ratio and the candidate integer value, and its value is a dimensionless number. This threshold can be determined based on the fundamental frequency fluctuation range, frequency positioning error, and harmonic determination accuracy in power quality analysis standards. For example, the preset classification threshold can be between 0.01 and 0.02, preferably 0.015; when the fundamental frequency is 50Hz, 0.015 corresponds to an allowable deviation of approximately 0.75Hz for integer harmonics. If the error of the accurate frequency positioning result can be controlled within the order of 0.01Hz, and the on-site frequency fluctuation is small, the preset classification threshold can be set to 0.005 to 0.01 to improve the ability to distinguish between integer harmonics and adjacent harmonics; if the sampling environment has strong noise, a short signal segment, or a large dynamic drift of the fundamental frequency, the preset classification threshold can be appropriately relaxed to 0.02. The classification threshold should not be set too high, otherwise interharmonics located near integer harmonics may be mistakenly classified as integer harmonics; the classification threshold should also not be set too low, otherwise true integer harmonics affected by measurement errors may be misclassified as interharmonics.
[0130] In the actual classification process, the absolute deviation between the frequency ratio and the candidate integer value is first calculated. When the absolute deviation is less than the preset classification threshold, the effective component is classified as an integer harmonic, and the candidate integer value is written as the harmonic order. For example, if the fundamental frequency is 49.98Hz and the precise frequency of an effective component is 249.91Hz, its frequency ratio is approximately 5.000. After rounding, the candidate integer value is 5, and the absolute deviation is less than 0.015, so the effective component is classified as the 5th harmonic. When the absolute deviation is greater than or equal to the preset classification threshold, the effective component is classified as an interharmonic, and its precise frequency is retained as the primary identifier. For example, if the precise frequency of an effective component is 267.40Hz, its frequency ratio relative to the 49.98Hz fundamental frequency is approximately 5.350. After rounding, the candidate integer value is 5, and the absolute deviation is greater than 0.015, so the effective component is classified as an interharmonic. If two effective components are located near the same integer harmonic, and one of them meets the integer harmonic threshold while the other does not, then they are written into the parameter table separately to avoid merging interharmonics into integer harmonics due to their proximity in frequency.
[0131] Furthermore, the parameter table can record classification results by generating it segment-by-segment or updating it across signal segments. Each record includes at least the signal segment time identifier, component number, precise frequency, amplitude, phase, power spectrum value, harmonic type, harmonic order, and interharmonic identifier. For integer harmonics, the harmonic order field is written with the corresponding integer value, and the interharmonic identifier field can be empty or set to no. For interharmonics, the harmonic order field can be empty, set to 0, or written with the nearest integer order as a reference order, the interharmonic identifier field is written as yes, and the actual frequency value is retained in the precise frequency field. If multiple interharmonics exist within the same signal segment, they can be sorted from low to high precise frequency or from large to small power spectrum value. If used for compensation control, it is preferable to sort them from large to small power spectrum value to prioritize the processing of interharmonics with higher energy. Through the above classification and table writing rules, the parameter table can simultaneously serve both conventional integer harmonic evaluation and interharmonic-specific analysis, and will not cause distortion in harmonic order judgment due to slight shifts in the fundamental frequency.
[0132] Preferably, a convolutional kernel network is constructed for each harmonic component. This convolutional kernel network is a fully connected feedforward network, comprising an input layer, a hidden layer, and an output layer connected sequentially, wherein:
[0133] The input layer uses sinusoidal positional encoding to map scalar frequency offsets to a high-dimensional vector with a preset encoding dimension. The hidden layer has two layers, with the number of neurons in each layer being the same as the encoding dimension. Each layer receives the output of the previous layer in sequence and uses a sinusoidal activation function. The output layer is a single neuron and uses linear mapping to map the output of the last hidden layer to scalar convolution weights.
[0134] For example, the convolutional kernel network is configured in a one-to-one correspondence with the located harmonic components. For any target harmonic component, the precise frequency of the harmonic component is used as the center frequency of the convolutional kernel, and the difference between the frequency position to be processed and the center frequency of the convolutional kernel is used as the scalar frequency offset. The scalar frequency offset is in Hz, and its positive or negative sign indicates whether the frequency position to be processed is located on the high-frequency side or low-frequency side of the target harmonic frequency, and its absolute value indicates the distance of the frequency position from the center of the target spectral peak. In order to enable harmonic components at different frequency positions to share the same network structure, the scalar frequency offset can be scaled and normalized before being input into the convolutional kernel network. For example, the effective bandwidth of the convolutional kernel can be used as the normalization reference, mapping the target harmonic center position to 0, and mapping the area near the effective bandwidth boundary to around ±1. The effective bandwidth of the convolution kernel can be determined based on the precise frequency interval of adjacent harmonic components. When there are adjacent spectral peaks on both sides of the target harmonic, half the distance from the target harmonic to the nearest adjacent spectral peak frequency can be taken as the initial effective bandwidth. When the target harmonic is at the low-frequency end or the high-frequency end and there is an adjacent spectral peak on only one side, half the distance to the nearest adjacent spectral peak on that side can be taken, or a preset maximum bandwidth can be taken as the boundary. The preset maximum bandwidth can be set from 1Hz to 5Hz according to the power grid analysis accuracy, and from 0.5Hz to 2Hz in dense interharmonic scenarios, to avoid the convolution kernel covering too wide and introducing neighboring components.
[0135] Furthermore, sinusoidal positional encoding of the input layer is used to enhance the convolutional kernel network's ability to express frequency shift details. Since convolutional weights need to maintain passivity near the target harmonic center and suppress other harmonic frequencies, relying solely on a single scalar frequency shift directly input to the fully connected layer can make the network insensitive to small frequency differences. Sinusoidal positional encoding can expand the normalized frequency shift into multi-scale sine and cosine components, enabling the convolutional kernel network to simultaneously perceive wide-range attenuation trends and narrow-range local changes. The preset encoding dimension can be set to 64 dimensions, corresponding to 32 sets of sine and cosine codes; in scenarios with sufficient computational resources or small intervals between adjacent spectral peaks, it can also be set to 128 dimensions to enhance the expressive ability of narrowband suppression boundaries. The encoding scale parameter is preferably distributed geometrically, so that low-scale encoding is responsible for expressing the overall outline of the convolutional kernel, and high-scale encoding is responsible for expressing the weight details near the target spectral peak and adjacent spectral peaks. For implementation scenarios with a sampling frequency of 10kHz and an analysis frequency band of 0 to 5kHz, 64-dimensional encoding can usually meet the weight expression requirements of multiple dense inter-harmonic components.
[0136] Preferably, the hidden layers of the convolutional kernel network employ a two-layer fully connected structure, with the number of neurons in each layer consistent with the preset encoding dimension. Taking 64-dimensional encoding as an example, the first hidden layer receives a 64-dimensional encoding vector and outputs 64-dimensional hidden features, while the second hidden layer continues to output 64-dimensional hidden features. Each hidden layer uses a sinusoidal activation function, enabling the convolutional kernel network to express smooth but locally bendable frequency domain weight curves. The two-layer hidden structure achieves a balance between parameter quantity and expressive power: while a single-layer structure has lower computational cost, it is insufficient for fitting asymmetric weight contours, narrow stopband depressions, and multiple adjacent inhibition locations; too many hidden layers increase training time and online deployment complexity. With 64-dimensional encoding and two hidden layers, the number of parameters in a single convolutional kernel network is in the thousands to tens of thousands, allowing for parallel training or parallel inference across multiple harmonic components, and will not become the main computational bottleneck for continuous frequency domain separation.
[0137] The output layer consists of a single linear neuron, whose output value serves as the scalar convolution weight for the current frequency offset position. This scalar convolution weight is a dimensionless real number used to multiply with the complex spectral value of the continuous spectral function at the same frequency position, thus obtaining the retention ratio of the target harmonic component at that frequency position. When the convolution weight is close to 1, it indicates that the spectral component at that frequency position mainly belongs to the target harmonic and is retained; when the convolution weight is close to 0, it indicates that the frequency position is more likely to belong to other harmonics or noise components and is suppressed. The output layer uses a linear mapping instead of fixed activation limiting to allow for flexible adjustment of the weight shape during the training phase through constraints, avoiding gradient shrinkage due to activation function saturation in the initial training phase. In engineering implementation, the output weights can be pruned or normalized after the convolution kernel training is complete. For example, weights less than 0 can be truncated to 0, weights greater than 1 can be truncated to 1, or range limitation can be applied only before frequency domain multiplication to ensure that the separated continuous spectrum does not exhibit inverse gain or excessive amplification.
[0138] Furthermore, each convolutional kernel network is not built based on a fixed harmonic order, but rather on the precise frequency of the target harmonic. Therefore, the same network structure can be used for both integer harmonics and interharmonics. For integer harmonics, the center of the convolutional kernel shifts with the actual fundamental frequency. For example, when the fundamental frequency is 49.98Hz, the center of the 5th harmonic is based on the precisely located frequency, rather than being fixed at 250Hz. For interharmonics, the center of the convolutional kernel is directly set at its precise frequency, without needing to be forcibly assigned to a neighboring integer frequency. Multiple convolutional kernel networks can share the same structural parameter configuration, but each has independently trained network weights to form different frequency domain weight patterns based on the frequency interval between the target harmonic and adjacent components. When two harmonic components are close together, the corresponding convolutional kernel can form a narrower passing region; when the frequency range around the target harmonic is relatively open, the corresponding convolutional kernel can form a smoother retention region. Thus, the frequency domain separation process can adapt to complex spectral scenarios such as dense harmonics, interharmonic drift, and weak interharmonics accompanying integer harmonics.
[0139] Preferably, the optimization objectives for training convolutional kernel networks include passband constraints, stopband constraints, and smoothness constraints, wherein:
[0140] The passband constraint is that the output of the convolutional kernel network is equal to 1 at a frequency offset of zero; the stopband constraint is that the output of the convolutional kernel network at frequency offsets of other harmonic components relative to the current harmonic component approaches zero; the smoothing constraint is that the derivative of the output value of the convolutional kernel network with respect to the frequency offset is calculated and the derivative is regularized.
[0141] For example, passband constraints are used to prevent the target harmonic components from being weakened after convolution processing. For the target harmonic component to be separated, its precise frequency is taken as the center frequency of the convolution kernel, and the position where the frequency offset is zero corresponds to the center of the target spectral peak. When training the convolution kernel network, this position is used as the passband training point, and its target convolution weight is set to 1. In actual training, the difference between the output value of the convolution kernel network at this position and 1 can be calculated, and the difference is penalized by squaring. If there is a slight drift or a wide spectral peak near the target harmonic frequency, several passband auxiliary training points can be set near the zero offset. For example, 3 to 5 auxiliary points can be selected at equal intervals in the range of ±0.02Hz to 0.05Hz, and the target convolution weight of the auxiliary points can be set between 0.8 and 1, so that the convolution kernel forms a flat-top or nearly flat-top preservation region near the target spectral peak. The range of the passband auxiliary points should not exceed one-third of the distance to the nearest neighboring harmonic to avoid the passband region covering other harmonic components.
[0142] Stopband constraints are used to limit the suppression of located harmonic components other than the current target harmonic during convolution processing. For each non-target harmonic component, the frequency difference between its precise frequency and the precise frequency of the current target harmonic is calculated, and this frequency difference is used as a stopband training point input into the convolutional kernel network. The target convolution weight of the stopband training point is set to 0. If the power spectral value of a non-target harmonic component is high, or its frequency is close to the current target harmonic, the stopband training point has a greater impact on the separation result and can be assigned a higher stopband penalty weight. For example, the stopband penalty weight can be set to be positively correlated with the normalized result of the non-target harmonic power spectral value, and the nearest neighboring harmonic can be additionally multiplied by a proximity enhancement factor of 1.5 to 3 times. Here, 1.5 times is used to provide moderate enhancement when the power of the neighboring spectral peak is low or the frequency interval is large, and 3 times is used to increase the suppression strength when the power of the neighboring spectral peak is high or the frequency interval is small; this range can enhance the suppression effect of the neighboring strong spectral peak, while avoiding excessive stopband constraints that would destroy the passband fidelity of the target harmonic.
[0143] Furthermore, in dense spectral peak scenarios, if the frequency distance between the target harmonic and its adjacent harmonics is too small, passband and stopband constraints may simultaneously act at very close positions. To avoid excessively steep changes in the convolution kernel weight curve, the training point weights and effective bandwidth can be adjusted based on the distance between the target spectral peak and its nearest neighboring spectral peak. When the distance between the nearest neighboring spectral peaks is less than 0.5 Hz, the range of passband auxiliary training points can be narrowed, and the weight of the nearest neighboring stopband training points can be increased; when the distance between the nearest neighboring spectral peaks is greater than 2 Hz, the passband auxiliary range can be appropriately widened to make the spectrum near the target spectral peak smoother. If the distance between two spectral peaks is less than the preset minimum separable distance, for example, less than 5 times the upper limit of the fine positioning error of the continuous spectral function, and their power spectral peaks are unlikely to form independent maxima in the neighborhood, they can be marked as low-confidence separation objects, retaining their respective frequency parameters, but a low-confidence label is added to the component waveform output to indicate that the separation result may contain residual neighboring components.
[0144] Smoothing constraints are used to limit the oscillation of convolutional weights as they change with frequency offsets. Convolutional kernel networks have non-linear expressive capabilities; if trained solely on passband and stopband points, the network may experience sharp fluctuations between training points, leading to abnormal gains or negative weights at frequencies not covered by training. To avoid these abnormal fluctuations, smoothing sampling points can be uniformly selected within the effective bandwidth of the convolutional kernel, for example, 128 to 512 frequency offset points. The rate of change of the convolutional kernel output value relative to the frequency offset is calculated, and the squared mean of the rate of change is penalized. The number of smoothing sampling points is determined based on the effective bandwidth of the convolutional kernel, the density of spectral peaks, and computational cost. 128 sampling points can cover the main changes in a typical convolutional weight curve, while 512 sampling points are suitable for scenarios with a wide effective bandwidth. Increasing the number of sampling points usually only increases computational cost with limited improvement in the smoothing constraint effect. The rate of change can be obtained through automatic differentiation; in deployment environments that do not support automatic differentiation, the output difference between adjacent smoothing sampling points can be approximated by dividing by the frequency interval. The weight of the smoothing constraint can be set to 0.01 to 0.1, the overall weight of the stopband constraint can be set to 5 to 20, and the passband constraint, as the target fidelity constraint, maintains a high priority. The basis for these weight ranges is that the passband constraint is used to ensure the target spectral peak passes through and should be the primary constraint; the stopband constraint is used to suppress non-target spectral peaks; and the smoothing constraint is used to suppress oscillations between training points. For example, after normalizing each error term, a smoothing constraint weight of 0.01 to 0.1 allows it to play a regularization role without dominating training; a stopband constraint weight of 5 to 20 allows for stronger suppression of non-target harmonics without causing excessive shrinkage of the convolution kernel near the target spectral peak.
[0145] The training of the convolutional kernel network can be accomplished using the Adam optimizer or other first-order gradient optimization algorithms. The learning rate can be around 0.001. If the training objective increases for three consecutive iterations, the learning rate is adjusted to half of its original value. The number of iterations can be 50 to 100, with 50 iterations used for general spectral peak separation and 100 iterations used for cases where adjacent harmonics are dense or where constraints are strong. In each iteration, passband training points, stopband training points, and smoothing sampling points are input into the convolutional kernel network. The passband error, stopband error, and smoothing error are calculated separately, and then weighted and summed with a passband error weight of 1, a stopband error weight of 5 to 20, and a smoothing error weight of 0.01 to 0.1 to form the training objective and update the network parameters. The stopband error weight is determined based on the power and proximity of the non-target harmonics, and the smoothing error weight is determined based on the oscillation degree of the convolution weight curve. After training, the convolutional kernel network can be validated: the difference between the output value at a frequency offset of zero and 1 should not exceed 0.01, based on the fact that the target harmonic passing weight error should not exceed 1%, which will not significantly affect the target harmonic amplitude; the output value at each stopband training point should not exceed 0.05, based on the fact that the non-target harmonic passing weight should not exceed 5%, which can limit the residual of adjacent harmonics; the output value at the effective bandwidth boundary should not exceed 0.05, to avoid the preservation of spectral components outside the bandwidth boundary; the output difference between adjacent smoothed sampling points should not exceed 0.1, to avoid abrupt changes in the convolutional weight curve at locations without training points. If the above validation conditions are not met, the stopband constraint or smoothing constraint weights can be increased and retrained, or the effective bandwidth of the convolutional kernel can be reduced to reduce training conflicts. Before performing frequency domain separation, the trained convolutional weights can also be restricted to between 0 and 1, so that they represent the proportion of the original continuous spectrum preserved, avoiding negative weights or weights greater than 1 that cause phase flipping or amplitude amplification. Through the above training method, the convolutional kernel network can generate adaptive frequency domain weights based on the actual accurate frequency of each harmonic component, without relying on a fixed filter template, thereby adapting to the spectral structure of alternating integer harmonics and interharmonics.
[0146] Example 2
[0147] Please see Figure 3 One embodiment of the present invention provides a harmonic extraction system based on frequency domain convolution, the system comprising:
[0148] The signal preprocessing module is used to preprocess and segment the acquired power grid signals to obtain multiple signal segments;
[0149] The spectrum fitting module is used to construct an implicit neural spectrum network. It optimizes the parameters of the implicit neural spectrum network with the time-domain reconstruction error of the multiple signal segments as the optimization target, and obtains the continuous spectrum function corresponding to each signal segment.
[0150] The spectral positioning module is used to locate the precise frequency of each harmonic component on the continuous spectral function, and to obtain the amplitude and phase of each harmonic component based on the complex spectral values at the precise frequency.
[0151] The frequency domain convolution separation module is used to construct and train a convolution kernel network for each harmonic component based on the precise frequency of each harmonic component, and multiply the continuous spectrum function with the output of each trained convolution kernel network point by point in the frequency domain to obtain the continuous spectrum after separation of each harmonic component.
[0152] The time-domain reconstruction and output module is used to perform inverse Fourier transform on the continuous spectrum after the separation of each harmonic component, reconstruct the time-domain waveform of each harmonic component, and generate a parameter table based on the precise frequency, amplitude and phase.
[0153] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A harmonic extraction method based on frequency domain convolution, characterized in that, The method includes: The collected power grid signals are preprocessed and segmented to obtain multiple signal segments; An implicit neural spectrum network is constructed with frequency values as input and complex spectral values at that frequency as output. The parameters of the implicit neural spectrum network are optimized with the time-domain reconstruction error of the multiple signal segments as the optimization target to obtain the continuous spectrum function corresponding to each signal segment. The precise frequency of each harmonic component is located on the continuous spectrum function, and the amplitude and phase of each harmonic component are obtained based on the complex values of the spectrum at the precise frequency. Based on the precise frequency of each harmonic component, a convolutional kernel network with frequency offset as input and convolution weight as output is constructed and trained for each harmonic component. The continuous spectrum function is multiplied point by point in the frequency domain with the output of each trained convolutional kernel network to obtain the continuous spectrum after separation of each harmonic component. An inverse Fourier transform is performed on the continuous spectrum after the separation of each harmonic component to reconstruct the time-domain waveform of each harmonic component, and a parameter table is generated based on the precise frequency, amplitude and phase.
2. The harmonic extraction method based on frequency domain convolution according to claim 1, characterized in that, The implicit neural spectral network comprises an input layer, a hidden layer, and an output layer, wherein: The input layer uses sinusoidal position coding to map scalar frequency values to a high-dimensional space. The sinusoidal position coding includes multiple frequency scale parameters. The ratio between adjacent frequency scale parameters is a fixed common ratio. The minimum frequency scale parameter is determined according to the reciprocal of the sampling frequency, and the maximum frequency scale parameter is determined according to half of the sampling frequency. The hidden layer uses a sinusoidal activation function; The output layer employs a linear mapping to output the real and imaginary parts of the complex value of the spectrum.
3. The harmonic extraction method based on frequency domain convolution according to claim 2, characterized in that, The implicit neural spectral network is optimized by taking the temporal reconstruction error of the multiple signal segments as the optimization objective, including: Multiple integration nodes are set on the frequency range of the continuous spectrum function. The time-domain signal is reconstructed by numerical integration of the complex spectrum values at each integration node. The mean square error between the reconstructed time-domain signal and the corresponding signal segment is calculated as the time-domain reconstruction error. Calculate the power spectrum value at each integration node, and perform smooth binarization on each power spectrum value using the Sigmoid function. Use the mean of the smooth binarization result as a constraint on the spectral sparsity. The weighted sum of the temporal reconstruction error and the spectral sparsity constraint is used as the parameter optimization objective of the implicit neural spectral network.
4. The harmonic extraction method based on frequency domain convolution according to claim 3, characterized in that, The parameter optimization employs a two-stage warm-start acceleration strategy, including: In the offline phase, a training task set containing different harmonics is constructed, and the general initialization parameters of the implicit neural spectrum network are obtained by training through a meta-learning algorithm. The training task set covers the operating conditions of fundamental frequency fluctuation, integer harmonics of different orders and amplitudes, interharmonics of different frequencies and amplitudes, and the total number of different harmonic components. During the online phase, the parameters of the multiple signal segments are optimized sequentially in a sliding window order. The parameter optimization of the first signal segment starts with the general initialization parameters, and the parameter optimization of the remaining signal segments starts with the parameters of the previous signal segment after convergence.
5. The harmonic extraction method based on frequency domain convolution according to claim 1, characterized in that, Locating the precise frequencies of each harmonic component on the continuous spectrum function includes two steps: coarse positioning and fine positioning. The coarse positioning is to uniformly sample the continuous spectrum function at a preset interval and calculate the power spectrum value of each sampling point, and take the local maxima points where the power spectrum value exceeds the preset power threshold as candidate spectral peaks. The precise positioning involves calculating the derivative of the power spectrum with respect to frequency in the neighborhood centered on each candidate spectral peak, updating the frequency value iteratively through gradient ascent, stopping the iteration when the absolute value of the derivative is less than a preset convergence threshold, and using the converged frequency value as the precise frequency of the harmonic component.
6. The harmonic extraction method based on frequency domain convolution according to claim 5, characterized in that, The method further includes classifying each harmonic component into harmonic types, the classification including: The precise frequency corresponding to the harmonic component with the largest power spectral value among all harmonic components is taken as the fundamental frequency. For each harmonic component, calculate the ratio of its precise frequency to the fundamental frequency, and then round the ratio to obtain an integer value. Calculate the absolute value of the difference between the ratio and the integer value. When the absolute value is less than a preset classification threshold, classify the harmonic component as an integer harmonic and use the integer value as the harmonic number of the harmonic component. When the absolute value is greater than or equal to the preset classification threshold, classify the harmonic component as an interharmonic. Write the harmonic type, harmonic order, and precise frequency of interharmonics for each harmonic component into the parameter table.
7. The harmonic extraction method based on frequency domain convolution according to claim 1, characterized in that, A convolutional kernel network is constructed for each harmonic component. This convolutional kernel network is a fully connected feedforward network, comprising an input layer, a hidden layer, and an output layer connected sequentially, wherein: The input layer uses sinusoidal position coding to map the scalar frequency offset into a high-dimensional vector with a preset coding dimension. The hidden layer has two layers, and the number of neurons in each layer is the same as the encoding dimension. Each layer receives the output of the previous layer in sequence and uses a sinusoidal activation function. The output layer is a single neuron, and a linear mapping is used to map the output of the last hidden layer to scalar convolution weights.
8. The harmonic extraction method based on frequency domain convolution according to claim 7, characterized in that, The optimization objectives for training convolutional kernel networks include passband constraints, stopband constraints, and smoothness constraints, among which: The passband constraint is that the output of the convolutional kernel network is equal to 1 at a frequency offset of zero. The stopband constraint is to constrain the output of the convolutional kernel network to approach zero at frequency offsets of other harmonic components relative to the current harmonic component. The smoothing constraint is to calculate the derivative of the output value of the convolutional kernel network with respect to the frequency shift, and then regularize the derivative.
9. The harmonic extraction method based on frequency domain convolution according to claim 1, characterized in that, In the process of obtaining multiple signal segments, no window function weighting is applied to each signal segment, and the complete time-domain information of each signal segment is directly used for parameter optimization of the implicit neural spectrum network.
10. A harmonic extraction system based on frequency domain convolution, used to implement the harmonic extraction method based on frequency domain convolution as described in any one of claims 1 to 9, characterized in that, The system includes: The signal preprocessing module is used to perform low-pass filtering on the acquired power grid signal, divide it into sliding window segments according to a fixed window length, and remove the DC component to obtain multiple signal segments; The spectrum fitting module is used to construct an implicit neural spectrum network. It optimizes parameters with the time-domain reconstruction error and spectrum sparsity constraints of the multiple signal segments as optimization objectives to obtain the continuous spectrum function corresponding to each signal segment. The spectral line positioning module is used to locate spectral peaks on the continuous spectral function and solve for the precise frequency of each harmonic component through gradient optimization, and obtain the amplitude and phase of each harmonic component based on the complex spectral values at the precise frequency. The frequency domain convolution separation module is used to construct and train a convolution kernel network for each harmonic component based on the precise frequency of each harmonic component, and multiply the continuous spectrum function with the output of each trained convolution kernel network point by point in the frequency domain to obtain the continuous spectrum after separation of each harmonic component. The time-domain reconstruction and output module is used to perform inverse Fourier transform on the continuous spectrum after the separation of each harmonic component, reconstruct the time-domain waveform of each harmonic component, and generate a parameter table of each harmonic component based on the precise frequency, amplitude and phase of each harmonic component.