Example #1
0
def plotSegments(jason, name="", labels=False):
    # read delimeters for each stop
    delims = readDelims()

    stopAdds = [getStopSet(jason["packets"], stop) for stop in delims]
    intersectBins = [set() for stop in delims]
    combobs = combinations(range(len(delims)), 2)
    for combob in combobs:
        curSect = stopAdds[combob[0]].intersection(stopAdds[combob[1]])
        for i in range(combob[0], combob[1]):
            intersectBins[i+1].update(curSect)
    probably_junk = stopAdds[0].intersection(stopAdds[-1])

    y = [len(bin - probably_junk) + 2 for bin in intersectBins]
    y[0] = y[1]  # For labelling purposes

    x = [stop['start'] for stop in delims]
    realy = [stop['actual'] for stop in delims]
    plot.xlabel('Seconds since '+jason["initial_time"])
    plot.ylabel('Number of bus occupants (predicted)')
    plot.xlim(0, delims[-1]['end'])
    plot.title(name)
    plot.step(x, y)
    plot.step(x, realy, color="purple", where="post")

    if(labels):
        for stop in delims:
            annotate(stop["code"], stop["start"], stop["actual"], 10, 10)

    makeWidePlot("bus", "segments")

    plot.show()
Example #2
0
def plotVectors(json, coincidence=0, name="", minTime=30, maxTime=1700,
                labels=False):
    delims = readDelims()

    macAddresses = {}
    json["packets"].apply(lambda row: addPacket(row, macAddresses), axis=1)

    sum = np.zeros(json["last"], dtype=np.int)
    for val in macAddresses.values():
        diff = val[1] - val[0]
        if ((diff > minTime) and (diff < maxTime) and (val[2] >= coincidence)):
            sum[val[0]: val[1]] += 1

    plot.xlabel('Seconds since start')
    plot.ylabel('Devices', color='b')
    plot.step(range(int(json["last"])), sum.tolist())

    actual = [stop['actual'] for stop in delims]
    stopx = [stop['start'] for stop in delims]
    ax2 = plot.twinx()
    ax2.step(stopx, actual, 'r', where="post")
    (t1.set_color for t1 in ax2.get_yticklabels())
    ax2.set_ylabel('Riders', color='r')
    plot.ylim(0, 30)
    plot.xlim(0, json["last"])

    if(labels):
        for stop in delims:
            annotate(stop["code"], stop["start"], stop["actual"], 10, 10)

    makeWidePlot("bus", "vectors")

    plot.show()
Example #3
0
def plotStrengthHistogram(jason, cutoff=120):
    macAddresses = {}
    jason["packets"].apply(lambda row: addPacket(row, macAddresses), axis=1)

    packetAxis = [val[3]/val[2] for val in macAddresses.values()
                  if (val[0]+jason["last"]-val[1]) < cutoff]

    xmax = len(packetAxis)
    plot.xlim(0, xmax)
    plot.bar(range(xmax), sorted(packetAxis), color="black")
    plot.xlabel("Unique MAC addresses present for the entire class period")
    plot.ylabel('Average Signal Strength for each MAC address')
    plot.title('April 7th, Classroom Signal Strength Distribution')

    graphlib.makeWidePlot("class", "strhist")
    plot.show()
Example #4
0
def plotUnique(jason, binsize=1, name="", labels=False):
    b = Binner(binsize, jason["last"])
    jason["packets"].apply(b.addPacket, axis=1)

    xaxis = [j*binsize for j in range(len(b.bins))]
    plot.bar(xaxis, b.bins, width=1, edgecolor='#000033')
    plot.xlim(0, jason["last"])
    plot.xlabel('Seconds since '+jason["initial_time"])
    plot.ylabel('Unique MACs in '+str(binsize)+' second interval')
    plot.title(name)

    if(labels):
        graphlib.wideAnnotate(plot, b.bins, binsize, ymax=max(b.bins))

    graphlib.makeWidePlot("bus", "unique")

    plot.show()
Example #5
0
def plotPacketHistogram(jason, cutoff=120):
    macAddresses = {}
    jason["packets"].apply(lambda row: addPacket(row, macAddresses), axis=1)

    packetAxis = [val[2] for val in macAddresses.values()
                  if (val[0]+jason["last"]-val[1]) < cutoff]

    xmax = len(packetAxis)
    plot.xlim(0, xmax)
    plot.yscale('log')
    plot.bar(range(xmax), sorted(packetAxis), color="black", log=True)
    plot.xlabel("Unique MAC addresses present for the entire class period")
    plot.ylabel('Number of Packets seen for each MAC address')
    plot.title('April 7th, Classroom Packet Distribution')

    graphlib.makeWidePlot("class","packethist")
    plot.show()
Example #6
0
def plotPackets(jason, binsize=1, labels=None):
    bins = np.zeros(int(jason["last"]/binsize)+1, np.int)
    jason["packets"]["time"].apply(lambda t: addToBin(t, bins, binsize))

    xaxis = [j*binsize for j in range(len(bins))]
    plot.bar(xaxis, bins, width=1, edgecolor='#000033')
    plot.xlim(0, jason["last"])
    plot.xlabel('Seconds since '+jason["initial_time"])
    plot.ylabel('Number of Packets in '+str(binsize)+' second interval')
    plot.title('April 7th, A Route')

    if(labels):
        graphlib.wideAnnotate(plot, bins, binsize, ymax=max(bins))

    graphlib.makeWidePlot("bus", "packets")

    plot.show()