-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathErrorCorrection.py
39 lines (32 loc) · 982 Bytes
/
ErrorCorrection.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
import datetime
import time
import numpy as np
import pandas as pd
from operator import and_
from operator import not_
ct_df = pd.read_csv('correct_tags.csv')
correct_tags = ct_df.loc[:,"powerStatus":"exit1"].values
temp = np.asarray(ct_df.columns)
tag_names = np.delete(temp,0)
def all_check(tag_list):
return sum(tag_list)
def mul(a,b): #Returns 1 if both values are same
if a == b:
return 1
else:
return 0
def mat_mul(mat1,mat2):
row1,col1 = mat1.shape
row2,col2 = mat2.shape
op_mat = np.zeros((row1,col2))
if (col1 == row2):
for i in range(row1):
for j in range(col2):
op_mat[i][j] = sum(list(map(mul,mat1[i,:],mat2[:,j])))
return op_mat
def faults(tags,time_val):
op = list(map(mul,tags,list(correct_tags[time_val,:])))
if all_check(op) != len(tags):
faults = list(map(bool,op))
faults = list(map(not_,faults))
print('Faults at:',tag_names[faults])