-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeekly_Power_Patterns.m.txt
117 lines (97 loc) · 4.59 KB
/
Weekly_Power_Patterns.m.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
clear; clc; close all; % clear:clean workspace, clc:clean command window, close all:close all currently open figures
%% -------------- Load data -------------------------------
%Download the CSV files of each circuit and the aggregate data from (Website)
%and upload the CSV files from 4 Oct to 11 Oct folder.
%You may change the data files from the folders. In this code, we will use the fourth folder for data visualization.
DBTG= readtable('DB TG.csv'); % The raw data of DB TG
DBT1= readtable('DB T1.csv'); % The raw data of DB T1
DBML1= readtable('DB ML 1.csv'); % The raw data of DB ML1
DBML2= readtable('DB ML 2.csv'); % The raw data of DB ML2
CPAC= readtable('CP AC.csv'); % The raw data of CP AC
EMSB1= readtable('EMSB 1.csv'); % The raw data of EMSB1
SSBMF= readtable('SSB MF.csv'); % The raw data of SSB MF
Agg= readtable('Aggregate.csv'); % The raw data of aggregate power
%% -------------- % The raw data of Phase A, B, and C-----------------
% The data in Excel files includes several parameters.
% real power columns: phase A= 12; phase B= 13; phase C= 14.
% Create the active power data based on phase A in separate tables.
TGA=DBTG{:,12};
T1A=DBT1{:,12};
ML1A=DBML1{:,12};
ML2A=DBML2{:,12};
ACA=CPAC{:,12};
EMSB1A=EMSB1{:,12};
MFA=SSBMF{:,12};
AggA=Agg{:,12};
%Create the active power data in separate tables for Phase B
TGB=DBTG{:,13};
T1B=DBT1{:,13};
ML1B=DBML1{:,13};
ML2B=DBML2{:,13};
ACB=CPAC{:,13};
EMSB1B=EMSB1{:,13};
MFB=SSBMF{:,13};
AggB=Agg{:,13};
%Create the active power data in separate tables for Phase C
TGC=DBTG{:,14};
T1C=DBT1{:,14};
ML1C=DBML1{:,14};
ML2C=DBML2{:,14};
ACC=CPAC{:,14};
EMSB1C=EMSB1{:,14};
MFC=SSBMF{:,14};
AggC=Agg{:,14};
%% -------------- Sampling frequency, time, and number of samples -----------------------
fs=1; % intrval frequency
ts=1/fs; % Sampling time is 1 second
L=length(AggA); % The length of the signal
t=(0:L-1)/fs; % The time require for block data t=N/fs
hold on
N=numsamples(t); % The number of the samples is 519001 = (5d*24*60*60)+10min*60sec
%% -------------- Plotting the aggregate power consumption for circuits Based on Phase A --------------------
% To visualize the power patterns data in the dataset, we will create line plots for both circuits and the aggregate circuit.
%In the plot, the x-axis represents the readings of samples recorded during the six days,
% while the y-axis corresponds to the real power parameter.
% plot the power data from circuit 1 to circuit 7 and the aggregate circuit
subplot(3,1,1) % create the sub-plot with 3 rows and 1 column
plot(t,TGA,t,T1A,t,ML1A,t,ML2A,t,ACA,t,EMSB1A,t,MFA,t,AggA,'k')
xticks([43200 129600 216000 302400 388800 475200])
xticklabels({'5 Oct','6 Oct','7 Oct','8 Oct','9 Oct', '10 Oct'}) % Label xtick at every 12 hours
xlim([0-500 518400+500])
yticks([10000 20000 30000])
yticklabels({'10','20','30'})
ylabel('Active power (kW)','FontSize', 12) %Label the y-axis as active power parameter
title('Phase A','FontSize', 12) %name the title based on the phase
x=[86400 172800 259200 345600 432000]; % Draw a vertical dashed line for each day
xline(x,'--k')
grid, grid minor
%Put eight legends based on the number of circuits
legend({'DB TG','DB T1','DB ML1','DB ML2','CP AC','EMSB 1','SSB MF','Aggregate'},'NumColumns',8)
%% -------------- Plotting the aggregate power consumption for circuits Based on Phase B --------------------
subplot(3,1,2)
plot(t,TGB,t,T1B,t,ML1B,t,ML2B,t,ACB,t,EMSB1B,t,MFB,t,AggB,'k')
xticks([43200 129600 216000 302400 388800 475200])
xticklabels({'5 Oct','6 Oct','7 Oct','8 Oct','9 Oct', '10 Oct'})
xlim([0-500 518400+500])
yticks([10000 20000 30000])
yticklabels({'10','20','30'})
ylabel('Active power (kW)','FontSize', 12)
title('Phase B','FontSize', 12)
x=[86400 172800 259200 345600 432000];
xline(x,'--k')
grid, grid minor
legend({'DB TG','DB T1','DB ML1','DB ML2','CP AC','EMSB 1','SSB MF','Aggregate'},'NumColumns',8)
%% -------------- Plotting the aggregate power consumption for circuits Based on Phase C --------------------
subplot(3,1,3)
plot(t,TGC,t,T1C,t,ML1C,t,ML2C,t,ACC,t,EMSB1C,t,MFC,t,AggC,'k')
xticks([43200 129600 216000 302400 388800 475200])
xticklabels({'5 Oct','6 Oct','7 Oct','8 Oct','9 Oct', '10 Oct'}) % Label xtick at every 12 hours
xlim([0-500 518400+500])
yticks([10000 20000 30000])
yticklabels({'10','20','30'})
ylabel('Active power (kW)','FontSize', 12)
title('Phase C','FontSize', 12)
x=[86400 172800 259200 345600 432000];
xline(x,'--k')
legend({'DB TG','DB T1','DB ML1','DB ML2','CP AC','EMSB 1','SSB MF','Aggregate'},'NumColumns',8)
grid, grid minor