Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
beaugunderson committed Jun 4, 2011
0 parents commit 5a8c211
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 0 deletions.
Binary file added input/Layout.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions input/mapping.csv
@@ -0,0 +1,51 @@
Grid Point,Drawing X,Drawing Y,2e:20,14:a1,f6:70,f6:71,5b:30,5b:31,74:c0,74:c1,f5:90,f5:91,16:a0,16:a1
1,24,49,-83,-84,-71,-72,-60,-60,-76,-73,-81,-83,-71,-73
2,77,49,-83,-83,-62,-60,-60,-62,-70,-74,-79,-81,-66,-66
3,155,49,-82,-82,-63,-58,-61,-59,-69,-72,-77,-77,-56,-59
4,237,49,-82,-84,-57,-71,-58,-55,-73,-74,-76,-77,-55,-53
5,300,49,-82,-82,-72,-66,-62,-67,-73,-72,-84,-83,-57,-66
6,470,44,-67,-69,-69,-72,-76,-75,-53,-51,-81,-81,-78,-82
7,538,49,-59,-60,-57,-58,-67,-66,-48,-51,-70,-72,-81,-84
8,633,49,-53,-49,-55,-49,-54,-60,-45,-40,-74,-67,-78,-81
9,714,49,-52,-53,-53,-58,-60,-63,-50,-46,-79,-75,-80,-81
10,762,49,-62,-62,-60,-63,-63,-67,-58,-55,-75,-75,-83,-84
11,52,142,-81,-80,-63,-60,-58,-56,-66,-69,-80,-81,-65,-62
12,155,142,-78,-80,-63,-65,-55,-56,-73,-67,-75,-75,-61,-60
13,252,142,-77,-77,-51,-62,-56,-47,-62,-61,-70,-72,-46,-50
14,349,130,-74,-73,-61,-66,-58,-59,-62,-62,-73,-78,-59,-62
15,440,130,-69,-69,-58,-58,-66,-67,-58,-57,-73,-78,-64,-62
16,547,142,-48,-48,-56,-51,-62,-61,-33,-33,-66,-67,-74,-78
17,633,142,-48,-45,-51,-60,-62,-61,-40,-37,-70,-71,-81,-80
21,728,152,-51,-57,-58,-59,-59,-57,-39,-36,-76,-74,-78,-78
22,52,225,-82,-83,-57,-60,-49,-50,-60,-63,-76,-82,-67,-71
23,155,225,-80,-78,-58,-56,-50,-51,-60,-55,-75,-89,-53,-60
24,252,225,-75,-76,-60,-53,-51,-50,-56,-54,-69,-68,-38,-38
25,349,225,-63,-63,-54,-46,-47,-49,-55,-58,-66,-73,-50,-45
26,440,225,-65,-60,-40,-46,-54,-54,-44,-44,-59,-56,-67,-67
27,534,225,-52,-56,-49,-46,-54,-46,-44,-41,-60,-61,-73,-72
28,633,225,-39,-39,-51,-58,-49,-59,-27,-27,-62,-61,-79,-77
29,736,225,-53,-60,-66,-54,-60,-60,-52,-38,-70,-66,-78,-77
30,52,314,-81,-82,-59,-62,-50,-57,-64,-63,-76,-75,-67,-65
31,155,314,-73,-73,-56,-58,-51,-52,-58,-58,-78,-79,-57,-54
32,252,314,-75,-74,-52,-55,-40,-43,-58,-59,-76,-74,-51,-52
33,349,314,-69,-70,-55,-54,-42,-49,-52,-51,-68,-70,-48,-51
34,440,314,-59,-59,-39,-49,-50,-50,-51,-45,-56,-59,-65,-64
35,534,314,-56,-62,-44,-45,-49,-53,-51,-44,-54,-59,-61,-67
36,633,314,-55,-59,-59,-50,-54,-50,-38,-38,-58,-60,-68,-69
37,736,314,-47,-47,-45,-43,-58,-59,-38,-35,-67,-72,-80,-75
38,52,395,-75,-76,-54,-56,-49,-45,-62,-62,-70,-74,-61,-59
39,155,400,-75,-72,-53,-46,-47,-47,-48,-51,-69,-70,-72,-66
40,251,400,-67,-67,-46,-49,-38,-34,-56,-56,-69,-70,-56,-59
41,349,400,-69,-71,-56,-51,-31,-37,-53,-55,-67,-69,-68,-65
42,440,400,-71,-72,-39,-40,-47,-47,-48,-50,-59,-65,-69,-59
43,534,400,-65,-65,-32,-33,-47,-47,-48,-48,-43,-43,-62,-66
44,633,400,-61,-58,-39,-35,-55,-56,-43,-46,-48,-44,-67,-69
45,697,400,-67,-66,-47,-51,-53,-58,-44,-48,-56,-61,-74,-72
46,39,460,-84,-85,-67,-71,-67,-68,-66,-71,-83,-82,-74,-74
47,155,486,-75,-75,-62,-63,-49,-47,-54,-53,-77,-78,-62,-62
48,252,486,-74,-72,-58,-55,-37,-43,-53,-51,-76,-70,-61,-61
49,349,486,-66,-66,-44,-56,-44,-45,-54,-52,-62,-59,-70,-62
50,440,486,-69,-73,-44,-44,-43,-48,-46,-58,-62,-68,-57,-62
51,534,486,-66,-62,-35,-41,-55,-51,-42,-37,-49,-48,-64,-62
52,633,486,-62,-62,-38,-40,-57,-57,-46,-47,-56,-53,-75,-77
53,736,486,-71,-69,-53,-56,-63,-68,-55,-58,-60,-65,-80,-78
Binary file added output/Results - 1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added output/Results - 2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
143 changes: 143 additions & 0 deletions wifi-heatmap.py
@@ -0,0 +1,143 @@
from __future__ import division

import tabular as tb
import numpy as np
import matplotlib.mlab as ml
import matplotlib.pyplot as pp

from mpl_toolkits.axes_grid1 import AxesGrid
from scipy.interpolate import Rbf
from pylab import imread, imshow

layout = imread('input/Layout.png')

a = tb.tabarray(SVfile='input/mapping.csv')

s_beacons = ['2e:20', 'f6:70', '5b:30', '74:c0', 'f5:90', '16:a0']
g_beacons = ['14:a1', 'f6:71', '5b:31', '74:c1', 'f5:91', '16:a1']

grid_width = 797
grid_height = 530

image_width = 2544
image_height = 1691

num_x = image_width / 4
num_y = num_x / (image_width / image_height)

print "Resolution: %0.2f x %0.2f" % (num_x, num_y)

x = np.linspace(0, grid_width, num_x)
y = np.linspace(0, grid_height, num_y)

gx, gy = np.meshgrid(x, y)
gx, gy = gx.flatten(), gy.flatten()

levels = [-85, -80, -75, -70, -65, -60, -55, -50, -45, -40, -35, -30, -25]

interpolate = True

def add_inner_title(ax, title, loc, size=None, **kwargs):
from matplotlib.offsetbox import AnchoredText
from matplotlib.patheffects import withStroke

if size is None:
size = dict(size=pp.rcParams['legend.fontsize'])

at = AnchoredText(title, loc=loc, prop=size,
pad=0., borderpad=0.5,
frameon=False, **kwargs)

at.set_zorder(200)

ax.add_artist(at)

at.txt._text.set_path_effects([withStroke(foreground="w", linewidth=3)])

return at

def grid_plots():
f = pp.figure()

f.suptitle("Individual AP RSSI")

# Adjust the margins and padding
f.subplots_adjust(hspace=0.1, wspace=0.1, left=0.05, right=0.95, top=0.85,
bottom=0.15)

# Create a grid of subplots using the AxesGrid helper
image_grid = AxesGrid(f, 111, nrows_ncols=(2, 3), axes_pad=0.1,
label_mode="1", share_all=True, cbar_location="right",
cbar_mode="single", cbar_size="3%")

for beacon, i in zip(s_beacons, xrange(len(s_beacons))):
# Hide the axis labels
image_grid[i].xaxis.set_visible(False)
image_grid[i].yaxis.set_visible(False)

if interpolate:
# Interpolate the data
rbf = Rbf(a['Drawing X'], a['Drawing Y'], a[beacon],
function='linear')

z = rbf(gx, gy)
z = z.reshape((num_y, num_x))

# Render the interpolated data to the plot
image = image_grid[i].imshow(z, vmin=-85, vmax=-25, extent=(0,
image_width, image_height, 0), cmap='RdYlBu_r', alpha=1)

#c = image_grid[i].contourf(z, levels, alpha=0.5)
#c = image_grid[i].contour(z, levels, linewidths=5, alpha=0.5)
else:
z = ml.griddata(a['Drawing X'], a['Drawing Y'], a[beacon], x, y)

c = image_grid[i].contourf(x, y, z, levels, alpha=0.5)

image_grid[i].imshow(layout, interpolation='bicubic', zorder=100)

# Setup the data for the colorbar and its ticks
image_grid.cbar_axes[0].colorbar(image)
image_grid.cbar_axes[0].set_yticks(levels)

# Add inset titles to each subplot
for ax, im_title in zip(image_grid, s_beacons):
t = add_inner_title(ax, "Beacon %s" % im_title, loc=3)

t.patch.set_alpha(0.5)

pp.show()

def max_plot():
# Get the maximum RSSI seen for each beacon
max_rssi = [max(i) for i in a[s_beacons]]

pp.title("Maximum RSSI seen for each beacon")

if interpolate:
# Interpolate the data
rbf = Rbf(a['Drawing X'], a['Drawing Y'], max_rssi, function='linear')

z = rbf(gx, gy)
z = z.reshape((num_y, num_x))

# Render the interpolated data to the plot
image = pp.imshow(z, vmin=-85, vmax=-25, extent=(0,
image_width, image_height, 0), cmap='RdYlBu_r', alpha=1)

#pp.contourf(z, levels, alpha=0.5)
#pp.contour(z, levels, linewidths=5, alpha=0.5)
else:
z = ml.griddata(a['Drawing X'], a['Drawing Y'], max_rssi, x, y)

pp.contourf(x, y, z, levels, alpha=0.5)

pp.colorbar(image)

pp.imshow(layout, interpolation='bicubic', zorder=100)

pp.show()

if __name__ == "__main__":
grid_plots()
max_plot()

1 comment on commit 5a8c211

@AishaMou
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi i was testing the script but it sais that there is error in line 28 .Any help ?
thanks

Please sign in to comment.