Wavelet Packet Transform Modulus-Based Feature Detection of Stochastic Power Quality Disturbance Signals

: Wavelet transform modulus (WTM) has been used to detect or localize transient signal discontinuities. A numerical analysis indicated that these power quality disturbance (PQD) events are extremely sensitive to the random phase offset due to shift-variant wavelet or wavelet packet characteristics, which have not been comprehensively discussed yet. In this paper, we deﬁne wavelet packet transform modulus (WPTM) and present a WPTM-based PQD feature detection that is robust to severe power signal channels including random phase offset and low signal-to-noise ratio ( ≤ 25 dB). The presented WPTM-based detection that exhibits an exponentially increased degrees of freedom ( DoF ) and has better correlation properties than existing WTM-based detection of a limited DoF (two or three). We then use a standard median ﬁlter to efﬁciently remove impulsive noise and add a threshold modiﬁcation step to reduce the false edge detection rate under random phase offset conditions while maintaining a reasonable detection rate. The proposed scheme uses the majority voting-based indirect correlation or root-mean-square metric between wavelet packet coefﬁcients, rather than the conventional wavelet denoising or correlation metric. For a reliable numerical analysis, the proposed scheme uses both double- and single-edge-based detection measures, and the results verify its superiority over the conventional wavelet-based, wavelet-correlation-based, or non-wavelet-based schemes.


1.
We define WPTM using WPC and propose a PQD feature detection (or localization) algorithm using WPTM-based metrics (such as RMS and MV). Hence, the presented WPTM-based PQD detection scheme, with larger degrees of freedom (DoF = 2 l − 1), exhibits better correlation properties than the existing WTM-based PQD detection schemes (DoF = two or three).

2.
For the WPTM-based PQD detection, we also define and use a modified threshold (TH M ) rather than a conventional universal threshold (TH U ), which makes it more robust to practically severe power signal conditions, including random phase offset and low SNR (≤25 dB) 3.
In the presented PQD detection procedure [see the details in Section 2.2], we add the SM plus wavelet filter-based adaptive denoising step after the pure power signal removal process (which follows the PQD feature strengthening process [7]), the socalled preprocessing stage, that effectively removes both impulsive noise and AWGN. Next, the proposed PQD detection stage using MV or RMS metric is executed. In particular, the MV metric uses the MV-based indirect correlation between WPCs instead of the conventional direct correlation between WCs.

4.
A numerical analysis is performed for the proposed scheme (Section 3) under random power signal conditions and compared with the existing schemes. For reliable PQD localization, double edge-based detection is used and compared with the conventional single edge-based detection. In the numerical evaluation, various standard PQD event signals, including voltage sag, voltage swell, interruption, harmonics, notch, and so on, are generated and tested based on IEEE-1159. In addition, we implement a power distribution network using MATLAB ® Simulink ® (Natick, MA, USA) to create several PQD events and test the proposed scheme for the PQD signals generated by the network, for further validating our proposed system model. Via the numerical analysis, we prove that the proposed scheme is superior to the conventional waveletbased, wavelet-correlation-based, or non-wavelet-based schemes.
FT extracts the frequency components of PQD event signals but does focus on the analysis of stationary signals [10]. STFT, also termed as windowed FT, overcame the limitations of FT by segmenting the signal into narrow time intervals; however, it cannot simultaneously provide suitable frequency and time resolutions [14]. In [15], PLL-based PQD detection was proposed; however, a small distortion of the mains voltage substantially degraded the detection performance. The authors in [3] presented an S-transform-based technique, where the denoising threshold was determined with the energy congregation level; however, this technique incurred a highly complex noise level estimation. In [16], the authors introduced HHT to detect and analyze PQDs, where MM was used to suppress the noise level. However, HHT is sensitive to the noise superimposed on an electric signal [17].
WT allows simultaneous signal localization in the time and frequency domains, which is a favorable characteristic for the analysis and detection of nonstationary transient signals [1, 4,18,19], such as PQD, as compared to the other schemes mentioned above, including FT and STFT [10,14]. Recently, Liao et al. showed that the spatial correlation between adjacent WCs is robust to nonlinear PQD signals over power signal channels [1]. WPT, which is an extended version of WT, allows the further decomposition of both high-frequency components (details) and low-frequency components (approximations) [7,13]. As the WPT output (i.e., WPCs) has larger degrees of freedom than the WT output (i.e., WCs), feature detection using WPCs exhibits a better spatial correlation property than waveletcorrelation-based-detection (WC-Det). Very recently, in [7], the authors presented a feature detection scheme using an MV-based indirect correlation. However, they used a universal threshold TH U for feature detection, which yields a large FER over severe power signal channels with random phase offset and impulsive noise.
In the present study, we extend our previous study [20] further by proposing an updated PQD detection algorithm that includes a preprocessing stage to make it more robust to severe power channel conditions like random phase ϕ m and low signal-to-noise ratio. Furthermore, we elaborate our previous study by adding an adaptive impulsive denoising function to the proposed algorithm, and thoroughly analyzing the presented system model under impulsive electricity channel conditions. With the help of numerical analysis, the proposed system model is proved to be superior to the conventional waveletbased, wavelet-correlation-based, or non-wavelet-based schemes.
The remainder of this paper is organized as follows. In Section 2, we briefly introduce the PQD signal model, address the proposed detection system model with adaptive denoising, explain WPT including how to decompose a PQD signal into different WPCs, define WPTM and WPTM-based metrics (MV and RMS), and present WPTM-based PQD feature detection using MV or RMS metric. Section 3 presents the numerical results of the proposed system model and a discussion on these results. Section 4 concludes the paper.

Signal Model
The occurrence of a single PQD event in a power grid can be a major cause of internal (or external) grid failure or severely damage various precision instruments, devices, equipment, and factories using the grid energy. Table 1 lists the several major PQD events that may often occur within the grid, such as sag, swell, harmonic, interruption, and notch.

Events PQD Event Signal Models Parameters
Sag Swell or Sag with harmonics 8 ms ≤ε ≤ 40 ms A power signal delivered through a power cable can be represented as where s(t) (= s 0 (t) [pure power source] +q(t) [distortion component]) is a PQD event signal and n(t) is an additive noise signal.
In the absence of any PQD event, that is, q(t) = 0, s(t) represents the standard (pure) sinusoidal electric power signal, that is, s(t) = s 0 (t) = A sin(ωt), where the peak value of the power signal A = 220 √ 2 V and its radian frequency ω = 2π f rad/s ( f = 1/T [=electric signal period] = 60 or 50 Hz). However, when a PQD event occurs, that is, q(t) = 0, s(t) = s 0 (t) + q(t), which becomes one of the PQD event signal models listed in Table 1 [9]. In these signal models, τ 1 and τ 2 indicate the starting and ending edge points of the PQD events, respectively. The signal model parameters, such as τ 1 , τ 2 , and α (amplitude ratio), as well as the power cable noise component n(t), can be intrinsically random. The additive noise n(t) in (1) is the sum of the Gaussian noise component n a (t) and impulsive noise component n i (t) [2]: where the impulsive noise component n i (t), which mainly results from the power switching ON/OFF or man-made EMI, may severely hinder the PQD signal detection (or localization) [2]. In case of Gaussian noise, the typical magnitude of noise is less than 1% (i.e., SNR = 40 dB) of the voltage magnitude [9]. For impulsive noise sample generation, we apply the following statistical Bernoulli Gaussian model [21]: where b(t) is the Bernoulli process with the probability of success ψ, and g(t) is the Gaussian process with zero mean and variance σ 2 I . After the A/D conversion, the noisy power signal x(t) is converted into the following sampled version (assuming sampling interval T s ): where s[i] indicates the PQD signal samples, n a [i] indicates the Gaussian noise samples with zero mean and variance σ 2 G , and n i [i] indicates the impulsive noise samples with zero mean and variance σ 2 I . The two variances σ 2 G and σ 2 I are related by the impulsive to Gaussian power ratio µ = σ 2 I /σ 2 G .

System Model
This paper proposes a PQD detection algorithm with adaptive impulsive denoising, whose flowchart is shown in Figure 1. In the proposed algorithm, if the noise type is "impulsive" (N c = 1), we use both an SM filter [22], for removing the impulsive noise components n i [i], and a wavelet denoising filter, for removing the Gaussian noise components n a [i]; otherwise (i.e., if the noise type is "Gaussian" (N c = 0)), we only use a wavelet denoising filter. In the classification of the noise type (see Step 3 in Figure 1), the noise type of the input signal is determined using a threshold (th). In this step, the 3-sigma threshold, that is, th = 3σ, is used, where σ is the standard deviation of the output samples (seeŷ[i] in (6)) from Step 2. That is, In what follows, the proposed algorithm procedure based on the flowchart shown in Figure 1 is explained in detail, where an 80% pu sag signal (Figure 2a), which is added with Gaussian plus impulsive noise (i.e., under impulsive noise channel (IMPN) conditions; the signal is shown in Figure 2b), is used as an example.
Step 1: Obtain the estimated (extracted) noise plus distortion component signal, denoted as (Figure 2c), by directly subtracting the power source signal s 0 [i] from the input signal x[i], as follows: Step 2: Apply a wavelet-based denoising filter to y[i] for the removal of Gaussian noise. As a result, we obtain a denoised (estimated) distortion component signal (Figure 2d), as follows: Step 3: Classify the estimated distortion component signal into two noise types: impulsive noise type (N c = 1), if the output samples of Step 2 are above 3-sigma, and otherwise, non-impulsive type (N c = 0). If N c = 1, then go to Step 4; otherwise, go to Step 5.
Step 4: Use the SM filter for impulsive noise removal, whose output becomes (Figure 2e) (7) Although this SM filter, which is a type of nonlinear filter, is simple, it has an excellent impulse noise cancelation function [22].
Step 5: Finally, execute the presented PQD localization process using WPTM metrics (whose pseudocode is presented in Algorithm 1 [for MV metric] or Algorithm 2 [for RMS metric]), which improves the robustness of the proposed PQD detection system over nonstationary noisy power signal channels [7].  Although this SM filter, which is a type of nonlinear filter, is simple, it has an excellent impulse noise cancelation function [22].
Step 5: Finally, execute the presented PQD localization process using WPTM metrics (whose pseudocode is presented in Algorithm 1 [for MV metric] or Algorithm 2 [for RMS metric]), which improves the robustness of the proposed PQD detection system over nonstationary noisy power signal channels [7].
In the wavelet-based Gaussian denoising step (Step 2), we choose a Daubechies wavelet with a five-coefficient filter (DB5), which is relatively better than the other Daubechies wavelet filters (e.g., three-coefficient (DB3), six-coefficient (DB6), or eight-coefficient (DB8)) in terms of the recovered SNR (for simplicity, the comparison of numerical results among these filters is omitted here). That is, in this Gaussian denoising step (Step 2), we first use DB5 with a universal threshold th = σ w 2 log|N| (where N is the size of the WT sample vector W 1 l and σ w = med W 1 l /0.6745) [9]. Then, if the estimated noise type in Step 3 is impulsive, that is, N c = 1, in Step 4, we use an SM filter that removes the impulsive noise. In the wavelet-based Gaussian denoising step (Step 2), we choose a Daubechies wavelet with a five-coefficient filter (DB5), which is relatively better than the other Daubechies wavelet filters (e.g., three-coefficient (DB3), six-coefficient (DB6), or eight-coefficient (DB8)) in terms of the recovered SNR (for simplicity, the comparison of numerical results among these filters is omitted here). That is, in this Gaussian denoising step (Step 2), we first use DB5 with a universal threshold ℎ σ 2log| | (where is the size of the WT sample vector and σ med 0.6745 ⁄ [9]. Then, if the estimated noise type in Step 3 is impulsive, that is, 1, in Step 4, we use an SM filter that removes the impulsive noise. After the Gaussian and impulsive denoising process (Steps 2-4 in Figure 1), the WPTM-based PQD detection process (Step 5 in Figure 1) is performed, for which Daubechies's WPT with DB3 is assumed to be used. The presented PQD detection scheme using WPTM-based metric (MV or RMS) is detailed in the next subsection.

WPT
WPT generates WPCs through WPD, whereas WT generates WCs through WD. Throughout the paper, a dyadic WD or WPD is assumed to be used (Figure 3), where the input signal vector, denoted as | 0, 1, … . , 1 , is the root node of the binary tree at the level index 0. Using a level-(≥1) WD, the approximation vector at the previous level (i.e., level − 1) is recursively projected into two level-orthonormal wavelet basis functions, that is, a scale function ϕ ( ψ ) and a wavelet function ψ , which generate the correspondingly decomposed two wavelet vectors (also termed as WCs): approximation (low frequency) and detail (high frequency) . In contrast, using the level-l WPD, both approximation (low frequency) and details (high frequency) (where 1, … , 2 1) at the previous level (i.e., level − 1) are recursively projected into the level-l orthonormal WP basis functions ψ (where 0, 1, … , 2 1) [23], thus producing the correspondingly decomposed 2 wavelet packet vectors (which are also called WPCs). Hence, as observed in the binary tree of Figure  3  After the Gaussian and impulsive denoising process (Steps 2-4 in Figure 1), the WPTMbased PQD detection process (Step 5 in Figure 1) is performed, for which Daubechies's WPT with DB3 is assumed to be used. The presented PQD detection scheme using WPTM-based metric (MV or RMS) is detailed in the next subsection.

WPT
WPT generates WPCs through WPD, whereas WT generates WCs through WD. Throughout the paper, a dyadic WD or WPD is assumed to be used (Figure 3), where the input signal vector, denoted as W 0 , is the root node of the binary tree at the level index l = 0. Using a level-l (≥1) WD, the approximation vector W 0 l−1 at the previous level (i.e., level l − 1) is recursively projected into two level-l orthonormal wavelet basis functions, that is, a scale function φ 0 l (= ψ 0 l ) and a wavelet function ψ 1 l , which generate the correspondingly decomposed two wavelet vectors (also termed as WCs): approximation (low frequency) W 0 l and detail (high frequency) W 1 l . In contrast, using the level-l WPD, both approximation (low frequency) W 0 l−1 and details (high frequency) W p l−1 (where p = 1, . . . , 2 l−1 − 1) at the previous level (i.e., level l − 1) are recursively projected into the level-l orthonormal WP basis functions ψ p l (where p = 0, 1, . . . , 2 l − 1) [23], thus producing the correspondingly decomposed 2 l wavelet packet vectors W p l (which are also called WPCs). Hence, as observed in the binary tree of Figure 3, while WD decomposes the original input signal vector W 0 0 into l + 1 WCs (e.g., for l = 3, . In WPT, we select the "cost function" in each WP sub-band as an optimal representation basis of the input signal. The cost function can determine the cost value of each node and its children nodes in the obtained full binary tree ( Figure 3). There are several possible choices for the cost function, such as 1-norm, Shannon entropy (SE), and log energy. Of these, we choose the Shannon entropy of the coefficients of sub-band S, which is calculated as follows [2]: Liao et al. showed that the spatial correlation between WCs can emphasize the starting and ending points of PQDs and suggested a wavelet-correlation-based detection method that improves the PQD detection performance over that of generic wavelet-based denoising methods [1]. However, this scheme has limited degrees of freedom (DoF = 2 or 3) and covers a limited frequency range as l increases, as WD decomposes only the approximation (low frequency) vector W 0 l . Sci. 2021, 11, x FOR PEER REVIEW 9 of 25 In WPT, we select the "cost function" in each WP sub-band as an optimal representation basis of the input signal. The cost function can determine the cost value of each node and its children nodes in the obtained full binary tree ( Figure 3). There are several possible choices for the cost function, such as 1-norm, Shannon entropy (SE), and log energy. Of these, we choose the Shannon entropy of the coefficients of sub-band S, which is calculated as follows [2]:

log .
Liao et al. showed that the spatial correlation between WCs can emphasize the starting and ending points of PQDs and suggested a wavelet-correlation-based detection method that improves the PQD detection performance over that of generic wavelet-based denoising methods [1]. However, this scheme has limited degrees of freedom (DoF = 2 or 3) and covers a limited frequency range as l increases, as WD decomposes only the approximation (low frequency) vector . In contrast, this paper defines WPTM using WPCs, introduces the WPTM-based metrics that exhibit large degrees of freedom (DoF = 2 1), and present a PQD feature detection system that uses these WPTM-based metrics.

WPTM and WPTM-Based Metrics
WTM using WCs has been widely applied to locate (or detect) the discontinuities of transient signals, such as images [2]. This paper similarly defines WPTM using WPCs and suggests several WPTM-based metrics for reliable PQD feature detection under severe power signal conditions.
In a binary tree, as shown in Figure 3, the top node (i.e., top WPC) is | 0, 1, … . , 1 . A WP space (where the level index 0, … , 1 and the packet index 0, … , 2 1) is defined with its corresponding orthonormal basis functions ψ . By using the dyadic WPD, a WP space is decomposed into two WP subspaces (producing the corresponding two WPCs)--⊕ --which are, respectively, defined with their corresponding basis functions ψ as follows: In contrast, this paper defines WPTM using WPCs, introduces the WPTM-based metrics that exhibit large degrees of freedom (DoF = 2 l − 1), and present a PQD feature detection system that uses these WPTM-based metrics.

WPTM and WPTM-Based Metrics
WTM using WCs has been widely applied to locate (or detect) the discontinuities of transient signals, such as images [2]. This paper similarly defines WPTM using WPCs and suggests several WPTM-based metrics for reliable PQD feature detection under severe power signal conditions.
In a binary tree, as shown in Figure 3, the top node (i.e., top WPC) is W 0 where the level index l = 0, . . . , L − 1 and the packet index p = 0, . . . , 2 l − 1) is defined with its corresponding orthonormal basis functions ψ p l . By using the dyadic WPD, a WP space W p l is decomposed into two WP subspaces (producing the corresponding two WPCs)-W l+1 -which are, respectively, defined with their corresponding basis functions ψ p l as follows: where r = 2 l n denotes the translation index and ψ where Considering the transient (high-frequency) component of the PQD signal x[i], we can approximate the component with all WPCs besides approximation (W 0 l ). Hence, for level l, the WPC matrix W of the signal x[i] can be approximately expressed with P = 2 l − 1 WPCs (except approximation) as follows: For level l, WPTM exhibits an exponentially increasing degrees of freedom, that is, DoF = P = 2 l − 1, whereas WTM exhibits a linearly increasing degrees of freedom, that is, DoF = 2 or 3 (except approximation) [1]. Furthermore, while WTM has a limited spectrum support (only low-frequency part), due to the nature of WD, WPTM maintains the entire spectrum support, due to the nature of WPD ( Figure 3). Hence, WPTM exhibits better correlation properties than WTM while appropriately retaining the high-frequency components of the PQD signal.
We can also specify the basis functions ψ p l with θ l (u) = 2 −l θ 2 −l u (where u = u p p = 1, . . . , P indicates the orthonormal vectors defining the wavelet packet signal space and θ(·) is the convolution kernel), where conventional WTM-based schemes have been used for the edge detection of nonstationary signals, such as images [2]. In this study, for PQD detection, we use scaled wavelets, denoted by which can smoothen the PQD signal space surface. In (12), ψ p l (u) = ψ p l (−u) and θ l (u) = θ l (−u). Then, the lth-level WPT components (i.e., WPCs) for the PQD input signal x[i] can be redefined with θ l as follows: where n and r = 2 l n are the time-shift and translation parameters, respectively. Thus, we rewrite the WPC matrix W in (11) with the gradient vector smoothened by θ l , as follows: Hereinafter, for simplicity, we will drop the subscript l of the WPC W p l in (11) and (14). Throughout the paper, for PQD feature detection, we define the WPTM M as a function of the W components, as follows: From (15), it is confirmed that the presented WPTM-based metrics exhibit greater degrees of freedom (P = 2 l − 1) than the existing wavelet-based or wavelet-correlation-based metrics. Thus, the proposed scheme exhibits improved PQD signal detection and local-ization capability compared to the existing schemes [1]. This difference further increases under critical channel conditions, such as low SNR (≤25 dB).
Conventionally, considering only the Gaussian noise channel (AWGN), the PQD feature detection threshold th of each WPC can be initialized with the following universal threshold TH U [24]: where the parameter σ p d is the median of W p ; that is, The PQD event is inherently random and its channel characteristics are not pure Gaussian. In particular, the numerical results (Section 3) indicate that the PQD edge detection (or localization) is much sensitive to random phase offset ϕ m = {τ m mod T} × 2π/T, where ϕ m~U [0, 2π) is uniformly distributed and m = 1 and 2 indicate the start and end edge locations, respectively, because of the shift variant characteristics of the wavelets or wavelet packets. When assuming the use of the universal threshold TH U , Figure 4 shows the average detection rate (DR) and FER curves of a sag signal with 80% pu (assuming Gaussian noise with SNR = 35 dB) along the phase offset axis. DR can be almost 0% at approximately ϕ m ≈ π/2 or 3π/2. This means that even after the denoising step (see Steps 2-4 in Figure 1), TH U [7] does not work well, especially for the detection of a random PQD event signal. The numerical results also prove that FER is very high when using TH U (Figure 4 and Table 2).     Hence, to avoid such high FER, we define a modified threshold with "k" factor (Table 3), whose value depends on the used metric, such as MV or RMS. In the proposed algorithm, an optimal value of k that maintains a low FER (<12%) without damaging the DR (even if it remains low at ϕ m ≈ π/2 or 3π/2) is obtained through simulation. Consequently, the modified threshold (TH M ) of the proposed scheme is determined as

PQD Feature Detection Using MV Metric
We define an MV-based WPTM metric M = M mv and use it for PQD feature detection. This metric is based on MV-based indirect correlation rather than direct correlation in existing schemes [1]. While the existing metric using wavelet correlation exhibits a limited degrees of freedom (DoF = 2 or 3), the proposed MV metric using indirect WP correlation exhibits an exponentially increased degrees of freedom (i.e., DoF = P = 2 l − 1). Hence, the MV metric is relatively simple yet robust to severe random PQD characteristics, including phase offset and impulsive noise.
For reliable PQD localization, we choose double-edge-based detection instead of the conventional single-edge-based detection [1,25], where we use two (front and back) edge checkers, denoted as C f det and C bdet , such that a PQD event will be detected only if both edge checkers are enabled.
In the detection procedure presented in Figure 1, Step 5 can call the WPTM-based PQD detection function using the MV metric (Algorithm 1). In Algorithm 1, the refined (denoised) wavelet packets W p (where p = 1, . . . , P) that undergo the impulsive denoising process and wavelet-based Gaussian denoising process (see Steps 2 to 4 in Figure 1) are input. We assume that DB3 is used for WPD. In the MV-based detection procedure presented in Algorithm 1, we first enable ("1") or disable ("0") the checking flag F, whether the sample value of each packet within all observation windows T A PQ is larger than a modified threshold TH M . Then, in the MV-based detection step, the PQD edge detection checkers C f det and C bdet are enabled if the accumulated (summed) flag value "accF" within their corresponding windows T f PQ (or T b PQ ) is greater than or equal to P/2 . That is, in the presented double-edge-based detection procedure, the detection checker C det becomes "TRUE" only if both C f det and C bdet are enabled. For instance, when assuming l = 3, if the values of accF at the two edge points are greater than or equal to 4 (= P/2 ), the PQD event checker is enabled (i.e., C det = "TRUE"). In addition, if accF is greater than or equal to P/2 at the outside (or remaining) window T o PQ , the false edge detection checker C f alse is enabled (i.e., C f alse = "TRUE").
Below, a list of notations used in this paper and a pseudocode representation of the proposed MV-based detection function (Algorithm 1) are presented, where the modified threshold TH M is used to detect both edges; l = 3 (or P = 7) is assumed in this algorithm.
As an example, in Figure 5, the proposed MV-based detection algorithm is applied to detect a voltage swell signal with 110% pu at SNR = 35 dB. Assuming l = 3, Figure 5a shows the denoised PQD signal input and Figure 5b-h, respectively, shows each of the seven WPCs of that input signal. In this MV-based WPTM metric, the sample values of all WPCs are compared with a threshold value th = TH M to update the accumulator accF (add one or not (hold)). After accumulating the 2 l − 1 WPCs, the PQD event is detected if accF is greater than or equal to P/2 . where,

| | .
For RMS-based PQD detection, the proposed algorithm procedure in Figure 1 calls the WPTM-based PQD detection function using the RMS metric (see Algorithm 2; whose pseudocode is shown below), where the following modified threshold is used: While the MV metric uses measures (one measure per packet), the RMS metric exploits a single combined measure to detect the PQD event. The denoised wavelet packets undergoing the impulsive and/or Gaussian denoising process (Step 2 to Step 4 in Figure 1) are used to obtain the RMS metric, as observed in (19). In the presented double-edge detection procedure, becomes "TRUE" only if both and are enabled "1". For instance, if the RMS value at the two edge points is greater than or equal to the threshold ℎ, then the PQD event is detected (i.e., = "TRUE"). In addition, if is greater than or equal to ℎ at the outside (or remaining) window , is enabled (i.e., = "TRUE").

PQD Feature Detection Using RMS Metric
Next, we define and use the WPTM-based detection scheme with the RMS metric: where, For RMS-based PQD detection, the proposed algorithm procedure in Figure 1 calls the WPTM-based PQD detection function using the RMS metric (see Algorithm 2; whose pseudocode is shown below), where the following modified threshold is used: While the MV metric uses P measures (one measure per packet), the RMS metric exploits a single combined measure to detect the PQD event. The denoised wavelet packets undergoing the impulsive and/or Gaussian denoising process (Step 2 to Step 4 in Figure 1) are used to obtain the RMS metric, as observed in (19).
In the presented double-edge detection procedure, C det becomes "TRUE" only if both C f det and C bdet are enabled "1". For instance, if the RMS value M[t] at the two edge points is greater than or equal to the threshold th, then the PQD event is detected (i.e., C det = "TRUE"). In addition, if M[t] is greater than or equal to th at the outside (or remaining) window T o PQ , C f alse is enabled (i.e., C f alse = "TRUE").
As an example, Figure 6a shows snapshots of RMS-based feature detection for a sag signal with 80% pu at SNR = 40 dB. Assuming l = 3, Figure 6b-d, respectively, shows the first, second, and seventh wavelet packets (or WPCs) (the other packets are omitted for simplicity) of the PQD signal. Figure 6e is the resulting subplot of the WPTM-based RMS metric, that is, M = M rms in (19). A PQD event is detected when the RMS value is larger than the red-dotted threshold line (th = TH M ). As an example, Figure 6a shows snapshots of RMS-based feature detection for a sag signal with 80% at SNR = 40 dB. Assuming = 3, Figure 6b-d, respectively, shows the first, second, and seventh wavelet packets (or WPCs) (the other packets are omitted for simplicity) of the PQD signal. Figure 6e is the resulting subplot of the WPTM-based RMS metric, that is, in (19). A PQD event is detected when the RMS value is larger than the red-dotted threshold line ( ℎ = ). Table 3 summarizes the difference between the two metrics (MV and RMS) of the proposed scheme and the wavelet-correlation metric of conventional ("Conv") scheme [1], in terms of complexity, strength, and the factor values over the simulated different noise channels. While the MV metric compares each (=2 1) wavelet packet with its corresponding threshold ℎ and collects the accumulated result for PQD detection, the RMS metric directly compares a single RMS value derived from packets with ℎ for PQD detection. Thus, the MV metric is more complex than the RMS metric, but exhibits relatively better DR and worse FER than the RMS metric. On the other hand, the existing scheme [1] using wavelet correlation-based metrics has much higher complexity due to the additional scale adjustment procedure (see Step 4, page 1989 of [1] for the details). In addition, it has lower DR and higher FER than our scheme; their numerical results are compared in detail in the next section.

Numerical Results and Discussions
This section presents the numerical results of the proposed WPTM-based PQD detection scheme and compares them with those obtained for the existing wavelet-based denoising (W-Den [10]), WC-Det [1], and non-wavelet-based detection schemes (S-transform [26]). In the simulation, we generate standard PQD event signals [9], including voltage sag, voltage swell, harmonics, sustained interruption, notch, and so on, under real stochastic electricity channel conditions. In the proposed detection scheme, we use RMS or MV metric. Let us assume = 3; thus, 2 1 7 packets are used to detect these PQD events. In the proposed PQD detection procedure, the universal threshold σ 2log| | is initially used, assuming 2504 (with a sampling rate 1 ⁄ 2 10 samples/s). Then, the proposed algorithm replaces with a modified (or updated) threshold with parameter (Table 3), σ 2log| |, depending on the  Table 3 summarizes the difference between the two metrics (MV and RMS) of the proposed scheme and the wavelet-correlation metric of conventional ("Conv") scheme [1], in terms of complexity, strength, and the k factor values over the simulated different noise channels. While the MV metric compares each P (=2 l − 1) wavelet packet with its corresponding threshold th and collects the accumulated result for PQD detection, the RMS metric directly compares a single RMS value derived from P packets with th for PQD detection. Thus, the MV metric is more complex than the RMS metric, but exhibits relatively better DR and worse FER than the RMS metric. On the other hand, the existing scheme [1] using wavelet correlation-based metrics has much higher complexity due to the additional scale adjustment procedure (see Step 4, page 1989 of [1] for the details). In addition, it has lower DR and higher FER than our scheme; their numerical results are compared in detail in the next section.

Numerical Results and Discussions
This section presents the numerical results of the proposed WPTM-based PQD detection scheme and compares them with those obtained for the existing wavelet-based denoising (W-Den [10]), WC-Det [1], and non-wavelet-based detection schemes (S-transform [26]). In the simulation, we generate standard PQD event signals [9], including voltage sag, voltage swell, harmonics, sustained interruption, notch, and so on, under real stochastic electricity channel conditions. In the proposed detection scheme, we use RMS or MV metric. Let us assume l = 3; thus, P = 2 l − 1 = 7 packets are used to detect these PQD events. In the proposed PQD detection procedure, the universal threshold TH U = σ d 2 log|N| is initially used, assuming N = 2504 (with a sampling rate f s = 1/T s = 2 × 10 5 samples/s). Then, the proposed algorithm replaces TH U with a modified (or updated) threshold with parameter k (Table 3), TH M = kσ d 2 log|N|, depending on the estimated channel and defined metric, such that its robustness is improved under severe stochastic power signal conditions, including impulsive noise, random phase offset, and low SNR. The simulation assumes that the phase offset ϕ m is uniformly distributed, that is, ϕ m ∼ U[0, 2π], and that impulsive noise is generated following the B-G model [21].
In the following subsections, we numerically validate that the proposed scheme with the adaptive denoising function is superior to the existing schemes over such real statistical channels. In particular, double-edge-based detection, which is chosen for more precise PQD localization, is compared with conventional single-edge-based detection over impulsive and Gaussian noise channels. We then analyze the performance effect of the proposed system model with an adaptive impulsive denoising function in detail and evaluate the proposed model for diverse standard PQDs and generate PQDs from an implemented practical distribution network using MATLAB ® Simulink ® [27]. Finally, we present a summarized discussion on the numerical analysis of the proposed system model.

Effect of Random Phase Offset and Modified Threshold
PQD feature detection is much sensitive to the start or end edge positions of PQD signals. Hence, the detection scheme must be robust to the random phase offset of the PQD signals, as shown in Figure 4. For this purpose, the proposed scheme uses a modified threshold TH M rather than a universal threshold TH U , which results in a lower FER (<10% for Gaussian noise) while maintaining suitable DR, even though it is still low at ϕ m ≈ π/2 or 3π/2 ( Figure 4). Table 2 compares the performance (in terms of DR and FER) of the proposed scheme (herein, assuming double edge detection) for a sag signal of 80% pu with a fixed phase offset (assuming ϕ m = π, i.e., "fixed PQD") or random phase offset (assuming ϕ m ∼ U[0, 2π), i.e., "random PQD"). In this simulation, MV is used as the detection metric and a Gaussian noise channel with SNR = 40 dB is assumed. Table 2 shows that for both fixed and random PQDs, the presented MV metric with TH M dominates the same metric with TH U [7] in terms of FER. Hereinafter, unless stated otherwise, TH M with k factor (Table 3) is used for the proposed scheme.

Single-and Double-Edge-Based Detection
We evaluate the performance of the proposed scheme in terms of both double-and single-edge-based detection. In Table 4, the single-edge-based detection performance of both the proposed algorithm (denoted as "Prop") and conventional WC-Det algorithm ("Conv") is compared over either Gaussian noise channels (AWGN) or impulsive noise channels (IMPN). Table 4. Single-edge-based PQD detection performance (DR/FER (%)) of the proposed and conventional wavelet-correlation-based-detection (WC-Det) algorithms, where a swell signal with 120% pu is used over Gaussian noise (AWGN) with signal-to-noise ratio (SNR) = 35 dB or IMPN with SNR = 35 dB, µ = 400, ψ = 0.02%. As the simulated PQD event, a swell signal with 120% pu and ϕ m = π (for fixed PQD) or ϕ m ∼ U[0, 2π) (for random PQD) is used. As indicated in Table 4, the proposed scheme has approximately 9-10% higher DR and 2-5% lower FER for random PQD over AWGN, as compared to WC-Det. In contrast, the proposed scheme has approximately 14-15% higher DR and approximately 47% lower FER for random PQD over IMPN, as compared to WC-Det. This indicates that the proposed scheme has an improved FER and DR compared to WC-Det, especially for random PQD. For fixed PQD, the proposed scheme is slightly better (8% lower over IMPN) in terms of FER than WC-Det while maintaining the same DR.

Fixed PQD
Comparing MV and RMS, especially for random PQD, while MV is relatively better than RMS in terms of DR, RMS is relatively better than MV in terms of FER. While assuming single-edge-based PQD detection, Table 4 shows that the proposed (MV or RMS) scheme has a similar DR for fixed PQD but a slightly improved DR for random PQD, as compared to the existing scheme (WC-Det). In terms of FER (for both fixed PQD and random PQD), the proposed scheme is superior to the existing scheme, especially over IMPN.
In most previous studies, including Liao's papers [1,28], only single-edge-based PQD detection has been used. However, for precise PQD localization, double edge-based detection identifying both (start and end) edges of a PQD signal is necessary. In the simulation, we set the allowable limit of error (ALE) time of double-edge-based detection to be within ±7.5 × 10 −5 s (±15 samples). This means that the PQD detection position (time) can deviate as much as the ALE time from the actual position of PQD occurrence. The accuracy of PQD detection position (time) decreases as the ALE time increases. Table 5 compares the DR of double-edge-based PQD over AWGN or IMPN channel, where SNR = 35 dB or 40 dB is assumed, between the proposed and existing schemes (WC-Det and W-Den). For the simulated PQD, we generate either (a) a sag signal with 80% pu or (b) a swell signal with 120% pu. Table 5 shows that, in case of fixed PQD, there is no large difference between the existing and proposed schemes in terms of DR. However, in case of random PQD, the proposed scheme has much more improved DR over AWGN or IMPN than the existing wavelet-based schemes (WC-Det and W-Den). Specifically, for signal (a) over AWGN with SNR = 35 dB and 40 dB, the proposed MV/RMS exhibits 5.9%/5.4% and 8.8%/8.7% (or 34.5%/34% and 16.8%/16.7%) better DR, respectively, than WC-Det (or W-Den). For the signal (b) over AWGN with SNR = 35 dB and 40 dB, the proposed MV/RMS exhibits 7.7%/6.9% and 9.1%/8.9% (or 34.6%/33.8% and 23.6%/23.4%) better DR, respectively, than WC-Det (or W-Den).
When considering random PQD over IMPN, the proposed scheme is more dominant than the conventional wavelet-based schemes. For instance, for the signal (a) over IMPN with SNR = 35 dB and 40 dB, the proposed MV/RMS exhibits 26.9%/26.4% and 13.5%/13.2% (or 48.9%/48.4% and 30.9%/30.6%) better DR, respectively, than WC-Det (or W-Den). For the signal (b) over IMPN with SNR = 35 dB and 40 dB, the proposed MV/RMS exhibits 27.4%/25.4% and 13.4%/13% (or 52.6%/50.6% and 32.2%/31.8%) better DR, respectively, than WC-Det (or W-Den). In Table 5, the proposed scheme is also compared with the S-transform-based scheme [3,27] as a non-wavelet-based detection. We confirm that the S-transform exhibits much lower DR (even worse than those of WC-Det and W-Den), especially in the case of random PQD, as compared to the proposed scheme. Table 5. Double-edge-based PQD detection performance (DR (%)) of the proposed and conventional (WC-Det, W-Den, and S-Transform) algorithms, where (a) a sag signal with 80% pu or (b) SWELL: a swell signal with 120% pu is used over AWGN or IMPN with SNR = 35 dB or 40 dB.   5 indicates that the proposed scheme is superior to the existing schemes in terms of both single-and double-edge-based detection performance. Particularly, for the double-edge-based detection of random PQD (Table 5), the proposed MV or RMS scheme has much more improved performance indices (i.e., in terms of DR and FER; even FER results are omitted in Table 5 for simplicity) than the existing schemes. A comparison between the proposed metrics indicates that MV is slightly better than RMS, especially in terms of double-edge-based DR.

Effect of Adaptive Impulsive Denoising
In Table 6, we assume that a sag signal of 80% pu under the randomly phased IMPN conditions with SNR = 20 to 40 dB, µ = 400, and ψ = 0.02% is generated. The results in Table 6 show that the proposed scheme with the adaptive denoising function (see Step 4 in Figure 1) effectively eliminates impulsive noise. In addition, the proposed algorithm considerably reduces the FER under severe impulsive electricity channel conditions, even at a very low SNR (≤25 dB). Moreover, the proposed scheme with adaptive impulsive denoising (case (b) in Table 6) exhibits more improved FER and DR than the same scheme without adaptive impulsive denoising (i.e., only with wavelet-based Gaussian denoising; case (a) in Table 6). Specifically, by adding the impulsive denoising function, the proposed MV and RMS methods exhibit an improved DR of 7.5% and 8.6% (or 11.3% and 13.7%) at SNR = 35 dB (or SNR = 25 dB), respectively, while considerably reducing the FER. At SNR = 40 dB, the proposed algorithm with the impulsive denoising step (Step 4) exhibits a slightly better (<1.3%) DR while maintaining a suitable FER. As a result, we confirm that adaptive impulsive denoising makes the proposed detection algorithm more robust to a real IMPN environment.

Detection of Diverse PQD Types
Within a power grid, various PQD events can occur. Herein, we focus on six major PQD events-sag, swell, interruption, harmonics, notch, and oscillatory transient-and two combined PQD events-swell with harmonics and sag with harmonics, which can often be generated within the power grid and cause serious problems in the connected electric devices or facilities. Table 7 summarizes the numerical results of the proposed detection scheme for the diverse randomly phased PQD events ( ϕ m ∼ U[0, 2π); that is, random PQDs) that are generated over the IMPN channels with SNR = 40 dB, µ = 400, and ψ = 0.02%. In the simulation, the critical PQD events specified by IEEE1159 (Table 1) (e.g., a swell with 110% pu, a sag with 90% pu, and harmonics ("Har") with 10% pu) are assumed to occur. In this simulation, we assume that such PQD event signals have a limited duration of two cycles (which are specified as "instantaneous"-or "momentary"-type signals by IEEE1159). Table 7. Detection performance (DR (%)) of double-edge-based random PQD events using the proposed algorithm, where a sag signal with 90% pu, a swell signal with 110% pu, a harmonics signal with 10% pu, interruption, notch, oscillatory transient signal, and swell (or sag) with harmonics are assumed over IMPN channels of SNR = 40 dB, µ = 400, and ψ = 0.02%  Table 7 shows that a swell with 1.1 pu (or a sag with 0.9 pu) exhibits much more degraded DR than that with 1.2 pu (or a sag with 0.8 pu; Table 5). This indicates that the amplitude of the PQD signals substantially affects the detection performance. In addition, a comparison of MV and RMS indicates that MV is only slightly better in terms of DR than RMS.

PQD Events MV RMS
The table also shows that the proposed scheme exhibits almost 100% DR for harmonics, interruption, notch, oscillatory transient, and swell (or sag) with harmonics [29], which indicates that these PQD events are relatively easy to detect as compared to pure sag or swell.

Simulation for a Distribution Network
We implement a simple power distribution network with line faults using MATLAB ® Simulink ® , as shown in Figure 7a, which generates PQD event signals such as voltage sag and voltage swell, and we test the proposed system model for the created event signals. We also implement a nonlinear load network using MATLAB ® Simulink ® , as shown in Figure 7b, which generates harmonic voltage disturbance signals. Those models comprise 11 KV, 30 MVA, and 60 Hz three-phase source block feeding through 0.4 KV, 1 MVA delta/wye transformers to a 10 KW resistive and 100 VAR inductive load (whose detailed properties can be referred to from [27]). In a practical network model [27], we can insert line faults generating voltage sage or swell events. The PQD events generated by this network are assumed to have a fixed phase (i.e., fixed PQD).   Figure 8 shows the voltage sag (Phases A and B) and voltage swell (Phase C) waveforms generated by the corresponding line faults of the power distribution network in Figure 7a. A simulation time of 0.2 s is set and the ode23tb solver is selected to run the simulation. From the above waveforms shown in Figure 8, we choose Phase B for the voltage sag signal with 78% pu and Phase C for the voltage swell signal with 111% pu, and then apply our proposed algorithm to the PQD event signals generated over AWGN channels with SNR = 30-35 dB and IMPN channels with SNR = 30-35 dB, µ = 400, and ψ = 0.02%, respectively, to evaluate the detection performance.  Table 8 shows the performance of the double-edge-based PQD detection system over AWGN channels with SNR = 30-35 dB and IMPN channels with SNR = 30-35 dB, = 400, and = 0.02%. The results of the network distribution model (Figure 7a) and the nonlinear load model (Figure 7b) over AWGN or IMPN channel, as observed in Table 8, verify that the proposed system model is suitable for real grid systems. Compared to the proposed schemes (MV or RMS), the conventional scheme (WC-Det) has a similar DR for sag or swell signals but has a degraded DR for harmonic signals over AWGN or IMPN channels. However, WC-Det has a higher FER than the proposed schemes, especially for PQD over IMPN. Table 8 also shows that both MV and RMS have comparable performance over AWGN and IMPN channels. Table 8. Double-edge-based detection performance (DR/FER (%)) of the proposed algorithm, for which a sag signal with 78% pu, a swell signal with 111% pu generated from the implemented network model of Figure 7a, and a harmonics signal with 10% pu generated from the implemented network model of Figure 7b are generated over AWGN channels with SNR = 30-35 dB or IMPN channels with SNR = 30-35 dB, = 400, and = 0.02%.

Discussion
Most of the existing PQD detection schemes have been evaluated over generic electricity channels using only Gaussian noise (AWGN). Hence, the PQD detection analysis under practically severe SG channel conditions, including random phase offset, impulsive noise, and low SNR (≤40 dB), has been limited. For instance, a numerical comparison between fixed PQD and random PQD in Tables 4 and 5 indicates that the PQD detection performance is considerably dependent upon the random phase offset. The impulsive  Table 8 shows the performance of the double-edge-based PQD detection system over AWGN channels with SNR = 30-35 dB and IMPN channels with SNR = 30-35 dB, µ = 400, and ψ = 0.02%. Table 8. Double-edge-based detection performance (DR/FER (%)) of the proposed algorithm, for which a sag signal with 78% pu, a swell signal with 111% pu generated from the implemented network model of Figure 7a, and a harmonics signal with 10% pu generated from the implemented network model of Figure 7b are generated over AWGN channels with SNR = 30-35 dB or IMPN channels with SNR = 30-35 dB, µ = 400, and ψ = 0.02%.

dB
The results of the network distribution model (Figure 7a) and the nonlinear load model (Figure 7b) over AWGN or IMPN channel, as observed in Table 8, verify that the proposed system model is suitable for real grid systems. Compared to the proposed schemes (MV or RMS), the conventional scheme (WC-Det) has a similar DR for sag or swell signals but has a degraded DR for harmonic signals over AWGN or IMPN channels. However, WC-Det has a higher FER than the proposed schemes, especially for PQD over IMPN. Table 8 also shows that both MV and RMS have comparable performance over AWGN and IMPN channels.

Discussion
Most of the existing PQD detection schemes have been evaluated over generic electricity channels using only Gaussian noise (AWGN). Hence, the PQD detection analysis under practically severe SG channel conditions, including random phase offset, impulsive noise, and low SNR (≤40 dB), has been limited. For instance, a numerical comparison between fixed PQD and random PQD in Tables 4 and 5 indicates that the PQD detection performance is considerably dependent upon the random phase offset. The impulsive noise, which is mainly due to the power switch ON/OFF or man-made EMI, can also substantially affect the performance of PQD detection or localization [2] (Tables 4-8).
Throughout this section, we analyze the proposed WPTM-based PQD detection system model numerically under such severe electricity channel conditions and compare it with the existing system models. Specifically, in case of PQD events with a fixed phase offset (see fixed PQD in Tables 3-5), there is no significant difference in DR between the proposed and conventional methods (there is even some more difference of FER over IMPN channels). However, in case of PQD events with random phase offset (see random PQD in Tables 4 and 5), the proposed method using WPTM-based metrics (MV and RMS) is relatively superior to conventional wavelet-based (WC-Det and W-Den) or non-wavelet-based (S-Tran) methods, especially over IMPN.
When considering the precise detection or localization of PQD events with a limited duration, double-edge-based detection is more favorable than conventional single-edgebased detection. In particular, for random PQD (i.e., PQD event signal with a uniformly distributed random phase: ϕ m ∼ U[0, 2π)) in Table 5, the simulation results obtained for AWGN or IMPN indicate that the proposed scheme using MV or RMS metric is much superior to the existing wavelet-based or non-wavelet-based scheme in terms of doubleedge-based detection performance (DR or FER). Especially for the IMPN channel with a very low SNR (≤25 dB), the DR difference between the proposed and existing schemes increases further.
The simulation results in Tables 6 and 7 indicate that the proposed PQD detection algorithm (see Figure 1 in Section 2), which has an adaptive impulsive denoising function, improves the robustness under the IMPN channel conditions. Specifically, Table 6 shows that the adaptive impulsive denoising step effectively eliminates impulsive noise; thus, the proposed MV or RMS significantly reduces FER while maintaining a suitable DR. Table 7 also shows that the presented algorithm works well for various PQD events, including harmonics, interruption, notch, oscillatory transient, and swell (or sag) with harmonics, as well as pure sag or swell. According to the simulation results, MV is superior to RMS in terms of DR, whereas RMS is superior to MV in terms of FER.
Through the simulated experiment of real network distribution models (Table 8), we verify that the proposed MV or RMS scheme guarantees better DR and FER over both AWGN and IMPN channels, as compared to the existing scheme (WC-Det). In particular, the performance difference between the proposed and existing schemes further increases as the SNR decreases (Tables 5 and 8).
The results of the numerical analysis indicate that the proposed PQD detection scheme with WPTM-based metrics is more reliable and has better detection capability under severe random electricity channel conditions than the conventional schemes.

Conclusions
This paper presents a WPTM-based PQD detection algorithm that is applicable to reliable smart grid construction and demonstrates its simulation under real stochastic electricity channel conditions, including random phase offset, impulsive noise, and low SNR. We define several WPTM-based metrics, such as MV and RMS, that exhibit more degrees of freedom than conventional WTM-based metrics. In addition, in the proposed PQD feature detection scheme, we define a modified threshold (TH M ) rather than a conventional universal threshold (TH U ), which makes it more robust against such severe electricity channel conditions. The simulation results indicate that the proposed algorithm, which has an SM filter-based adaptive denoising function, is robust to such severe channel environments, including impulsive noise. The results of the numerical analysis indicate that the proposed scheme is more reliable and has a better detection capability than the existing wavelet-based or wavelet packet-based and non-wavelet-based detection schemes. Furthermore, the presented algorithm is found to work well for various PQD events. Using the experiment for an implemented distribution network with MATLAB ® Simulink ® , we prove that the proposed MV or RMS scheme guarantees better performance over both AWGN and IMPN channels.  remaining window C f det front edge detection checker C bdet back edge detection checker C det detection checker C f alse false edge detection checker F edge detection flag accF edge detection flag accumulator