-
Notifications
You must be signed in to change notification settings - Fork 1
/
resolution.py
64 lines (46 loc) · 1.2 KB
/
resolution.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
import os
import numpy as np
import scipy.io as spio
import utility as util
from tqdm import tqdm
dirName = 'base_load'
if not os.path.exists(dirName):
os.mkdir(dirName)
print("Directory " , dirName , " Created ")
else:
print("Directory " , dirName , " already exists")
resolution = 2 # min
dirName+='/'+str(resolution)+'_min'
if not os.path.exists(dirName):
os.mkdir(dirName)
print("Directory " , dirName , " Created ")
else:
print("Directory " , dirName , " already exists")
resolution*=60
mat_path = 'PQ1DayF20.mat'
#resolution = 600 #sec
print('Loading .mat file...:')
mat = spio.loadmat(mat_path, squeeze_me=True)
temp = mat['P']
P = []
print('Loading P...:')
for i in tqdm(range(0,86400,resolution)):
P.append(temp[:, i])
P = np.array(P).T
temp = mat['Q']
Q = []
print('Loading Q...:')
for i in tqdm(range(0,86400,resolution)):
Q.append(temp[:, i])
Q = np.array(Q).T
resolution/=60
d = 60/resolution
for h in range(0,24):
dict_ = {}
s = int(h*d)
f = int(s+d)
dict_['P'] = P[:, s:f].tolist()
dict_['Q'] = Q[:, s:f].tolist()
save_file = dirName + '/h' + str(h) + '.txt'
util.save_dict(save_file, dict_)
print('Saved successfully')