1. Introduction
In recent years, the integration of a large amount of renewable energy has posed significant challenges to power quality. In addition, the increasing penetration of power electronic devices, nonlinear loads, and electric vehicles has led to more frequent power quality disturbances [
1,
2,
3], with increasingly complex disturbance types. These disturbances have resulted in greater economic losses and safety risks for power users [
4]. Efficiently extracting the features of various power quality disturbances and accurately classifying them plays a critical role in the assessment and mitigation of power quality issues.
Time–frequency analysis is a fundamental technique for detecting power disturbance signals. Several signal processing-based time–frequency analysis methods have been applied in the field of power quality disturbance detection [
5], such as Short-Time Fourier Transform (STFT) [
6], Wavelet Transform [
7,
8], Hilbert Transform [
9], and S-Transform [
10,
11,
12], among others. Among these, the S-Transform (ST) can be viewed as a combination of STFT and Wavelet Transform. Its time–frequency matrix is highly effective in representing both time-domain and frequency-domain disturbance characteristics of power quality.
However, the conventional S-Transform (ST) relies on a Gaussian window whose standard deviation varies inversely with frequency, limiting its adaptability for diverse PQ disturbances. Alternatives such as Blackman [
13], Bohman [
14], and Kaiser windows [
15] can improve flexibility but sacrifice the Gaussian window’s superior time–frequency resolution [
16]. The Generalized S-Transform (GST) introduces modulation factors to adjust window width [
17,
18], yet lacks a systematic parameter-selection scheme and still underperforms over wide frequency spans. Multi-segment approaches further enhance local resolution by applying different Gaussian windows per band [
19,
20,
21,
22,
23], but their complex structures demand frequent parameter switching, increasing computational overhead and hindering simultaneous detection of composite disturbances [
24]. A concise solution that balances resolution, adaptability, and efficiency remains necessary.
Classification is the second key step, used to accurately assign each power quality (PQ) disturbance to its corresponding category. The performance of classification models generally depends on the dataset, the dimensionality of the dataset, and parameter tuning to avoid overfitting. Artificial Neural Networks (ANN) [
25,
26], Support Vector Machines (SVM) [
27], and Decision Trees (DT) [
28,
29] are among the most widely used classification models for PQ disturbance classification.
ANN-based classifiers have fast learning processes, and their weight adjustments do not require iteration, offering quick response times. This makes ANN classifiers widely used. However, they tend to perform slowly when classifying new disturbances, requiring a significant amount of training data and sometimes necessitating retraining, which limits their applicability in real-time systems. On the other hand, SVM has the advantage of a simple structure and can achieve good generalization with relatively few training samples. However, when there are many disturbance types, feature aliasing can lead to an increased error rate in classification. DT-based classifiers are relatively easy to implement, but their performance can be negatively affected by irrelevant data, and their classification accuracy decreases when dealing with more complex disturbance types.
In this paper, a method for detecting and classifying power quality disturbances based on improved adaptive S-transform and random forest is proposed. A global adaptive Gaussian window is constructed as the kernel function for IAST, accompanied by corresponding parameter selection and a fast calculation scheme. By applying IAST to quickly and accurately perform time–frequency analysis on power quality disturbances, four feature quantities that can characterize various types of power quality disturbances are extracted. On this basis, a random forest classifier is used to classify different disturbance signals. Due to the high efficiency of IAST, the efficiency of the random forest classifier is also guaranteed. Finally, the effectiveness of the method proposed in this paper is verified through experiments, and 16 types of power quality disturbance signals are generated. Results confirm that the proposed method accurately detects and classifies disturbances under both noise-free and noisy conditions. Its effectiveness for real-time PQ monitoring is validated by experiments, with future work focusing on field deployment.
2. Improved Adaptive S-Transform and Random Forest
2.1. Traditional ST and Other Improved ST
S-Transform is an invertible time–frequency analysis method. For any time-domain signal
x(
t), the definition of the S-Transform is given by the following equation:
The window function of ST is as follows:
The standard deviation of the Gaussian window is as follows:
where
represents the Gaussian window function of the S-Transform, and Equation (2) provides its explicit expression. The parameter
τ is the time-shifting factor that controls the position of the window in the time domain, while the standard deviation
is a function of the signal frequency
f.
From Equation (3), it can be seen that in the traditional S-Transform, the standard deviation of the window is inversely proportional to the frequency
f, which results in poor adaptability between the window and the detected signal, limiting the detection range. To increase the degree of freedom in controlling the window’s standard deviation, the generalized S-Transform (GST) was proposed in [
13]. The window function in GST is defined as
The GST introduces an amplitude stretching factor α and a frequency scaling factor β based on the structure of Equation (2), which enhances the flexibility of adjusting the time–frequency resolution. Considering the detection requirements of disturbance features, the goal is to achieve high time resolution when detecting low frequencies and high frequency resolution when detecting high frequencies. However, this method does not fundamentally change the inverse proportional relationship between window width and detection frequency. As the detection frequency increases, the window width narrows, and the trend of change in time–frequency resolution is opposite to the detection requirements, leading to a decrease in the accuracy of time–frequency feature extraction.
To address this issue and allow the window function to adapt to the time–frequency analysis requirements of disturbances across different frequency ranges, a dual-window detection method, the Double Resolution S-Transform (DRST), was proposed in [
15]. It is defined as
The DRST divides the frequency range of the disturbance signal into low-frequency and high-frequency regions, using different window width adjustment factors and for each region. This modification helps alter the fixed inverse proportional relationship between window width and frequency, thus improving the time–frequency resolution for disturbances in different frequency bands. However, this method increases the complexity of both the window function structure and the algorithm, leading to lower detection efficiency.
2.2. Improved Adaptive S-Transform
To improve the adaptability of the window function to disturbances across various frequencies, this paper proposes a globally adaptive Gaussian window, which has a single structure that meets the time–frequency analysis requirements of complex disturbances. It enables more efficient time–frequency transformations of disturbance signals.
In time–frequency signal analysis, there exists a fundamental trade-off between time and frequency resolution: a narrower analysis window yields better time resolution at the cost of frequency resolution, while a wider window improves frequency resolution but compromises time resolution. This trade-off makes it impossible to simultaneously achieve optimal resolution in both domains, which necessitates careful window design in time–frequency transforms. According to the Heisenberg uncertainty principle, a narrower window width provides higher time resolution but reduces frequency resolution. Conversely, a wider window width offers higher frequency resolution but reduces time resolution. It is impossible to achieve optimal time and frequency resolution simultaneously. To make the detection algorithm more efficient, the proposed window function maintains a single window structure, and its width is adaptively adjusted based on the standard deviation σ(f) for the detection frequency.
The designed window function is as follows:
where
represents the standard deviation of the Gaussian window, defined as
The standard deviation can be flexibly controlled by two window width adjustment factors
and
. By setting
to be less than 0 and combining it with
to ensure that the overall value
remains positive, the standard deviation
can be adjusted as described in Equation (7). As the detection frequency
f increases or decreases,
will increase or decrease accordingly, causing the window width to expand or contract. This approach ensures that as the detection frequency increases, the frequency resolution also improves, providing accurate frequency resolution for detecting oscillatory transients, harmonics, and other frequency-domain disturbances. On the other hand, it also ensures that a high time resolution is maintained at the fundamental frequency, allowing for precise monitoring of voltage amplitude changes and their occurrence time.
Figure 1 shows the time-domain window width and frequency spectrum of the adaptive Gaussian window.
As shown in
Figure 1a, when the standard deviation is 0.5, the effective window width in the time domain is relatively narrow. In contrast,
Figure 1b corresponds to a wider main lobe and lower amplitude side lobes, providing higher time resolution. As the detection frequency increases, the standard deviation increases to 1.5, causing the main lobe in the frequency response to narrow, thus providing high frequency resolution. Therefore, the proposed globally adaptive Gaussian window can meet the time–frequency analysis requirements of complex disturbances, while maintaining a low okcomplexity for the window function.
Based on the globally adaptive Gaussian window, the improved adaptive S-Transform is defined as
Using the convolution theorem and the inverse fast Fourier transform (IFFT), one can obtain the following:
where
is the Fourier transform of signal
following a frequency-domain shift of
.
From the characteristics of the different forms of S-Transforms discussed above, it can be seen that the IAST addresses the issues of poor time–frequency resolution in the generalized S-Transform and the complex window function structure with low detection efficiency in multi-resolution S-Transforms. The IAST is able to balance both the accuracy of the detection algorithm and its execution efficiency.
In this paper, the standard deviation of the Gaussian window is linearly defined as to ensure adaptive time–frequency resolution across a wide frequency band. Compared with traditional inverse proportional forms, the proposed linear formulation facilitates both time resolution at low frequencies and frequency resolution at high frequencies. Parameters λ1 and λ2 are determined by an energy concentration optimization scheme, balancing the trade-off between time and frequency resolution.
2.3. Parameter Selection and Fast Calculation Scheme
2.3.1. Parameter Selection Scheme
Currently, many methods lack a systematic basis for parameter selection and fail to fully consider the intrinsic properties of the detected signal, such as its time-varying frequency distribution and energy distribution characteristics (i.e., energy concentration), which are essential for accurate time–frequency localization. To address this, this paper proposes a parameter optimization scheme with the goal of enhancing the energy concentration of the IAST signal as an objective function, thereby improving both the energy concentration in signal detection and the adaptability between the window function and the signal.
The energy concentration [
30] applied to the improved adaptive S-Transform is defined as
where normalized IAST matrix is given by the following:
In time–frequency signal analysis, there exists a fundamental trade-off between time and frequency resolution: a narrower analysis window yields better time resolution at the cost of frequency resolution, while a wider window improves frequency resolution but compromises time resolution. This trade-off makes it impossible to simultaneously achieve optimal resolution in both domains. Therefore, while enhancing energy concentration, it is necessary to consider the trade-off between time and frequency resolution as a constraint. The parameter values under these conditions are key to ensuring that the window can adapt to complex disturbance signals.
The following constraints are set first:
In the equation,
represents the standard deviation of the global adaptive Gaussian window, and
and
determine the upper limits of time resolution and frequency resolution, respectively. For discrete signal sampling sequences,
can be replaced by
, where
is the sampling period of the signal and
n is an integer greater than or equal to 1. In this paper,
n is set to 5. Therefore, the left-hand side of Equation (12) can be converted into the following constraint condition:
where
<
f <
, with
determined by the detection signal based on the sampling theorem, and the minimum frequency
set to 1 Hz, Equation (13) is transformed into
Similarly, the right-hand side of Equation (12) can be transformed into constraint condition 2:
In this paper, the value of
u is set to 300, which results in
= 0.06. In addition to constraining based on time and frequency resolution, it is also necessary to impose reasonable limits on the parameters themselves to improve the speed of parameter optimization. The overall parameter optimization scheme is as follows:
The interior-point method is used to obtain parameter solutions that enhance energy concentration while balancing the trade-off between time–frequency resolution, resulting in satisfactory performance in composite disturbance detection. In the experiments, the optimized parameters a = –0.0016 and b = 21.84 yielded the highest energy concentration (ECM = 0.0046).
In this study,
n is set to 5 to ensure sufficient temporal resolution while maintaining computational efficiency, based on empirical testing and recommendations from related literature [
30]. Likewise, u is set to 300 to restrict the upper bound of
to 0.06, which ensures acceptable frequency resolution without degrading energy concentration.
2.3.2. Fast Calculation Scheme
For a disturbance signal with a length of
N points, the traditional ST has a time complexity of
. By utilizing the Fourier transform in the frequency domain, this can be reduced to
[
31]. However, based on reasonable parameter selection, most of the energy in the actual signal analysis is concentrated near the main frequency points. In contrast, the other frequency points mainly contain non-essential feature information, which still consumes a significant amount of computational resources. Therefore, in this paper, an automatic thresholding method based on the Fourier spectrum is used to filter out non-dominant frequency points, and time–frequency calculations are only performed on the dominant frequency points. An improved adaptive fast S-Transform (IAFST) is then constructed.
As an example, consider a signal that includes voltage sag and three different harmonic components with varying amplitudes. The principle of the automatic thresholding method is to first perform a Fourier transform on the disturbance signal to obtain its frequency spectrum, which allows for a preliminary assessment of the frequency distribution. Based on the characteristics of the actual disturbance signal, a threshold is set, and frequency components with amplitudes exceeding this threshold are defined as dominant frequency points. The remaining non-dominant frequency points are automatically filtered out. The basic process is shown in
Figure 2. In consideration of removing the impact of noise interference and the fact that some disturbance frequencies with short durations may have smaller spectral amplitudes, the threshold is set to 0.02 pu in this paper. Only the selected dominant frequency points are subjected to improved time–frequency analysis. For a signal of length
N, the time complexity of calculating all frequency points sequentially is
. However, the number of dominant frequency points
v determined by the automatic thresholding method is much smaller than
N, which reduces the time complexity of the IAST calculation to
.
Another advantage of using the automatic thresholding method is that there is no need to separately compute the Fourier spectrum, as the FFT of the disturbance signal is an inherent step in the S-Transform, thus further reducing the computational workload.
To reduce computation and support real-time feasibility, the discrete form of the IAFST algorithm is derived for efficient implementation. For an input signal with a sampling period
and a sampling length
N, the time variable
t and frequency
f in Equation (9) are discretized as
and
, respectively, where
m and
k are the indices of discrete time and discrete frequency. By calculating only the main frequency points, the discrete form of the IAFST can be expressed as
where
represents the main frequency points selected by the automatic thresholding method, while
m and
l range from 0, 1, 2, …,
N − 1 and
i ranges from 1, 2, …,
v. is the discrete form of
from Equation (9), and
represents the discrete Fourier transform of the adaptive Gaussian window. The detailed implementation flow of the IAFST algorithm is shown in
Figure 3.
2.4. Basic Principle of Random Forest
The random forest classification algorithm is a large ensemble classification model composed of multiple tree-based classification models. It is a combination of the Bagging algorithm and the random subspace method. The basic building block of random forest is the decision tree, and the fundamental principle is to improve the accuracy of classification predictions through the aggregation of multiple decision trees. Typically, the decision trees used in random forest are binary trees [
32]. The randomness in data sampling and the collective voting process of numerous decision trees ensure that random forest exhibits resistance to overfitting and achieves high accuracy. The basic principle is illustrated in
Figure 4. This paper combines IAST and RF for the detection and classification of power quality disturbances.