-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweight.py
More file actions
67 lines (47 loc) · 1.96 KB
/
Copy pathweight.py
File metadata and controls
67 lines (47 loc) · 1.96 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
import math
from Distance import Distance
import numpy as np
from dataset import DataSet
class WeightCal(object):
def __init__(self):
self.rs = 0
@staticmethod
def weighted(rs_fil, rs_raw):
diff = rs_raw - rs_fil
if diff == 0: # Sometimes the filtered is equal to the raw value
diff = 1
snr = rs_raw/(rs_raw)
cf = np.convolve(diff, snr, "valid") # Check dimensions
d = Distance().get_distance(rs_fil)
d1 = Distance().get_distance(diff) # Dimensioning again
return rs_fil/d # Need Rechecking
def weight_median_based(self, halo, k):
a = DataSet(halo, k).rssi_filtered_
# Sort the RSSI values from each node, from node a to node c
node_a = sorted(a[0])
node_b = sorted(a[1])
node_c = sorted(a[2])
# Find the RSSI medium set for each node
# find the length 'n' of the set
# "t" is the length of the new developed set
# if the length of the set is equal to odd then use t =(n+1)/2
# if the length of the set is even then use the formula t = n/2
# So
# medium = [] # This will contain three median values
# m = [node_a, node_b, node_c]
# for i in range(0, len(m)):
# # Check for even and odd RSSI
# a = [i]
# if len(a) % 2 is 1: # If odd
# b = int((len(a) + 1)/2)
# medium.append(a[b])
# else: # Else even
# b = int(len(a)/2)
# medium.append(a[b])
# Check for the distance
# may be we should fix one rssi value vs distance and use it
# for correcting other rssi values, and not convolution
# let pick the rssi average value for one meter distance as our reference
# buth this will be correnting the
# if distance and not rssi in such:
#