-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate_data.py
executable file
·51 lines (39 loc) · 1.14 KB
/
validate_data.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
#!/usr/bin/python
# opens a given file and makes sure that the relation between
# control power and load speed is monotonic
# So we check that when control power changes, load speed does not decrease
import pandas as pd
import sys
def check_match(spdIncreasing, pwrIncreasing):
if spdIncreasing is not None and pwrIncreasing is not None:
if spdIncreasing != pwrIncreasing:
if spdIncreasing:
print "ERR: Speed increased while power decreased"
sys.exit(1)
else:
print "ERR: Speed decreased while power increased"
sys.exit(1)
if __name__ == '__main__':
if len(sys.argv) != 2:
print "arg format: input_data"
sys.exit(1)
df = pd.read_csv(sys.argv[1], sep='\t')
pwrIncreasing = None
spdIncreasing = None
curPwr = None
for i, time in enumerate(df.Time):
if curPwr is None:
curPwr = df.CtrlPwr[i]
curSpd = df.LdSpd[i]
else:
prevPwr = curPwr
prevSpd = curSpd
if curPwr > prevPwr:
pwrIncreasing = True
if curPwr < prevPwr:
pwrIncreasing = False
if curSpd > prevSpd:
spdIncreasing = True
if curSpd < prevSpd:
spdIncreasing = False
check_match(spdIncreasing, pwrIncreasing)