コード例 #1
0
def top_loc_grid_freq(data, mac, size):
    results = []
    drone_data = read_drone_data()
    time_grouped = group_data(data, 0)

    for time_group in time_grouped:
        index_count = {}

        for row in time_group[1]:
            loc = find_location(row[1], drone_data)
            loc_tup = (loc['x_m'], loc['y_m'])

            index = grid_index(loc_tup, (X_OFFSET, Y_OFFSET), size)
            index_tup = (index[0], index[1])

            try:
                index_count[index_tup][0] += 1
                index_count[index_tup][1] += 100 + int(row[2])
            except KeyError:
                index_count[index_tup] = [1, 100 + int(row[2])]

        top_loc = max(index_count,
                      key=lambda x: (index_count[x][0], index_count[x][1]))

        res = get_xyz(top_loc, (X_OFFSET, Y_OFFSET), size)
        results.append([mac, time_group[0], res[0], res[1]])

    return results
コード例 #2
0
ファイル: top_loc.py プロジェクト: Nickyz94/Thesis
def top_loc_signal(data, mac):
    locs = []
    drone_data = read_drone_data()
    time_grouped = group_data(data, 0)

    for time_group in time_grouped:
        max_score = max(time_group[1], key=lambda x: x[2])
        loc = find_location(max_score[1], drone_data)

        locs.append([mac, time_group[0], loc["x_m"], loc["y_m"], loc["z_m"]])

    return locs
コード例 #3
0
def normal_grid_method(data, mac, size, std, method, alpha=0.5):
    results = []
    drone_data = read_drone_data()
    prev_pos = None
    prev_time = None
    dimensions = get_dimensions(size)
    std_matrix = create_std_matrix(std)

    time_grouped = group_data(data, 0)
    for time_group in time_grouped:
        values = list(time_group[1])
        g_data = [(item[0], item[1], item[2]) for item in values]

        index_count = np.zeros(dimensions)

        for row in g_data:
            loc = find_location(row[1], drone_data)

            if loc is None:
                continue

            loc_tup = (loc['x_m'], loc['y_m'])

            index = grid_index(loc_tup, (X_OFFSET, Y_OFFSET), size)
            index_tup = (index[0], index[1])

            if method == 'signal_sum':
                index_count[index_tup] += 100 + int(row[2])
            elif method == 'freq':
                index_count[index_tup] += 1
            else:
                index_count[index_tup] = max(100 + int(row[2]),
                                             index_count[index_tup])

        # make the matrix sum up to 1
        index_count = index_count / np.sum(index_count)

        if prev_pos is None or (time_group[0] - prev_time) > MAX_SECONDS_DIFF:
            prev_pos = get_max_matrix_value(index_count)
        else:
            norm_matrix = create_norm_matrix((prev_pos[1], prev_pos[0]),
                                             std_matrix, dimensions)
            prev_pos = get_max_matrix_value(alpha * index_count +
                                            (1 - alpha) * norm_matrix)

        res = get_xyz(prev_pos, (X_OFFSET, Y_OFFSET), size)
        prev_time = time_group[0]
        results.append([mac, time_group[0], res[0], res[1]])

    return results
コード例 #4
0
def top_loc_grid_signal(data, mac, size):
    results = []
    drone_data = read_drone_data()
    time_grouped = group_data(data, 0)

    for time_group in time_grouped:
        max_score = max(time_group[1], key=lambda x: x[2])

        loc = find_location(max_score[1], drone_data)
        loc_tup = (loc['x_m'], loc['y_m'])

        index = grid_index(loc_tup, (X_OFFSET, Y_OFFSET), size)
        index_tup = (index[0], index[1])

        res = get_xyz(index_tup, (X_OFFSET, Y_OFFSET), size)
        results.append([mac, time_group[0], res[0], res[1]])

    return results
コード例 #5
0
ファイル: top_loc.py プロジェクト: Nickyz94/Thesis
def top_loc_signal_sum(data, mac):
    locs = []
    drone_data = read_drone_data()
    time_grouped = group_data(data, 0)

    for time_group in time_grouped:
        sums = {}

        for row in time_group[1]:
            try:
                sums[row[1]] += 100 + int(row[2])
            except KeyError:
                sums[row[1]] = 100 + int(row[2])

        max_score = max(sums, key=lambda x: sums[x])

        loc = find_location(max_score, drone_data)

        locs.append([mac, time_group[0], loc["x_m"], loc["y_m"], loc["z_m"]])

    return locs
コード例 #6
0
ファイル: top_loc.py プロジェクト: Nickyz94/Thesis
def top_loc_frequency(data, mac):
    locs = []
    drone_data = read_drone_data()
    time_grouped = group_data(data, 0)

    for time_group in time_grouped:
        frequencies = {}

        for row in time_group[1]:
            try:
                frequencies[row[1]][0] += 1
                frequencies[row[1]][1] += 100 + int(row[2])
            except KeyError:
                frequencies[row[1]] = [1, 100 + int(row[2])]

        max_score = max(frequencies,
                        key=lambda x: (frequencies[x][0], frequencies[x][1]))
        loc = find_location(max_score, drone_data)

        locs.append([mac, time_group[0], loc["x_m"], loc["y_m"], loc["z_m"]])

    return locs