A photovoltaic time series anomaly detection method of self-supervised three-domain contrast learning combined with prior modulation transformer

By combining self-supervised three-domain contrastive learning with Transformer, the problems of single feature domain and insufficient cross-domain collaborative representation ability in photovoltaic anomaly detection are solved, realizing stable and reliable anomaly identification of photovoltaic systems under complex conditions and reducing the risk of false alarms and missed detections.

CN122174132APending Publication Date: 2026-06-09NANJING UNIV OF INFORMATION SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NANJING UNIV OF INFORMATION SCI & TECH
Filing Date
2026-05-12
Publication Date
2026-06-09

Smart Images

  • Figure CN122174132A_ABST
    Figure CN122174132A_ABST
Patent Text Reader

Abstract

The application discloses a photovoltaic time sequence anomaly detection method of self-supervised three-domain contrast learning combined with prior modulation Transformer, and comprises the following steps: data preprocessing and window division; three-domain contrast learning and anomaly screening; point-level fine detection of prior modulation Transformer; multi-granularity anomaly fusion and output; the application constructs a multi-stage and hierarchical cooperative detection mechanism to realize accurate positioning of anomalies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of photovoltaic anomaly detection technology, and in particular to a photovoltaic timing anomaly detection method based on self-supervised three-domain comparative learning and prior modulation Transformer. Background Technology

[0002] With the large-scale deployment of photovoltaic power generation systems and the increasing complexity of operating environments, power plant operation data exhibits characteristics such as multivariate coupling, strong periodicity, frequent switching of operating conditions, and significant noise disturbances. The monitoring sequences of photovoltaic system power, performance ratio, irradiance, temperature, and inverter efficiency not only have obvious daily periodic structures, but also fluctuate significantly with weather changes, seasonal differences, and adjustments to operating strategies. Engineering practice shows that existing photovoltaic anomaly detection technologies still have the following prominent problems in engineering applications: (1) The feature domain is single and lacks the ability to cross-domain collaborative characterization of time domain, frequency domain, and residual domain, resulting in inaccurate anomaly identification; (2) There is a lack of explicit constraints on the photovoltaic periodicity and physical consistency, resulting in insufficient detection stability under operating condition switching; (3) It is difficult to balance real-time performance and accuracy in large-scale online scenarios; (4) It is difficult to unify point-level positioning and segment-level structural anomaly identification, affecting anomaly interpretation and operation and maintenance decisions. Summary of the Invention

[0003] Purpose of the invention: The purpose of this invention is to provide a photovoltaic time series anomaly detection method based on self-supervised three-domain contrastive learning and joint prior modulation Transformer. It jointly optimizes the periodic alignment features of the time domain, frequency domain, and residual domain, and enables the model to achieve unified anomaly representation across multiple feature domains by jointly constraining intra-domain similarity and inter-domain consistency. Furthermore, it uses Transformer in conjunction with the method for anomaly detection, thus solving the problems existing in the background technology.

[0004] Technical Solution: The photovoltaic timing anomaly detection method based on self-supervised three-domain contrastive learning and prior modulation Transformer, as described in this invention, includes the following steps:

[0005] Step 1: Data preprocessing and window partitioning: Collect multivariate time series data of photovoltaic system, perform standardization processing, and use a sliding window mechanism to divide the series into multiple fixed-length subsequences as analysis windows;

[0006] Step 2: Three-Domain Contrastive Learning and Anomaly Screening: Multivariate synchronous data augmentation is performed on the obtained window samples. The original window and the augmented window are respectively fed into a three-domain encoder consisting of a time-domain encoder, a frequency-domain encoder, and a residual-domain encoder to extract the structured features of each window in the time domain, frequency domain, and residual domain. Through self-supervised contrastive learning, the features before and after augmentation of the same window are used as positive sample pairs, and the features of different windows are used as negative sample pairs. Combined with a three-domain consistency regularization term used to constrain the physical characteristics of the photovoltaic system, the three-domain encoder is trained. The trained encoder is used to calculate the structural consistency between each window and the normal operation mode to obtain a window-level confidence score, and anomaly candidate windows are screened based on the score.

[0007] Step 3: Point-level fine-grained detection using prior modulated Transformer: For the selected anomaly candidate windows, the Transformer model is used to model the sequence relationships and calculate the actual correlation distribution between each time point within the window; simultaneously, a hybrid periodic prior correlation distribution dynamically modulated by the window-level confidence score is constructed; the hybrid periodic prior correlation distribution integrates local temporal proximity bias and periodic reference structure, and the constraint strength adaptively weakens as the window confidence decreases; by calculating the difference between the actual correlation distribution and the prior correlation distribution, the structural anomaly score at each time point is obtained;

[0008] Step 4: Multi-granularity anomaly fusion and output: Generate a comprehensive anomaly score for each time point, and sort and filter to select the final anomalies.

[0009] Furthermore, in step 2, the data augmentation is as follows: noise perturbation, frequency domain perturbation, and amplitude scaling operations are applied synchronously to all variables within the window to simulate non-fault perturbations such as sensor noise, period offset, and overall irradiance variation in the actual operation of the photovoltaic system, forcing the contrastive learning model to focus on the invariant physical structure and periodic patterns in the data.

[0010] Furthermore, in step 2, the time-domain encoder is used to directly extract the trend change features of the original sequence within the window; the frequency-domain encoder extracts the main frequency and energy distribution features of the window data through Fourier transform; and the residual-domain encoder extracts the residual perturbation features by separating the trend component from the original sequence.

[0011] Furthermore, the three-domain consistency regularization term is used to constrain the structured features of the three domains—time-domain encoder, frequency-domain encoder, and residual-domain encoder—to satisfy the following physical consistency during the contrastive learning process: the local change slope of the time-domain trend tends to be consistent with the cross-frequency change slope of the frequency-domain energy; the daily periodic dominant frequency component in the frequency domain and the periodic drift component contained in the residual signal maintain a matching energy distribution; and the trend profile recovered from the residual domain remains synchronized with the original time-domain trend.

[0012] Furthermore, in step 3, the hybrid periodic prior association distribution is as follows: when the window confidence is high, the local constraint range of the prior distribution is tightened to encourage the model to establish accurate long-range physical associations; when the window confidence is low, the local constraint range of the prior distribution is adaptively relaxed to avoid imposing incorrect strong periodic assumptions on the model in non-stationary or anomalous intervals.

[0013] Furthermore, in step 3, the difference between the actual association distribution and the prior association distribution is obtained by calculating the JS divergence between the actual association distribution and the prior association distribution, and the difference value is directly used as the basis for measuring whether the time point structure is abnormal.

[0014] Furthermore, step 4 is as follows: a hierarchical strategy combining window-level coarse screening and in-window fine detection is adopted: first, a computationally efficient three-domain contrastive learning model is used to quickly screen all windows, and only high-risk abnormal candidate windows are sent to the computationally complex Transformer model for fine detection.

[0015] Furthermore, the anomaly candidate window is fed into the computationally complex Transformer model for fine-grained detection. The specific process is as follows: By comparing the difference between the sequence association structure learned by the model and the prior structure, the structural dependency at the time point is evaluated to determine whether an anomalous shift has occurred, resulting in a structural anomaly score. The structural anomaly score is used to reflect anomalous changes in the temporal association pattern. By comparing the difference between the Transformer's reconstruction results at the time point and the original observations, the numerical reconstruction anomaly score is evaluated to determine whether the time point deviates from the normal operating mode at the numerical level. The window anomaly score, structural anomaly score, and numerical reconstruction anomaly score are then normalized to generate a comprehensive anomaly score.

[0016] Beneficial Effects: Compared with existing technologies, this invention has the following significant advantages: By innovatively combining three-domain contrastive learning with Transformer, this invention achieves more stable and reliable anomaly identification under complex operating conditions and large-scale online monitoring. This invention no longer relies solely on single time-domain features or numerical deviations for judgment, but comprehensively utilizes time-domain trends, frequency-domain periodic structures, and residual perturbation features to characterize the structural consistency of the photovoltaic system's operating state. This effectively distinguishes between normal operating condition fluctuations and genuine abnormal damage, significantly reducing the risk of false alarms and missed detections under conditions of strong noise, strong periodic perturbations, and multivariate coupling. Attached Figure Description

[0017] Figure 1 This is a flowchart of the present invention; Figure 2 This is a flowchart of the comparison learning process of the three-domain comparison learning module of the present invention; Figure 3This is a flowchart of the Transformer anomaly detection based on contrastive learning confidence, as described in this invention. Detailed Implementation

[0018] The technical solution of the present invention will be further described below with reference to the accompanying drawings. (All algorithm experiments and verifications in the following embodiments were completed in the PyCharm integrated development environment using the Python language and the PyTorch deep learning framework. The specific parameter values ​​given in the embodiments are the preferred configurations determined by the present invention after comparative experiments and analysis on typical photovoltaic operating data.)

[0019] like Figure 1 As shown, embodiments of the present invention provide a photovoltaic timing anomaly detection method based on self-supervised three-domain contrastive learning and prior modulation Transformer, comprising two parts: three-domain contrastive learning and Transformer fine-tuning. The process is as follows: Figure 1 As shown, the specific steps are as follows.

[0020] Step S1: Data preprocessing and multivariate sliding window partitioning

[0021] Step S1 specifically includes:

[0022] Step S1-1: Collect multivariate operating data of the photovoltaic system over continuous time, assuming a time interval of 10:00-11: (This is the first step in the second step, where 10 is the second step, and 11 is the third step, where 10 is the third step, and 11 is the fourth step, where 10 is the fifth step, and 11 is the sixth step, where 10 is the seventh step, and 11 is the eighth step, where 10 is the ninth The observation vector is represented as:

[0023]

[0024] in, In this embodiment, the dimension of the variable is... =5, corresponding to power, performance ratio, irradiance, temperature, and inverter efficiency, respectively. In this embodiment, the anomaly types used in the test set include segment anomalies (continuous interval decreases), trend anomalies (overall drift), and frequency anomalies (periodic changes), with the anomaly interval accounting for approximately 10%.

[0025] To eliminate the impact of differences in units and numerical scales among different variables on model training, z-score standardization was performed on the multivariate time series data collected from the photovoltaic system. For the observation vector at time t... Its standardized result is defined as:

[0026]

[0027] in, This represents the observation vector after z-score normalization; This represents the mean vector of each variable on the training dataset; This represents the standard deviation vector of each variable on the training dataset.

[0028] The mean vector with standard deviation vector Statistical calculations are performed only on the training dataset and remain fixed during subsequent training, validation, and testing phases. This standardization process is used to ensure data consistency between the model training and inference phases.

[0029] Step S1-2: Use a sliding window mechanism to process the standardized time series. Divide into several lengths Window samples ,in For window indexing, Let N be the window length, and N represent the total number of sampling points within a single sliding window. Considering the significant diurnal periodicity of photovoltaic power generation, the window length is set to ensure that a single window can cover the complete or near-complete periodic structural features. Set to a daily cycle length corresponding to the sampling frequency of the photovoltaic system. This example uses the photovoltaic data sampling interval. The window length is 0.25h. Set the value to 24 / 0.25=96, and simultaneously set N=w=96, step size. for =24, meaning a window is extracted every 24 time steps to cover overlapping areas. Simultaneously, quality checks are performed on each subsequence, removing windows with excessive noise or a missing value exceeding 5%. Step S2: Perform self-supervised training using three-domain contrastive learning to generate preliminary abnormal windows and window confidence scores.

[0030] This invention comprehensively characterizes the real operating state of photovoltaic systems by simultaneously modeling window data in the time, frequency, and residual domains and constraining its structural consistency. It explicitly constructs the inherent diurnal cycle trend stability, dominant frequency energy concentration, and weak residual periodic drift patterns of photovoltaic systems as three-domain consistency regularization terms incorporated into the contrastive loss. Through self-supervised contrastive learning training, the model can extract invariant patterns from the data during the training phase and calculate the distance between the test window and this stable structural representation during the detection phase. This distance is then used as an anomaly scoring index to effectively identify abnormal states.

[0031] like Figure 2 As shown, step S2 specifically includes: Step S2-1: For each window sample Applying multiple data augmentation operations yields augmented samples. The core purpose of data augmentation is to force the contrastive learning encoder to specifically learn the truly invariant physical coupling laws and periodic structure characteristics behind the photovoltaic multivariate sequence by simulating the non-fault-type disturbance environment that is common in the actual operation of photovoltaic power plants.

[0032] Specifically, for window samples Multivariate synchronous perturbation augmentation is employed. Data augmentation methods include the following operations: noise perturbation, frequency domain perturbation, and amplitude scaling. In this embodiment, one augmentation method is randomly selected from the window for data augmentation each time.

[0033] (1) Increased noise disturbance:

[0034] Noise perturbation enhancement is used to simulate random fluctuations in photovoltaic systems during actual operation, caused by sensor measurement errors, communication link jitter, or environmental disturbances. Specifically, random noise is synchronously superimposed on the window samples, and its mathematical form is expressed as:

[0035]

[0036] in, Indicates the noise term. express Follows a mean of 0 and a variance of Gaussian distribution; parameters Used to control the amplitude of noise disturbance, in this embodiment, specifically... .

[0037] (2) Enhanced frequency domain perturbation:

[0038] Frequency domain perturbation enhancement is primarily used to simulate slight shifts in the solar cycle and changes in energy distribution in photovoltaic systems when encountering cloud cover, sudden weather changes, or switching of operating conditions. This enhancement method can introduce controllable perturbations to the periodic structure without disrupting the overall consistency of the data, allowing the model to learn to distinguish between normal periodic fluctuations and actual anomalous deviations.

[0039] Specifically, for window samples Performing a discrete Fourier transform along the time dimension yields the corresponding complex spectrum:

[0040]

[0041] in, Indicates the first The variable in the first... Complex spectral components at discrete frequency points; Indicates the window sample number The observed values ​​of the variables at the nth sampling time; n is the time-domain sampling point index; k is the discrete frequency index, used to characterize the spectral components at different frequency positions; j is the imaginary unit. is the complex exponential basis function in the Discrete Fourier Transform. Through the above transformation, the frequency domain representation of the window sample at each discrete frequency point is obtained.

[0042] Subsequently, the core frequency set of photovoltaic data was defined. :

[0043]

[0044] in, For discrete frequency indexes. Represents the fundamental frequency and harmonic order ( Corresponding to the daily cycle fundamental frequency, (Corresponding to lower-order harmonics). For the allowed spectral offset tolerance index (taken in this embodiment) ), used to accommodate local periodic phase shifts and spectral leakage caused by factors such as cloud cover.

[0045] Since the window sample is a multivariate time series, therefore It includes the spectral components of each variable at the k-th discrete frequency point, therefore it adopts... Let represent the complex spectral component of the d-th variable at the k-th discrete frequency point. Then, random proportional perturbations are injected into the amplitudes of these core frequencies to generate the perturbed spectrum. For those not in the set Other background frequencies in the set have their amplitudes unchanged. The calculation logic is as follows: for the set... Each discrete frequency point in :

[0046]

[0047] Where d is the variable index; The values ​​are uniformly distributed and randomly generated within the interval [-1, 1] to ensure the randomness of the perturbation; This is a frequency domain perturbation intensity parameter used to control the maximum amplitude of spectral fluctuations (in this embodiment, ...). That is, the maximum allowed (spectral amplitude fluctuations).

[0048] Finally, a time-domain restoration operation is performed to restore the perturbed spectrum. The enhanced data is obtained by restoring the time series using the inverse fast Fourier transform:

[0049]

[0050] in, This represents the enhanced data at the d-th variable at the n-th sampling time after frequency domain perturbation and restoration via inverse fast Fourier transform; This represents the perturbation-induced complex spectral component of the d-th variable at the k-th discrete frequency point; n is the time-domain sampling point index; k is the discrete frequency index; N is the total number of sampling points participating in the inverse transform; This refers to the complex exponential basis functions in the inverse discrete Fourier transform. Through this inverse transform, the perturbed frequency domain representation can be restored to an enhanced time-domain sample.

[0051] Ultimately by all Arranged by time and variable dimensions, this constitutes a complete augmented sample. .

[0052] Through frequency domain perturbation, the model can be exposed to various sample formats during the training phase that exhibit slight changes in periodic structure but whose overall physical nature still conforms to the operating laws of photovoltaic systems. This allows the model to learn the relatively stable main frequency structure of photovoltaic systems under normal operating conditions, and demonstrates a high tolerance for a certain degree of spectral energy diffusion and period shift in actual operation.

[0053] (3) Amplitude scaling enhancement:

[0054] Amplitude scaling enhancement is used to simulate the operating state of a photovoltaic system where multiple variables change proportionally simultaneously under conditions such as variations in overall irradiance, module aging, or slow changes in system efficiency. A uniform amplitude scaling is applied to the window samples, expressed as follows:

[0055]

[0056] Wherein, scaling factor The proportionality coefficient is randomly selected. The parameter range... This is an adjustable parameter used to adapt to different light intensities and power generation levels. In this embodiment, it is taken as... This means scaling within a range of ±10% amplitude variation.

[0057] By combining the above three types of data augmentation operations, this invention constructs multiple positive sample perspectives with consistent structures but different numerical perturbations during the self-supervised comparative learning stage, guiding the model to focus on the stable structural features of the photovoltaic system in the time domain, frequency domain, and residual domain.

[0058] Step S2-2: Feed the normal samples and enhanced samples into the encoder to perform three-domain modeling.

[0059] This invention constructs time-domain encoders respectively Frequency domain encoder and residual domain encoder It is used to extract features from the same window of data in different domains.

[0060] (1) Time domain encoder Directly using window samples As input, features are embedded through linear mapping or one-dimensional convolution to preserve the overall trend structure of photovoltaic variables over time, which is expressed as follows:

[0061]

[0062] in This represents a time-domain feature mapping operator used to characterize the operating trajectory of a photovoltaic system within a window.

[0063] (2) Frequency domain encoder : For window samples Performing a discrete Fourier transform along the time dimension yields the spectral representation. The specific form of the discrete Fourier transform is consistent with the discrete Fourier transform defined in step S2-1 for frequency domain perturbation enhancement:

[0064]

[0065] Subsequently, the components at each discrete frequency point in the spectrum are calculated. amplitude The set of amplitudes of each component is then constructed as a real-valued input matrix in the frequency domain. Through frequency domain feature mapping operator Extracting the dominant frequency and energy distribution characteristics, its form is as follows:

[0066]

[0067] in, It is a frequency domain feature mapping operator used to extract the dominant frequency and energy distribution information in the spectral amplitude.

[0068] (3) Residual domain encoder To characterize disturbances beyond cyclical trends, trend separation is first performed on the window samples. This is achieved by using samples of length... The moving average operator is used to extract slowly varying trend components:

[0069]

[0070] in Let be the slowly varying trend vector of the i-th window at the t-th time step. The half-window length is the moving average; in this embodiment, it is taken as... =4. Subsequently, a residual signal is constructed based on this trend component. :

[0071]

[0072] in This represents the residual signal matrix obtained after trend separation of the i-th window, used to characterize the slow-varying trend component in the original multivariate time series. High-frequency / perturbation components.

[0073] By performing feature mapping on the residual signal, we obtain the feature representation in the residual domain:

[0074]

[0075] This residual domain feature is used to reflect small fluctuations, long-term drift, or irregular disturbances in the photovoltaic system outside of the stable period.

[0076] The above All of these are feature mapping operators designed uniformly in this invention, used to map input data into high-dimensional feature representations. Specifically, each operator consists of three one-dimensional convolutional networks. The convolutional kernels slide along the time or frequency dimension, with output channels of 16, 32, and 64 respectively. ReLU activation and batch normalization are applied after each convolutional layer, ultimately maintaining alignment with the input time step, resulting in an output feature dimension of 64. Finally, data from the same time window is mapped into three structured inputs in the time domain, frequency domain, and residual domain. , , :

[0077]

[0078] The augmented samples are processed using the same three-domain decomposition and encoding procedure as the original window to obtain the three-domain feature representation from the augmentation perspective:

[0079]

[0080] Step S2-3: Self-supervised contrastive learning and confidence score generation. Based on the above three-domain structural modeling, self-supervised contrastive learning is introduced to enhance the encoder's ability to represent structural consistency.

[0081] This invention employs self-supervised comparative learning of three-domain representations to ensure cross-domain consistency of the model's learning data. This invention uses data before and after enhancement within the same window (…). and ) are positive sample pairs, and data from different windows are used to construct negative sample pairs. and This invention explicitly introduces a three-domain consistency regularization term derived from photovoltaic physics into the contrast loss, defining the contrast loss as follows:

[0082]

[0083] The first term is the cross-domain contrast loss. Represents an exponential function; This represents the representation vector of the current sample in the corresponding feature domain; This represents the positive sample representation vector obtained by data augmentation of samples from the same window. This represents the negative sample representation vectors from different windows. This represents the set of samples used in the comparative loss calculation. Cosine similarity represents multivariate features. τ is a temperature parameter used to control the smoothness of the similarity distribution; in this embodiment, τ is set to 0.5. (Second item) The three-domain consistent positive sample constraint loss proposed in this invention is used as a regularization constraint added to the loss function during model training; As the weight, in this embodiment, we take... =0.3. This regularization term is used to constrain the physical characteristics of the photovoltaic system, namely "stable daily cycle trend, concentrated main frequency energy, and weak periodic drift of residuals". The specific expression is as follows:

[0084]

[0085] Wherein, α, β and γ are the weight coefficients of the three consistency constraint sub-items, which are used to control the contribution of each sub-item to the three-domain consistency regularization term. In this embodiment, α=0.4, β=0.3 and γ=0.3 are taken. The Frobenius norm is defined as the square root of the sum of the squares of all elements in a matrix; when the operator result is a scalar (i.e., a periodic component extraction operator). )hour, It is the sum of squares of the differences between the components.

[0086] The time trend operator can be defined as the first-order difference along the time dimension.

[0087]

[0088] in For time location indexing. This operator is used to extract time-domain features. Extracting the slope information that changes over time reflects whether the feature is rising, falling, or remaining stable at adjacent moments, thus characterizing typical time patterns such as a gradual increase in photovoltaic power in the morning, a near-plateau at noon, and a gradual decrease in the evening. If within a certain window... The occurrence of abnormally drastic positive and negative fluctuations indicates that the power generation behavior during that period is inconsistent with the normal daily cycle trend, and there may be a sudden blockage or failure.

[0089] The spectral energy change operator is defined as a first-order difference along the frequency axis:

[0090]

[0091] in, This represents the frequency position corresponding to the m-th discrete frequency point. Let represent the frequency bit corresponding to the (m-1)th discrete frequency point, and M represent the total number of discrete points of the frequency domain feature in the frequency dimension. This operator is used to describe the frequency domain feature in different frequency components. The energy changes on the system. Its dominant frequency energy distribution can reflect the low-frequency components dominated by the diurnal cycle under normal operating conditions of the photovoltaic system, as well as the high-frequency disturbances that occur under abnormal operating conditions. If the time-domain fluctuations or frequency-domain fluctuations are severe, It will get bigger.

[0092] The frequency domain periodic component extraction operator is used to aggregate energy at the dominant frequency and its harmonics.

[0093]

[0094] in It is a frequency domain feature Or features obtained from residuals through frequency domain transformation. This represents the target frequency set corresponding to the periodic components of the photovoltaic system, used to select discrete frequency points related to the dominant frequency of the daily cycle and its lower-order harmonics. This operator is used to... and Extracting the principal periodic component related to the photovoltaic diurnal cycle, and measuring the strength and consistency of the "diurnal cycle component" in different domains. If and The significant difference indicates that the periodic structure reflected in the frequency domain does not match the periodic drift that should exist in the residual, which may correspond to structural problems such as abnormal operating conditions.

[0095] For the trend recovery operator, a length of [length missing] is used. The moving average yields:

[0096]

[0097] in, Indicates the residual characteristics In the The output value obtained after trend recovery at each position; Representing residual characteristics In the The feature values ​​at each position; pos is the summation index within the moving average window; L is the moving average window length of the trend recovery operator, used to control the smoothing range of trend recovery; This is the time location index, representing the feature location currently being calculated for trend recovery; this operator is used to extract data from residual features. The corresponding slowly varying trend contour is recovered and mapped to the temporal features. The same trend represents space, so as to be consistent with Compare them one by one. If A smaller value indicates that the implicit trend in the residuals is consistent with the explicit trend in the time domain; conversely, a larger value indicates anomalies such as overall shift, long-term decay, or trend distortion.

[0098] This consistency constraint function ensures that the three-domain features conform to the actual physical laws of the photovoltaic system, resulting in stronger structural consistency in cross-domain features and enhancing the model's sensitivity to photovoltaic-specific anomalies such as periodic perturbations and efficiency degradation. The encoder ultimately outputs a high-order three-domain feature representation that satisfies physical consistency.

[0099] The contrast loss of the three domains is calculated. Then, the weighted sum of the losses in the three domains is calculated. :

[0100]

[0101] in, These represent the contrast loss in the time domain, frequency domain, and residual domain, respectively. , , These represent the weighting coefficients for the contrast loss in the time domain, frequency domain, and residual domain, respectively, used to adjust the contribution of each domain's loss term to the overall loss. In this embodiment, we take... , , =1. The contrastive loss is calculated by substituting the features from each domain into the aforementioned contrastive loss function. Calculated.

[0102] The corresponding features are extracted by the time-domain encoder, frequency-domain encoder, and residual-domain encoder, respectively. Subsequently, this embodiment achieves preliminary fusion of cross-domain information through feature concatenation and linear mapping. Specifically, the structured features of the three domains are first concatenated along the feature dimensions to construct a high-dimensional joint feature matrix:

[0103]

[0104] This represents the constructed high-dimensional joint feature matrix; This represents a cascade operator executed along the feature dimensions, used to spatially combine the 64-dimensional feature vectors of the three domains to form a 64-dimensional array. High-dimensional feature representation with 3=192.

[0105] Subsequently, joint features Dimensionality reduction and interaction modeling are performed to obtain the final fused features. :

[0106]

[0107] in This is a linear projection layer. The fusion feature... By integrating the trend changes in the time domain, the energy distribution in the frequency domain, and the perturbation characteristics in the residual domain, a unified feature representation space is provided for subsequent window-level confidence calculation and point-level fine detection.

[0108] Subsequently, the fusion characteristics were analyzed. Perform time-dimensional global average pooling (GAP) to obtain the window vector. Then, cosine similarity and linear mapping are used to calculate the window confidence:

[0109]

[0110] in, Let be the cosine similarity function, and its specific definition is as follows:

[0111]

[0112] The center vector is obtained by taking the arithmetic mean of the window vectors v corresponding to all windows participating in contrastive learning in the training set during the training phase. The window-level confidence score... Used to measure the consistency between the current window and the normal operating mode, when A larger value indicates that the window conforms more to normal structural characteristics. A smaller value indicates that the window may be experiencing abnormal disturbances.

[0113] Step S3: Perform Transformer anomaly detection based on contrastive learning confidence.

[0114] like Figure 3 As shown, step S3 specifically includes:

[0115] Step S3-1: Use the Transformer structure to model the sequence relationship of each sliding window subsequence, which is used to examine the dependency relationship between each point in the input sequence, thereby characterizing the actual correlation structure inside the photovoltaic data.

[0116] Based on the settings in step S1-2, the photovoltaic data sampling interval in this example is: The number of time steps corresponding to a complete daily cycle is Each time step contains Individual variable features. This embodiment uses the standardized observation vector. The 5-dimensional observations at each time step are mapped to a hidden dimension dim=128 through a linear embedding layer to obtain the embedding sequence. ,Will Enter to A 3-layer Transformer encoder is used to obtain encoded features.

[0117] In the In the Transformer layer, linear projections are performed on the feature sequences to obtain the query matrix. AND key matrix ,in:

[0118]

[0119] Simultaneously calculate the correlation weight matrix between time points:

[0120]

[0121] in, This represents the attention weight matrix of the l-th layer Transformer. As a dimensionality scaling factor, this embodiment uses 8 attention heads for multi-head attention calculation, with each attention head having a feature dimension of [missing information]. The answer is 128 / 8 = 16. This means performing a normalization operation on each row so that the sum of the association weights of each point with all points is 1, thereby obtaining the mutual influence relationship between the points in the sequence.

[0122] By using Transformer to model sequence relationships, the model can simultaneously capture local dependencies and global association structures, providing a foundation for subsequent anomaly detection.

[0123] Step S3-2: Introduce a Gaussian-Fourier mixed periodic prior modeling mechanism with contrastive learning confidence modulation as a control object in the sequence association modeling in step S3-1.

[0124] This invention constructs a hybrid periodic prior with dynamically modulated confidence output from three-domain contrastive learning. This prior simultaneously incorporates temporal proximity constraints and periodic reference components, and its diffusion scale and periodic modulation intensity adaptively change with the structural consistency of the window in the time, frequency, and residual domains. This prior is introduced as an independent correlation distribution comparison, used to measure consistency with the sequence correlation distribution learned by the Transformer, rather than being directly used as an attention weight bias.

[0125] The nearest neighbor association bias is defined in Gaussian form as follows:

[0126]

[0127] in, For the current time step, For the target time step, Based on the diffusion scale, in this embodiment, we take The mod term represents the modulo operation. This Gaussian term is used to characterize a local correlation bias where "the closer the time, the stronger the correlation," which makes the prior distribution naturally tend to support the correlation between nearby time points while suppressing the direct correlation between distant time points.

[0128] The core confidence modulation function is defined as a linear mapping with strictly monotonically decreasing properties:

[0129]

[0130] in, The three-domain window confidence score output in step S2. As the modulation sensitivity hyperparameter, in this embodiment, we take... The physical constraint significance of this modulation mechanism lies in the fact that when the photovoltaic data within the window is normal and the consistency of the three-domain structure is high, that is... )hour The nearest neighbor bias is tightened to the basic scale. The model must establish clear long-range physical correlations to overcome prior constraints and accurately capture anomalies; when under cloudy conditions or changes in operating conditions leading to local non-stationarity and low confidence levels... )hour, Increase the variance of the Gaussian kernel adaptively, thereby weakening the prior constraint strength.

[0131] Furthermore, due to the strong periodicity of photovoltaic data, a Fourier period modulation term is additionally defined to better characterize this periodicity:

[0132]

[0133] Where b is the current time step and t is the target time step. For the Fourier modulation coefficients, in this example, we take... The modulation coefficient is used to control the strength of the influence of the periodic reference in the overall prior. This modulation term serves as a periodic alignment reference skeleton, making it easier for sequence associations to establish long-distance dependencies across periods through this prior association under normal operating conditions.

[0134] Combining the nearest neighbor correlation bias term and the periodic reference modulation term, the final hybrid prior correlation distribution is defined as follows:

[0135]

[0136] Through the above construction, the prior distribution maintains the bias characteristic dominated by local proximity association, while structurally retaining a weak periodic reference, so that it can serve as a baseline for abnormal association patterns without excessively restricting the model from learning long-range periodic dependencies that may exist under normal conditions.

[0137] Step S3-3: In this invention, the sequence correlation distribution learned by the Transformer in step S3-1 is used to characterize the actual dependencies between time points in the current photovoltaic time series, while the prior correlation constructed in step S3-2 is used to provide a correlation bias reference. By comparing the degree of consistency between the two, it can be determined whether the behavior at the current time point deviates from the typical operating mode of the photovoltaic system.

[0138] In the In the Transformer layer, sequence association distribution is utilized. Characterize the actual dependencies at the current time point, while utilizing prior distributions. As a structural reference, the degree of agreement between the two is measured using the Jensen–Shannon difference:

[0139]

[0140] in Represents the attention matrix of the l-th layer The t-th row represents the association weight distribution of all time steps within the window when time point t is used as the query position; This represents the prior association distribution of all time steps within the window, with t as the current time step.

[0141] The Jensen–Shannon difference is used to measure the degree of deviation between the two associated distributions in the overall shape, and it is defined as follows:

[0142]

[0143] Here, A and B are two discrete probability distributions defined on the same set of indices. For the position index in the index set, Indicates that distribution A is in the th order. The values ​​at each index position, in this embodiment, are of sequence-related distribution. ; Indicates that distribution B is in the th order. The values ​​at each index position, in this embodiment, are a prior distribution. It possesses symmetry and numerical stability, enabling it to interpret the actual sequence association structure learned by the Transformer. Related structures with prior knowledge Explicit comparisons enable the model to identify whether the correlation patterns at the current time point deviate from the typical operating rules of the photovoltaic system, thus providing a reliable basis for the identification of structural anomalies.

[0144] Subsequently, the association consistency metric will be used. Summation, constructing the correlation consistency loss :

[0145]

[0146] Where l=1,2,3 are the layer indices of the Transformer (corresponding to the 3-layer Transformer encoder described in step S3-1), and w is the window length, i.e. The attention differences across the three layers are accumulated over all time steps within the window, and then normalized by the layer number to jointly optimize the correlation structure of each layer during training.

[0147] Step S3-4: While completing the sequence association modeling, the Transformer reconstructs the input time series to characterize the model's ability to represent and recover the original photovoltaic data. The reconstruction error is defined as:

[0148]

[0149] in, This represents the observation vector after standardization in step S1-1. This represents the reconstructed output of the Transformer at this time step, summed over all N time steps within the window. Under normal operating conditions, photovoltaic time series exhibits relatively stable statistical characteristics and structural patterns, allowing the model to reconstruct the input data well with small reconstruction errors. However, under abnormal conditions, due to changes in data distribution or structure, the model's ability to reconstruct abnormal patterns decreases, and the reconstruction error increases accordingly. Therefore, reconstruction error can serve as an important indicator reflecting the degree of anomaly.

[0150] The final loss function, which combines the structure distribution loss and reconstruction error, can be written as:

[0151]

[0152] in, These are weighting coefficients used to balance reconstruction accuracy and the ability to discriminate related structures. In this embodiment... We set the value to 0.2. The model is trained by minimizing the joint loss function described above, and the Adam optimizer is used to update the model parameters.

[0153] Step S4: Comprehensive Anomaly Detection Phase

[0154] Step S4 specifically includes:

[0155] Step S4-1: Window-level anomaly candidate screening based on dual-condition triggering:

[0156] The final window confidence score is output based on the three-domain comparative learning. ,definition This represents the window anomaly score. To avoid invalid global inference, this embodiment first sets a confidence safety threshold. (In this embodiment, the value is set to 0.85), only extracting... The window is designated as a suspected high-risk window; subsequently, if the total number of high-risk windows in the current time period exceeds the preset constraint limit... (This embodiment takes) =3), then only abnormal scores are truncated. Top The windows constitute the final candidate window set. If no window is below the threshold If no abnormality is found in that cycle, the subsequent Transformer detection process is skipped. This specific rule ensures a lower bound on the missed detection rate while allowing the system's computational load to adapt to the power plant's operating conditions.

[0157] Step S4-2: The above-mentioned abnormal candidate window set In this process, the Transformer model is used to perform fine-grained detection of time points within the window. For each time point t within the candidate window, anomaly evaluation is performed from the following two perspectives:

[0158] (1) Structural anomaly score :

[0159]

[0160] Where l is taken as the last layer of Transformer (i.e. Attention matrix. The structural anomaly score is used to assess whether structural dependencies at a given time point have shifted abruptly by comparing the differences between the sequence association structure learned by the model and the prior structure. This score reflects anomalous changes in temporal association patterns.

[0161] (2) Numerical reconstruction of outlier scores :

[0162]

[0163] in, The outlier score is reconstructed numerically by comparing the reconstruction results of the Transformer at time point t. With standardized observation vector The differences between them are used to assess whether the numerical value at that point in time deviates from the normal operating mode.

[0164] The two types of indicators described above characterize the abnormal features at a given time point from the structural and numerical levels, respectively, and are highly complementary.

[0165] Step S4-3: Fraction normalization and multi-granularity fusion:

[0166] Window anomaly score Structural anomaly score Numerical reconstruction of abnormal scores Normalization is performed (normalized to [0,1]). In this embodiment, min–max normalization is used, which involves subtracting the minimum value from each score within the detection time period and dividing by the difference between the maximum and minimum values ​​to eliminate the influence of differences in the dimensions of different scores on the fusion result. The overall fusion is as follows:

[0167]

[0168] in , This is a weighting coefficient used to adjust the weight of each outlier score; in this embodiment, it is taken as... ; This is the index of the window to which time step t belongs, that is, mapping the time step to the sliding window number it belongs to; This represents the three-domain confidence score corresponding to the window.

[0169] Step S4-4: Outlier Filtering and Outlier Range Output:

[0170] Fusion anomaly scores at each time point of the entire sequence Sort the data in descending order and select the n time points with the highest scores as the set of outliers, defined as:

[0171]

[0172] in, This is the outlier ratio parameter. This represents the total number of time steps in the time series to be detected. In this embodiment, The value is set to 0.05, meaning that the top 5% of time points with the highest scores are selected as outliers. The reason for choosing this ratio is that the percentage of labeled outlier intervals is approximately 10% in the training set. Considering that the fusion score ranking has strong discriminative power at the head, setting ρ=0.05 can concentrate the selected outliers in the head interval where the outlier score distribution is most significant, thus achieving stable recall of core outlier events while maintaining high accuracy.

Claims

1. A photovoltaic timing anomaly detection method based on self-supervised three-domain contrastive learning and joint prior modulation Transformer, characterized in that, Includes the following steps: Step 1: Collect multivariate time series data of the photovoltaic system. The multivariates include power, performance ratio, irradiance, temperature and inverter efficiency. Then, perform standardization processing and use a sliding window mechanism to divide the series into multiple fixed-length subsequences as analysis windows. Step 2: Perform multivariate synchronous data augmentation on the obtained window samples. The original window and the augmented window are fed into a three-domain encoder consisting of a time-domain encoder, a frequency-domain encoder, and a residual-domain encoder, respectively. The structured features of each window in the time domain, frequency domain, and residual domain are extracted. Through self-supervised contrastive learning, the features before and after augmentation of the same window are used as positive sample pairs, and the features of different windows are used as negative sample pairs. Combined with a three-domain consistency regularization term used to constrain the daily cycle trend stability, main frequency energy concentration, and weak periodic drift of the residual of the photovoltaic system, the three-domain encoder is trained. The trained encoder is used to calculate the structural consistency between each window and the normal operation mode to obtain the window-level confidence score, and abnormal candidate windows are selected based on the score. Step 3: For the selected abnormal candidate windows, the Transformer model is used to model the sequence relationship and calculate the actual correlation distribution between each time point within the window; at the same time, a hybrid periodic prior correlation distribution is constructed, which is dynamically modulated by the window-level confidence score; the hybrid periodic prior correlation distribution integrates the local temporal proximity bias and the periodic reference structure, and the constraint strength is adaptively weakened as the window confidence decreases. The structural anomaly score at each time point is obtained by calculating the difference between the actual association distribution and the prior association distribution; Step 4: Generate a comprehensive anomaly score for each time point, and sort and filter to find the final anomalies.

2. The photovoltaic timing anomaly detection method based on self-supervised three-domain contrastive learning and joint prior modulation Transformer according to claim 1, characterized in that, In step 2, the data augmentation is as follows: noise perturbation, frequency domain perturbation, and amplitude scaling operations are applied synchronously to all variables within the window to simulate sensor noise, period offset, and non-fault perturbations of overall irradiance variation in the actual operation of the photovoltaic system, forcing the contrastive learning model to focus on the invariant physical structure and periodic patterns in the data.

3. The photovoltaic timing anomaly detection method based on self-supervised three-domain contrastive learning and joint prior modulation Transformer according to claim 1, characterized in that, In step 2, the time-domain encoder is used to directly extract the trend change features of the original sequence within the window; the frequency-domain encoder extracts the main frequency and energy distribution features of the window data through Fourier transform. Its residual domain encoder extracts residual perturbation features by separating trend components from the original sequence.

4. The photovoltaic timing anomaly detection method based on self-supervised three-domain contrastive learning and joint prior modulation Transformer according to claim 3, characterized in that, The three-domain consistency regularization term consists of a weighted sum of three constraints, used to constrain the structured features of the time-domain encoder, frequency-domain encoder, and residual-domain encoder to satisfy the following physical consistency during the contrastive learning process: The first constraint minimizes the deviation between the first-order difference of the time-domain feature along the time dimension and the first-order difference of the frequency-domain feature along the frequency dimension at the corresponding index positions, making the local change slope of the time-domain trend and the cross-frequency change slope of the frequency-domain energy tend to be consistent; The second constraint minimizes the deviation between the energy components obtained by aggregating the frequency-domain features and the residual-domain features on the index sets corresponding to the diurnal fundamental frequency and its harmonics, respectively, making the diurnal dominant frequency component in the frequency domain match the periodic drift component contained in the residual signal in terms of energy distribution; The third constraint minimizes the deviation between the slowly varying trend profile recovered by the residual features through a moving average operator of a preset length and the time-domain features, making the trend profile recovered by the residual domain synchronized with the original time-domain trend.

5. The photovoltaic timing anomaly detection method based on self-supervised three-domain contrastive learning and joint prior modulation Transformer according to claim 1, characterized in that, In step 3, the hybrid periodic prior correlation distribution consists of a Gaussian local term and a Fourier periodic term. The Gaussian local term uses the distance between the current time step and the target time step after modulo operation under the photovoltaic main cycle as the independent variable, and the product of the basic diffusion scale and the confidence modulation function value as the variance. It is used to characterize the local proximity bias in the prior that "the closer the time distance, the stronger the correlation". The Fourier periodic term consists of the preset Fourier modulation coefficient and the cosine of the difference between the current time step and the target time step under the photovoltaic main cycle normalization. It is used to embed a weak periodic reference structure across cycles in the prior. The confidence modulation function takes the window-level confidence score output in step 2 as input and is defined as a monotonically decreasing linear function of the confidence score.

6. The photovoltaic timing anomaly detection method based on self-supervised three-domain contrastive learning and joint prior modulation Transformer according to claim 5, characterized in that, In step 3, when the window-level confidence score is high, the confidence modulation function approaches 1, the variance of the Gaussian local term is tightened to the basic diffusion scale, and the local constraint range of the prior distribution is correspondingly tightened, prompting the Transformer to establish accurate long-range dependencies that are significantly different from the prior. When the window-level confidence score is low, the confidence modulation function increases, the variance of the Gaussian local term is adaptively widened, and the local constraint range of the prior distribution is correspondingly widened. For each time point within the anomaly candidate window, the Jensen-Shannon divergence between the actual correlation distribution output by the Transformer and the mixed periodic prior correlation distribution is calculated to obtain the difference value characterizing the deviation between the actual correlation distribution output by the Transformer and the mixed periodic prior correlation distribution, and the difference value is used as the structural anomaly score of the time point.

7. The photovoltaic timing anomaly detection method based on self-supervised three-domain contrastive learning and joint prior modulation Transformer according to claim 1, characterized in that, Step 4 is as follows: A hierarchical strategy combining window-level coarse screening and in-window fine detection is adopted: First, a computationally efficient three-domain contrastive learning model is used to quickly screen all windows, and then high-risk abnormal candidate windows are sent to the Transformer model for fine detection.

8. The photovoltaic timing anomaly detection method based on self-supervised three-domain contrastive learning and joint prior modulation Transformer according to claim 7, characterized in that, The process of feeding anomaly candidate windows into the computationally complex Transformer model for fine-grained detection is as follows: By comparing the differences between the sequence association structure learned by the model and the prior structure, the structural dependencies at time points are evaluated to determine whether there are anomalous shifts, resulting in a structural anomaly score. The structural anomaly score reflects anomalous changes in the temporal association pattern. By comparing the differences between the Transformer's reconstruction results at time points and the original observations, the numerical reconstruction anomaly score is evaluated to determine whether the time points deviate from the normal operating mode at the numerical level. The window anomaly score, structural anomaly score, and numerical reconstruction anomaly score, obtained based on the confidence score, are normalized to generate a comprehensive anomaly score.