Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDataProcess.py
More file actions
258 lines (187 loc) · 9.18 KB
/
Copy pathDataProcess.py
File metadata and controls
258 lines (187 loc) · 9.18 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# -*-coding:utf-8-*-
import os
import time
from threading import Thread
import scipy.io as scio
import numpy as np
from DataProcessing.CsiToAmplitudeAndPhase import getAmplitudesAndPhasesLength
from DataProcessing.DataCalculate import DataCalculate
from DataProcessing.Normalize import Normalize
def dataProcessOfFixedFiles(path, path_p, path_ap, path_p2, path_ap2, doneN, totalN,
begin_time): # path:.../new targetpath:../demo.tfrecords
files2 = os.listdir(path)
for f2 in files2:
# f2:eatting settig ...
files3 = os.listdir(path + '/' + f2)
for f3 in files3:
# f3:1 2 3...
l = int(f3) - 1
files4 = os.listdir(path + '/' + f2 + '/' + f3)
for f4 in files4:
if '.mat' in f4:
# f4:1_1.mat 2_2.mat...
result = DataCalculate(path + '/' + f2 + '/' + f3 + '/' + f4)
'''
经过去噪等算法处理之后的数据
'''
ap = result[0]
p = result[1]
ap2 = result[2]
p2 = result[3]
N = result[4]
label = [l] * N
ap = ap.reshape(N, -1)
ap2 = ap2.reshape(N, -1)
p = p.reshape(N, -1)
p2 = p2.reshape(N, -1)
# 拼接后的数据
# x = np.concatenate((ap.reshape(N, -1), p.reshape(N, -1)), axis=1)
# lenght = x.shape[0]
for i in range(N):
ap[i] = Normalize(ap[i])
p[i] = Normalize(p[i])
ap2[i] = Normalize(ap2[i])
p2[i] = Normalize(p2[i])
scio.savemat(path_ap + '/' + f2 + '-' + f3 + '-' + f4, {'x': ap, 'y': label})
scio.savemat(path_ap2 + '/' + f2 + '-' + f3 + '-' + f4, {'x': ap2, 'y': label})
scio.savemat(path_p + '/' + f2 + '-' + f3 + '-' + f4, {'x': p, 'y': label})
scio.savemat(path_p2 + '/' + f2 + '-' + f3 + '-' + f4, {'x': p2, 'y': label})
doneN += N
now_time = time.time()
secod = round(now_time - begin_time, 2)
fenzhong = int(secod / 60)
secod = round(secod - fenzhong * 60, 2)
xiaoshi = int(fenzhong / 60)
fenzhong = fenzhong - xiaoshi * 60
persent = round((doneN / totalN) * 100, 2)
str1 = '已进行:' + str(persent) + '% 用时:' + str(xiaoshi) + '小时' + str(fenzhong) + '分钟' + str(
secod) + '秒 预计还需:'
secod = int((secod * totalN) / doneN)
fenzhong = int(secod / 60)
secod = secod - fenzhong * 60
xiaoshi = int(fenzhong / 60)
fenzhong = fenzhong - xiaoshi * 60
str2 = str(xiaoshi) + '小时' + str(fenzhong) + '分钟' + str(secod) + '秒'
print str1 + str2 + 'dataProcessOfFixedFiles-' + f2 + '-' + f3 + '-' + f4
print 'success:' + path
def dataProcessOfOpenAndSemiFiles(path, path_p, path_ap, path_p2,
path_ap2, doneN, totalN,
begin_time): # path:.../new targetpath:../demo.tfrecords
files3 = os.listdir(path)
for f3 in files3:
# f3:1 2 3...
files4 = os.listdir(path + '/' + f3)
l = int(f3) - 1
for f4 in files4:
if '.mat' in f4:
# f4:1_1.mat 2_2.mat...
result = DataCalculate(path + '/' + f3 + '/' + f4)
ap = result[0]
p = result[1]
ap2 = result[2]
p2 = result[3]
N = result[4]
label = [l] * N
ap = ap.reshape(N, -1)
ap2 = ap2.reshape(N, -1)
p = p.reshape(N, -1)
p2 = p2.reshape(N, -1)
# 拼接后的数据
# x = np.concatenate((ap.reshape(N, -1), p.reshape(N, -1)), axis=1)
# lenght = x.shape[0]
for i in range(N):
ap[i] = Normalize(ap[i])
p[i] = Normalize(p[i])
ap2[i] = Normalize(ap2[i])
p2[i] = Normalize(p2[i])
scio.savemat(path_ap + '/' + f3 + '-' + f4, {'x': ap, 'y': label})
scio.savemat(path_ap2 + '/' + f3 + '-' + f4, {'x': ap2, 'y': label})
scio.savemat(path_p + '/' + f3 + '-' + f4, {'x': p, 'y': label})
scio.savemat(path_p2 + '/' + f3 + '-' + f4, {'x': p2, 'y': label})
doneN += N
now_time = time.time()
secod = round(now_time - begin_time, 2)
fenzhong = int(secod / 60)
secod = round(secod - fenzhong * 60, 2)
xiaoshi = int(fenzhong / 60)
fenzhong = fenzhong - xiaoshi * 60
persent = round((doneN / totalN) * 100, 2)
str1 = '已进行:' + str(persent) + '% 用时:' + str(xiaoshi) + '小时' + str(fenzhong) + '分钟' + str(
secod) + '秒 预计还需:'
secod = int((secod * totalN) / doneN)
fenzhong = int(secod / 60)
secod = secod - fenzhong * 60
xiaoshi = int(fenzhong / 60)
fenzhong = fenzhong - xiaoshi * 60
str2 = str(xiaoshi) + '小时' + str(fenzhong) + '分钟' + str(secod) + '秒'
print str1 + str2 + 'dataProcessOfOpenAndSemiFiles-' + path + '-' + f3 + '-' + f4
print('success:' + path)
def getSemiOrOpenLength(path):
N = 0
files3 = os.listdir(path)
for f3 in files3:
# f3:1 2 3...
files4 = os.listdir(path + '/' + f3)
l = int(f3) - 1
for f4 in files4:
if '.mat' in f4:
N += getAmplitudesAndPhasesLength(path + '/' + f3 + '/' + f4)
return N
def getDataLength(fixed_path, open_path, semi_path):
N = 0
files2 = os.listdir(fixed_path)
for f2 in files2:
# f2:eatting settig ...
files3 = os.listdir(fixed_path + '/' + f2)
for f3 in files3:
# f3:1 2 3...
l = int(f3) - 1
files4 = os.listdir(fixed_path + '/' + f2 + '/' + f3)
for f4 in files4:
if '.mat' in f4:
# print('dataProcessOfFixedFiles-' + f2 + '-' + f3 + '-' + f4)
# f4:1_1.mat 2_2.mat...
N += getAmplitudesAndPhasesLength(fixed_path + '/' + f2 + '/' + f3 + '/' + f4)
print 'N of fixed:' + str(N)
N2 = getSemiOrOpenLength(open_path)
print 'N of open:' + str(N2)
N3 = getSemiOrOpenLength(semi_path)
print 'N of semi:' + str(N3)
return N + N2 + N3
if __name__ == '__main__':
'''
N of fixed:39600968
N of open:7476236
N of semi:12373101
total N:59450305
'''
path_fixed = '/media/xue/软件/CSI/RawMatData/fixed'
path_open = '/media/xue/软件/CSI/RawMatData/open'
path_semi = '/media/xue/软件/CSI/RawMatData/semi'
# N = getDataLength(path_fixed, path_open, path_semi)
# print 'total N:' + str(N)
beagin_time = time.time()
'''
dataProcessOfFixedFiles(path='/media/xue/软件/CSI/RawMatData/fixed',
path_ap='/media/xue/软件/CSI/MatData/AmplitudeWithOutNoiseRemoval',
path_ap2='/media/xue/软件/CSI/MatData/AmplitudeWithNoiseRemoval',
path_p='/media/xue/软件/CSI/MatData/PhaseWithOutNoiseRemoval',
path_p2='/media/xue/软件/CSI/MatData/PhaseWithNoiseRemoval',
begin_time=beagin_time, doneN=0, totalN=59450305)
'''
'''
dataProcessOfOpenAndSemiFiles(path='/media/xue/Data Storage/CSI/RawMatData/open',
path_ap='/media/xue/Data Storage/CSI/MatData/AmplitudeWithOutNoiseRemoval',
path_ap2='/media/xue/Data Storage/CSI/MatData/AmplitudeWithNoiseRemoval',
path_p='/media/xue/Data Storage/CSI/MatData/PhaseWithOutNoiseRemoval',
path_p2='/media/xue/Data Storage/CSI/MatData/PhaseWithNoiseRemoval',
begin_time=beagin_time, doneN=39600968, totalN=59450305
)
'''
dataProcessOfOpenAndSemiFiles(path='/media/xue/Data Storage/CSI/RawMatData/semi',
path_ap='/media/xue/Data Storage/CSI/MatData/AmplitudeWithOutNoiseRemoval',
path_ap2='/media/xue/Data Storage/CSI/MatData/AmplitudeWithNoiseRemoval',
path_p='/media/xue/Data Storage/CSI/MatData/PhaseWithOutNoiseRemoval',
path_p2='/media/xue/Data Storage/CSI/MatData/PhaseWithNoiseRemoval',
begin_time=beagin_time, doneN=39600968 + 7476236, totalN=59450305
)
You can’t perform that action at this time.
