-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQ_T_horizon_plot1_v2.py
82 lines (67 loc) · 3.88 KB
/
Q_T_horizon_plot1_v2.py
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
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
zone='20-601b-2'
## Ideal occ
#horizons=os.listdir(os.path.join('new_results','mpc_ideal_occ'))
horizons=['240','360','480','600']
Q_ideal_horizon=pd.DataFrame()
T_discomfort_ideal_horizon=pd.DataFrame()
for horizon in horizons:
Q_ideal_horizon['{}'.format(horizon)]=pd.read_csv(os.path.join('new_results','figs_ideal_occ_v2','{}_qr_200'.format(horizon),zone,'Q.csv'))['Q']
T_discomfort_ideal_horizon['{}'.format(horizon)]=pd.read_csv(os.path.join('new_results','figs_ideal_occ_v2','{}_qr_200'.format(horizon),zone,'T_discomfort.csv'))['T_vio']
## Predicted occ
Q_predicted_horizon=pd.DataFrame()
T_discomfort_predicted_horizon=pd.DataFrame()
for horizon in horizons:
Q_predicted_horizon['{}'.format(horizon)]=pd.read_csv(os.path.join('new_results','figs_predicted_occ_v2','{}_qr_200'.format(horizon),zone,'Q.csv'))['Q']
T_discomfort_predicted_horizon['{}'.format(horizon)]=pd.read_csv(os.path.join('new_results','figs_predicted_occ_v2','{}_qr_200'.format(horizon),zone,'T_discomfort.csv'))['T_vio']
Q_ideal=pd.DataFrame(Q_ideal_horizon.iloc[0]).set_index(np.arange(4,12,2)).rename(columns={0:'ideal_occ'})
Q_predicted=pd.DataFrame(Q_predicted_horizon.iloc[0]).set_index(np.arange(4,12,2)).rename(columns={0:'predicted_occ'})
Q=pd.concat([Q_ideal,Q_predicted],axis=1)
T_discomfort_ideal=pd.DataFrame(T_discomfort_ideal_horizon.iloc[0]).set_index(np.arange(4,12,2)).rename(columns={0:'ideal_occ'})
T_discomfort_predicted=pd.DataFrame(T_discomfort_predicted_horizon.iloc[0]).set_index(np.arange(4,12,2)).rename(columns={0:'predicted_occ'})
T_discomfort=pd.concat([T_discomfort_ideal,T_discomfort_predicted],axis=1)
Q_RBC=pd.read_csv(os.path.join('new_results','figs_rbc_Tc_Th_v2',zone,'Q.csv'))
T_RBC=pd.read_csv(os.path.join('new_results','figs_rbc_Tc_Th_v2',zone,'T_discomfort.csv'))
#plot energy consumption
plt.figure(figsize=(110,4),dpi=150)
ax=Q.plot.bar(rot=0)
plt.xlabel('Horizon [hour]')
plt.rc('font', size=12) # controls default text sizes
#plt.rc('axes', labelsize=14) # fontsize of the x and y labels
for x in Q.index.values:
plt.text((-0.28+(x-4)/2.), Q.at[x,'ideal_occ']+0.5, round(Q.at[x,'ideal_occ'],1))
plt.text(0.01+((x-4)/2.), Q.at[x,'predicted_occ']+0.5, round(Q.at[x,'predicted_occ'],1))
plt.axhline(y=Q_RBC['Q'].values, color='r', linestyle='--',label='RBC')
ax.legend(loc='upper center',
fancybox=True, shadow=True, ncol=3,fontsize=10)
#plt.xticks(np.arange(4,12,2))
plt.yticks(np.arange(0,80,10),fontsize=14)
plt.rc('ytick', labelsize=14)
plt.xticks(fontsize=14)
#plt.rc('xtick', labelsize=14) # fontsize of the tick labels
plt.ylabel('Energy consumption [kWh]',fontsize=16)
plt.xlabel('Horizon [hour]',fontsize=14)
plt.savefig(os.path.join('new_results','figs_MPC_ideal_vs_predicted_v2','20-601b-2','Q_total_bar_v2.pdf'))
#plot temperature discomfort
plt.figure(figsize=(30,4),dpi=150)
ax=T_discomfort.plot.bar(rot=0)
for x in T_discomfort.index.values:
plt.text((-0.25+(x-4)/2.), T_discomfort.at[x,'ideal_occ']+0.05, round(T_discomfort.at[x,'ideal_occ'],1))
plt.text((0.02+(x-4)/2.), T_discomfort.at[x,'predicted_occ']+0.05, round(T_discomfort.at[x,'predicted_occ'],1))
plt.axhline(y=T_RBC['T_vio'].values, color='r', linestyle='--',label='RBC')
ax.legend(loc='upper center',
fancybox=True, shadow=True, ncol=3,fontsize=10)
#plt.title('Temperature discomfort')
#plt.xticks(np.arange(4,12,2))
plt.yticks(np.arange(0,8,1))
plt.ylabel('Temperature discomfort [Kh]',fontsize=16)
plt.xlabel('Horizon [hour]',fontsize=14)
plt.rc('font', size=12) # controls default text sizes
plt.rc('axes', labelsize=14) # fontsize of the x and y labels
#plt.rc('xtick', labelsize=14) # fontsize of the tick labels
plt.xticks(fontsize=14)
plt.rc('ytick', labelsize=14)
plt.savefig(os.path.join('new_results','figs_MPC_ideal_vs_predicted_v2','20-601b-2','T_discomfort_bar_v2.pdf'))