In [1]:
from pyrobot.brain.ravq import *
#from scipy import *
#from numpy import *
#from matplotlib import 

def readin(files):
    openFiles = []
    data = []
    sensorStreams = []
    lineLen = 0
    for i in range(len(files)):
        openFiles.append(open(files[i], "r"))
        for l in openFiles[i]:
            for j in range(len(l.split(","))):
                if i == 0:
                    lineLen = len(l.split(","))
                sensorStreams.append([])
            break
        for line in openFiles[i]:
            line = line.split(",")
            for j in range(len(line)):
                try:
                    sensorStreams[i*lineLen+j].append(float(line[j].strip(",.\n\r ")))
                except:
                    if j == 0 and i == 0:
                        sensorStreams[i*lineLen+j].append(line[j].strip(",.\n\r "))
                    else:
                        sensorStreams[i*lineLen+j].append(-1)
    #print sensorStreams[5]
    return sensorStreams

def getVec(sensorStreams, maxes, t):
    vec = []
    for i in range(2, len(sensorStreams)):
        try:
            if maxes[i] == 0 or maxes[i] == -1:
                vec.append(0)
            else:
                vec.append(float(sensorStreams[i][t])/maxes[i])
        except:
            continue
    #print vec
    return vec

In [2]:
data = readin(["wxsta1_Table1.dat"])

In [70]:
r = ARAVQ(100, 1, .9, 2, .2)

#print data
states = []
maxes = []
stdDevs = []
for i in range(len(data)):
    m = max([data[i][j] for j in range(500)])
    maxes.append(m)

for i in range(len(getVec(data, maxes, 0))):
    stdDevs.append(0)
    
for i in range(len(data[0])):
    v=(getVec(data, maxes, i))
    r.input(v)
    for j in range(len(v)):
        stdDevs[j] = (stdDevs[j] + v[j])/2
        if abs(r.models[r.newWinnerIndex].vector[j] - v[j]) > 2*stdDevs[j]:
            print "potential error:", vec
    #print getVec(data, maxes, i)
    states.append(r.newWinnerIndex)
    #if len(states) > 10000:
        #break
print states


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/emily/Code/cs97Project/<ipython-input-70-faba8a41753e> in <module>()
     17     for j in range(len(v)):
     18         stdDevs[j] = (stdDevs[j] + v[j])/2
---> 19         if abs(r.models[r.winner].vector[j] - v[j]) > 2*stdDevs[j]:
     20             print "potential error:", vec
     21     #print getVec(data, maxes, i)


/home/emily/Code/cs97Project/pyrobot/tools/circularlist.pyc in __getitem__(self, index)
     35         if index >= 0 and index < len(self.contents):
     36             return self.contents[index]
---> 37         raise StopIteration, "no item at index %d in CircularList" % index
     38 
     39     def __iter__(self):

TypeError: %d format: a number is required, not str

In [4]:
def plot_stream(stream, data, r):
    """
    Plots the values of a specific stream over time.
    Inputs: stream - an int indicating the index of the desired stream
    data - An array of all sensor data
    r = a RAVQ object
    Returns: The number of -1s (indicating invalid data) in this stream
    """
    values = []
    negs = 0
    for i in range(len(states)):
        if states[i]  == -1:
            negs += 1
        else:
            values.append(r.models[states[i]].vector[stream])
    plot(data[1][negs:len(states)], values, 'r-')
    return negs

In [5]:
#print r.distanceMapAsString()
#print r
#print r.models[0].vector[1]
negs = plot_stream(2, data, r)



In [6]:
plot(data[1][negs:len(states)], data[2][negs:len(states)], 'b-')


Out[6]:
[<matplotlib.lines.Line2D at 0xaaa646c>]

In [7]:
fig = figure(figsize=(15.0,10))
#fig.add_subplot(111)
#subplot(111)
#subplot(111)
plot(data[1][:len(states)], states, '*')
#plot(


Out[7]:
[<matplotlib.lines.Line2D at 0xab6bc0c>]

In [8]:
time = 0
times = []
for i in range(1, len(states)):
    if states[i] == states[i-1]:
        time += 1
    else:
        times.append(time)
        time = 0
print times
print len(times)
print float(len(times))/len(states)


[99, 356, 1192, 341, 246, 167, 504, 151, 419, 268, 93, 654, 247, 117, 17, 6, 37, 85, 105, 399, 1149, 437, 69, 272, 15, 156, 62, 32, 159, 109, 77, 95, 889, 221, 194, 87, 90, 195, 493, 219, 55, 75, 236, 40, 116, 105, 204, 63, 312, 184, 1145, 49, 126, 21, 78, 577, 75, 126, 146, 247, 271, 239, 368, 54, 32, 320, 85, 116, 522, 37, 142, 137, 362, 578, 187, 77, 67, 45, 159, 71, 68, 259, 17, 219, 280, 96, 802, 79, 163, 533, 25, 1146, 229, 34, 5, 20, 3, 85, 696, 309, 63, 57, 42, 16, 62, 39, 310, 57, 507, 64, 181, 3791, 122, 177, 101, 219, 36, 27, 479, 144, 1, 30, 103, 111, 584, 153, 271, 60, 108, 72, 358, 62, 351, 220, 340, 14, 10, 40, 313, 56, 838, 437, 525, 175, 94, 3, 50, 32, 465]
149
0.00411943599668

In [9]:
diffs = []
n = 0
av_diffs = [0 for i in range(len(r.models[0].vector))]
for model1 in r.models:
    for model2 in r.models:
        for i in range(len(model1.vector)):
            diffs.append(model1.vector[i] - model2.vector[i])
            av_diffs[i] += model1.vector[i] - model2.vector[i]
        n+=1
        print diffs
        diffs = []
    print
for i in range(len(av_diffs)):
    av_diffs[i] = av_diffs[i]/n
print av_diffs


[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[-0.0074874371859295907, 0.1356320927394753, -0.67063458762198336, 0.013749999999999998, 0.0, 0.0, 0.0, -0.6711357123146513, 0.088382504235198445, 0.13402474430180178, 0.11408287229690139, 0.12516409681181739]
[-0.013316582914572828, 0.69458023184868822, -0.91249077657327227, 0.019999999999999997, 0.0, 0.0, 0.0, -0.91313908077367256, 0.13625129058521701, 0.69997778246428533, 0.68289842877186779, 0.69199596685634424]
[0.00042354630294327844, 0.15531482611348391, -1.6497979342582627, -0.044999999375000009, 0.0, 0.0, 0.0, -1.649194045669387, 0.076526074280026335, 0.17604868838521431, 0.16404712646220121, 0.1707062075217472]
[0.0074515434314429418, 0.79925381330079315, -2.0780314260705031, 0.0024999999999999988, 0.0, 0.0, 0.0, -2.0785422185999778, 0.039485641089766932, 0.82592083048925768, 0.80272053476908867, 0.81580118337955909]
[0.015082555635319461, 1.4316754118364856, -0.99619689767839426, 0.019999999999999997, 0.0, 0.0, 0.0, -0.99679902108083485, 0.08883885190680485, 1.4395509706630318, 1.4057917325509537, 1.4240575840946168]
[-0.020954773869346743, 1.620018303843807, -1.6728718563373115, 0.021874999999999999, 0.0, 0.0, 0.0, -1.673708305831195, 0.21618443544291721, 1.66818114170737, 1.6271356147418627, 1.6495648292313008]
[0.017085427135678399, 0.65741183648566204, -2.912842001741518, -0.020000000000000004, 0.0, -0.00011111111111095084, -0.00011111111111095084, -2.9130718970810778, -0.00892395639032173, 0.65928056612358854, 0.64726004504703749, 0.65407996382547184]
[-0.0074874371859295907, -0.44062843197071377, -2.0028013824869011, 0.021874999999999999, 0.0, 0.0, 0.0, -2.0038431098262035, 0.28635060462726314, -0.4146558479972362, -0.44331906301179347, -0.4262522128530567]
[-0.020890165111270509, 0.85751128737034776, -0.30023444930481924, 0.021874999999999999, 0.0, 0.0, 0.0, -0.30084508141917027, 0.52348453371643999, 0.91981769332208074, 0.87519239247192937, 0.90037675635891035]
[-0.0066259870782483521, -0.70111043319096999, -0.3271789267181513, 0.021874999999999999, 0.0, 0.0, 0.0, -0.3278909907989474, 0.41485681752564529, -0.68555229873820345, -0.72069485346966011, -0.70022689688399298]
[-0.0041062455132806486, -0.23762660158633309, -2.9882773812635022, -0.10062499999999999, 0.0, 0.0, 0.0, -2.9866433910828296, -0.09195238396605776, -0.24579029030873678, -0.24443038503453007, -0.24528969385584876]
[-0.010567121320890216, -0.7622147651006711, -0.97648089865072285, 0.021874999999999999, 0.0, 0.0, 0.0, -0.9773414759637733, 0.10412214778246609, -0.75317433828935676, -0.78458499963755945, -0.76306971626495834]

[0.0074874371859295907, -0.1356320927394753, 0.67063458762198336, -0.013749999999999998, 0.0, 0.0, 0.0, 0.6711357123146513, -0.088382504235198445, -0.13402474430180178, -0.11408287229690139, -0.12516409681181739]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[-0.0058291457286432369, 0.55894813910921293, -0.24185618895128891, 0.0062500000000000003, 0.0, 0.0, 0.0, -0.24200336845902126, 0.047868786350018566, 0.56595303816248355, 0.5688155564749664, 0.56683187004452684]
[0.0079109834888728692, 0.01968273337400861, -0.97916334663627946, -0.058749999375000007, 0.0, 0.0, 0.0, -0.97805833335473569, -0.01185642995517211, 0.042023944083412534, 0.049964254165299815, 0.045542110709929806]
[0.014938980617372533, 0.66362172056131785, -1.4073968384485198, -0.01125, 0.0, 0.0, 0.0, -1.4074065062853265, -0.048896863145431513, 0.69189608618745591, 0.68863766247218727, 0.6906370865677417]
[0.022569992821249052, 1.2960433190970104, -0.3255623100564109, 0.0062500000000000003, 0.0, 0.0, 0.0, -0.32566330876618355, 0.00045634767160640521, 1.3055262263612302, 1.2917088602540523, 1.2988934872827995]
[-0.013467336683417153, 1.4843862111043318, -1.002237268715328, 0.0081250000000000003, 0.0, 0.0, 0.0, -1.0025725935165437, 0.12780193120771877, 1.5341563974055683, 1.5130527424449611, 1.5244007324194833]
[0.02457286432160799, 0.52177974374618674, -2.2422074141195347, -0.033750000000000002, 0.0, -0.00011111111111095084, -0.00011111111111095084, -2.2419361847664265, -0.097306460625520175, 0.52525582182178676, 0.5331771727501361, 0.52891586701365445]
[0.0, -0.57626052471018907, -1.3321667948649178, 0.0081250000000000003, 0.0, 0.0, 0.0, -1.3327073975115522, 0.19796810039206469, -0.54868059229903798, -0.55740193530869486, -0.55141630966487409]
[-0.013402727925340918, 0.72187919463087247, 0.37040013831716412, 0.0081250000000000003, 0.0, 0.0, 0.0, 0.37029063089548109, 0.4351020294812416, 0.78579294902027896, 0.76110952017502798, 0.77521265954709295]
[0.00086145010768123864, -0.83674252593044529, 0.34345566090383206, 0.0081250000000000003, 0.0, 0.0, 0.0, 0.34324472151570395, 0.32647431329044685, -0.81957704304000523, -0.83477772576656151, -0.82539099369581037]
[0.0033811916726489422, -0.37325869432580838, -2.3176427936415189, -0.114375, 0.0, 0.0, 0.0, -2.3155076787681783, -0.1803348882012562, -0.37981503461053856, -0.35851325733143147, -0.37045379066766615]
[-0.0030796841349606252, -0.8978468578401464, -0.30584631102873949, 0.0081250000000000003, 0.0, 0.0, 0.0, -0.306205763649122, 0.015739643547267645, -0.88719908259115854, -0.89866787193446085, -0.88823381307677574]

[0.013316582914572828, -0.69458023184868822, 0.91249077657327227, -0.019999999999999997, 0.0, 0.0, 0.0, 0.91313908077367256, -0.13625129058521701, -0.69997778246428533, -0.68289842877186779, -0.69199596685634424]
[0.0058291457286432369, -0.55894813910921293, 0.24185618895128891, -0.0062500000000000003, 0.0, 0.0, 0.0, 0.24200336845902126, -0.047868786350018566, -0.56595303816248355, -0.5688155564749664, -0.56683187004452684]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.013740129217516106, -0.53926540573520432, -0.73730715768499056, -0.064999999375000006, 0.0, 0.0, 0.0, -0.73605496489571443, -0.059725216305190676, -0.52392909407907107, -0.51885130230966658, -0.52128975933459698]
[0.020768126346015769, 0.10467358145210495, -1.1655406494972309, -0.017500000000000002, 0.0, 0.0, 0.0, -1.1654031378263052, -0.096765649495450079, 0.1259430480249723, 0.11982210599722087, 0.1238052165232149]
[0.028399138549892289, 0.7370951799877975, -0.083706121105121989, 0.0, 0.0, 0.0, 0.0, -0.083659940307162284, -0.047412438678412161, 0.73957318819874651, 0.72289330377908589, 0.73206161723827257]
[-0.0076381909547739157, 0.92543807199511885, -0.76038107976403913, 0.0018749999999999999, 0.0, 0.0, 0.0, -0.76056922505752245, 0.0799331448577002, 0.96820335924308465, 0.94423718596999484, 0.95756886237495642]
[0.030402010050251227, -0.037168395363026234, -2.000351225168246, -0.040000000000000001, 0.0, -0.00011111111111095084, -0.00011111111111095084, -1.9999328163074053, -0.14517524697553874, -0.040697216340696882, -0.035638383724830365, -0.037916003030872364]
[0.0058291457286432369, -1.1352086638194021, -1.0903106059136289, 0.0018749999999999999, 0.0, 0.0, 0.0, -1.0907040290525309, 0.15009931404204613, -1.1146336304615216, -1.1262174917836614, -1.1182481797094008]
[-0.0075735821966976813, 0.16293105552165954, 0.61225632726845303, 0.0018749999999999999, 0.0, 0.0, 0.0, 0.61229399935450235, 0.38723324313122304, 0.21983991085779536, 0.19229396370006158, 0.20838078950256614]
[0.0066905958363244755, -1.3956906650396583, 0.58531184985512097, 0.0018749999999999999, 0.0, 0.0, 0.0, 0.58524808997472522, 0.27860552694042828, -1.3855300812024889, -1.403593282241528, -1.3922228637403371]
[0.009210337401292179, -0.93220683343502131, -2.0757866046902302, -0.120625, 0.0, 0.0, 0.0, -2.0735043103091568, -0.22820367455127477, -0.94576807277302211, -0.92732881380639787, -0.93728566071219299]
[0.0027494615936826117, -1.4567949969493594, -0.063990122077450584, 0.0018749999999999999, 0.0, 0.0, 0.0, -0.064202395190100736, -0.032129142802750921, -1.4531521207536422, -1.4674834284094274, -1.4550656831213025]

[-0.00042354630294327844, -0.15531482611348391, 1.6497979342582627, 0.044999999375000009, 0.0, 0.0, 0.0, 1.649194045669387, -0.076526074280026335, -0.17604868838521431, -0.16404712646220121, -0.1707062075217472]
[-0.0079109834888728692, -0.01968273337400861, 0.97916334663627946, 0.058749999375000007, 0.0, 0.0, 0.0, 0.97805833335473569, 0.01185642995517211, -0.042023944083412534, -0.049964254165299815, -0.045542110709929806]
[-0.013740129217516106, 0.53926540573520432, 0.73730715768499056, 0.064999999375000006, 0.0, 0.0, 0.0, 0.73605496489571443, 0.059725216305190676, 0.52392909407907107, 0.51885130230966658, 0.52128975933459698]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0070279971284996634, 0.64393898718730924, -0.42823349181224035, 0.047499999375000004, 0.0, 0.0, 0.0, -0.4293481729305908, -0.037040433190259403, 0.64987214210404343, 0.63867340830688746, 0.64509497585781195]
[0.014659009332376183, 1.2763605857230018, 0.65360103657986857, 0.064999999375000006, 0.0, 0.0, 0.0, 0.65239502458855214, 0.012312777626778515, 1.2635022822778175, 1.2417446060887525, 1.2533513765728697]
[-0.021378320172290022, 1.4647034777303232, -0.02307392207904857, 0.066874999375000008, 0.0, 0.0, 0.0, -0.024514260161808021, 0.13965836116289088, 1.4921324533221556, 1.4630884882796615, 1.4788586217095534]
[0.016661880832735121, 0.50209701037217813, -1.2630440674832553, 0.024999999375000005, 0.0, -0.00011111111111095084, -0.00011111111111095084, -1.2638778514116908, -0.085450030670348065, 0.48323187773837417, 0.48321291858483623, 0.48337375630372464]
[-0.0079109834888728692, -0.59594325808419768, -0.35300344822863838, 0.066874999375000008, 0.0, 0.0, 0.0, -0.35464906415681652, 0.2098245303472368, -0.59070453638245057, -0.60736618947399468, -0.59695842037480396]
[-0.021313711414213787, 0.70219646125686386, 1.3495634849534435, 0.066874999375000008, 0.0, 0.0, 0.0, 1.3483489642502167, 0.44695845943641371, 0.74376900493686637, 0.71114526600972816, 0.7296705488371632]
[-0.0070495333811916305, -0.8564252593044539, 1.3226190075401116, 0.066874999375000008, 0.0, 0.0, 0.0, 1.3213030548704396, 0.33833074324561896, -0.86160098712341782, -0.88474197993186132, -0.87093310440574023]
[-0.004529791816223927, -0.39294142769981699, -1.3384794470052395, -0.05562500062499999, 0.0, 0.0, 0.0, -1.3374493454134426, -0.1684784582460841, -0.42183897869395109, -0.40847751149673128, -0.41599590137759596]
[-0.010990667623833494, -0.917529591214155, 0.67331703560753997, 0.066874999375000008, 0.0, 0.0, 0.0, 0.67185256970561369, 0.027596073502439755, -0.92922302667457113, -0.94863212609976066, -0.9337759237867056]

[-0.0074515434314429418, -0.79925381330079315, 2.0780314260705031, -0.0024999999999999988, 0.0, 0.0, 0.0, 2.0785422185999778, -0.039485641089766932, -0.82592083048925768, -0.80272053476908867, -0.81580118337955909]
[-0.014938980617372533, -0.66362172056131785, 1.4073968384485198, 0.01125, 0.0, 0.0, 0.0, 1.4074065062853265, 0.048896863145431513, -0.69189608618745591, -0.68863766247218727, -0.6906370865677417]
[-0.020768126346015769, -0.10467358145210495, 1.1655406494972309, 0.017500000000000002, 0.0, 0.0, 0.0, 1.1654031378263052, 0.096765649495450079, -0.1259430480249723, -0.11982210599722087, -0.1238052165232149]
[-0.0070279971284996634, -0.64393898718730924, 0.42823349181224035, -0.047499999375000004, 0.0, 0.0, 0.0, 0.4293481729305908, 0.037040433190259403, -0.64987214210404343, -0.63867340830688746, -0.64509497585781195]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0076310122038765194, 0.63242159853569258, 1.0818345283921089, 0.017500000000000002, 0.0, 0.0, 0.0, 1.0817431975191429, 0.049353210817037918, 0.61363014017377415, 0.60307119778186502, 0.60825640071505771]
[-0.028406317300789685, 0.82076449054301392, 0.40515956973319178, 0.019375, 0.0, 0.0, 0.0, 0.40483391276878278, 0.17669879435315028, 0.84226031121811229, 0.82441507997277397, 0.83376364585174156]
[0.0096338837042354575, -0.14184197681513117, -0.83481057567101491, -0.022500000000000003, 0.0, -0.00011111111111095084, -0.00011111111111095084, -0.83452967848110005, -0.048409597480088662, -0.1666402643656692, -0.15546048972205123, -0.16172121955408725]
[-0.014938980617372533, -1.239882245271507, 0.075230043583601969, 0.019375, 0.0, 0.0, 0.0, 0.074699108773774281, 0.24686496353749621, -1.240576678486494, -1.2460395977808822, -1.2420533962326159]
[-0.028341708542713451, 0.058257474069554602, 1.7777969767656838, 0.019375, 0.0, 0.0, 0.0, 1.7776971371808075, 0.48399889262667312, 0.093896862832823058, 0.072471857702840703, 0.084575572979351255]
[-0.014077530509691294, -1.5003642464917633, 1.750852499352352, 0.019375, 0.0, 0.0, 0.0, 1.7506512278010304, 0.37537117643587836, -1.5114731292274612, -1.5234153882387489, -1.5160280802635522]
[-0.01155778894472359, -1.0368804148871262, -0.91024595519299911, -0.10312499999999999, 0.0, 0.0, 0.0, -0.90810117248285183, -0.13143802505582469, -1.0717111207979944, -1.0471509198036189, -1.061090877235408]
[-0.018018664752333158, -1.5614685784014644, 1.1015505274197803, 0.019375, 0.0, 0.0, 0.0, 1.1012007426362045, 0.064636506692699158, -1.5790951687786143, -1.5873055344066482, -1.5788708996445175]

[-0.015082555635319461, -1.4316754118364856, 0.99619689767839426, -0.019999999999999997, 0.0, 0.0, 0.0, 0.99679902108083485, -0.08883885190680485, -1.4395509706630318, -1.4057917325509537, -1.4240575840946168]
[-0.022569992821249052, -1.2960433190970104, 0.3255623100564109, -0.0062500000000000003, 0.0, 0.0, 0.0, 0.32566330876618355, -0.00045634767160640521, -1.3055262263612302, -1.2917088602540523, -1.2988934872827995]
[-0.028399138549892289, -0.7370951799877975, 0.083706121105121989, 0.0, 0.0, 0.0, 0.0, 0.083659940307162284, 0.047412438678412161, -0.73957318819874651, -0.72289330377908589, -0.73206161723827257]
[-0.014659009332376183, -1.2763605857230018, -0.65360103657986857, -0.064999999375000006, 0.0, 0.0, 0.0, -0.65239502458855214, -0.012312777626778515, -1.2635022822778175, -1.2417446060887525, -1.2533513765728697]
[-0.0076310122038765194, -0.63242159853569258, -1.0818345283921089, -0.017500000000000002, 0.0, 0.0, 0.0, -1.0817431975191429, -0.049353210817037918, -0.61363014017377415, -0.60307119778186502, -0.60825640071505771]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[-0.036037329504666205, 0.18834289200732135, -0.67667495865891714, 0.0018749999999999999, 0.0, 0.0, 0.0, -0.67690928475036016, 0.12734558353611236, 0.22863017104433814, 0.22134388219090895, 0.22550724513668385]
[0.0020028715003589381, -0.77426357535082369, -1.9166451040631238, -0.040000000000000001, 0.0, -0.00011111111111095084, -0.00011111111111095084, -1.916272876000243, -0.09776280829712658, -0.7802704045394433, -0.7585316875039162, -0.76997762026914496]
[-0.022569992821249052, -1.8723038438071995, -1.0066044848085069, 0.0018749999999999999, 0.0, 0.0, 0.0, -1.0070440887453687, 0.19751175272045829, -1.854206818660268, -1.8491107955627473, -1.8503097969476734]
[-0.03597272074658997, -0.57416412446613796, 0.69596244837357502, 0.0018749999999999999, 0.0, 0.0, 0.0, 0.69595393966166463, 0.4346456818096352, -0.51973327734095109, -0.53059934007902432, -0.52368082773570646]
[-0.021708542713567813, -2.1327858450274557, 0.66901797096024296, 0.0018749999999999999, 0.0, 0.0, 0.0, 0.6689080302818875, 0.32601796561884044, -2.1251032694012353, -2.1264865860206137, -2.1242844809786097]
[-0.01918880114860011, -1.6693020134228189, -1.992080483585108, -0.120625, 0.0, 0.0, 0.0, -1.9898443700019948, -0.18079123587286261, -1.6853412609717686, -1.6502221175854839, -1.6693472779504654]
[-0.025649676956209677, -2.193890176937157, 0.019715999027671405, 0.0018749999999999999, 0.0, 0.0, 0.0, 0.019457545117061548, 0.01528329587566124, -2.1927253089523884, -2.190376732188513, -2.1871273003595753]

[0.020954773869346743, -1.620018303843807, 1.6728718563373115, -0.021874999999999999, 0.0, 0.0, 0.0, 1.673708305831195, -0.21618443544291721, -1.66818114170737, -1.6271356147418627, -1.6495648292313008]
[0.013467336683417153, -1.4843862111043318, 1.002237268715328, -0.0081250000000000003, 0.0, 0.0, 0.0, 1.0025725935165437, -0.12780193120771877, -1.5341563974055683, -1.5130527424449611, -1.5244007324194833]
[0.0076381909547739157, -0.92543807199511885, 0.76038107976403913, -0.0018749999999999999, 0.0, 0.0, 0.0, 0.76056922505752245, -0.0799331448577002, -0.96820335924308465, -0.94423718596999484, -0.95756886237495642]
[0.021378320172290022, -1.4647034777303232, 0.02307392207904857, -0.066874999375000008, 0.0, 0.0, 0.0, 0.024514260161808021, -0.13965836116289088, -1.4921324533221556, -1.4630884882796615, -1.4788586217095534]
[0.028406317300789685, -0.82076449054301392, -0.40515956973319178, -0.019375, 0.0, 0.0, 0.0, -0.40483391276878278, -0.17669879435315028, -0.84226031121811229, -0.82441507997277397, -0.83376364585174156]
[0.036037329504666205, -0.18834289200732135, 0.67667495865891714, -0.0018749999999999999, 0.0, 0.0, 0.0, 0.67690928475036016, -0.12734558353611236, -0.22863017104433814, -0.22134388219090895, -0.22550724513668385]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.038040201005025143, -0.96260646735814503, -1.2399701454042067, -0.041875000000000002, 0.0, -0.00011111111111095084, -0.00011111111111095084, -1.2393635912498828, -0.22510839183323894, -1.0089005755837814, -0.97987556969482514, -0.99548486540582881]
[0.013467336683417153, -2.0606467358145206, -0.32992952614958981, 0.0, 0.0, 0.0, 0.0, -0.3301348039950085, 0.070166169184345928, -2.0828369897046062, -2.0704546777536561, -2.0758170420843571]
[6.4608758076234452e-05, -0.76250701647345931, 1.3726374070324923, 0.0, 0.0, 0.0, 0.0, 1.3728632244120247, 0.30730009827352284, -0.74836344838528923, -0.75194322226993326, -0.74918807287239031]
[0.014328786791098391, -2.3211287370347771, 1.34569292961916, 0.0, 0.0, 0.0, 0.0, 1.3458173150322477, 0.19867238208272808, -2.3537334404455734, -2.347830468211523, -2.3497917261152939]
[0.016848528356066095, -1.8576449054301403, -1.3154055249261909, -0.1225, 0.0, 0.0, 0.0, -1.3129350852516346, -0.30813681940897497, -1.9139714320161068, -1.8715659997763927, -1.8948545230871494]
[0.010387652548456527, -2.3822330689444779, 0.69639095768658854, 0.0, 0.0, 0.0, 0.0, 0.69636682986742171, -0.11206228766045112, -2.421355479996727, -2.4117206143794219, -2.412634545496259]

[-0.017085427135678399, -0.65741183648566204, 2.912842001741518, 0.020000000000000004, 0.0, 0.00011111111111095084, 0.00011111111111095084, 2.9130718970810778, 0.00892395639032173, -0.65928056612358854, -0.64726004504703749, -0.65407996382547184]
[-0.02457286432160799, -0.52177974374618674, 2.2422074141195347, 0.033750000000000002, 0.0, 0.00011111111111095084, 0.00011111111111095084, 2.2419361847664265, 0.097306460625520175, -0.52525582182178676, -0.5331771727501361, -0.52891586701365445]
[-0.030402010050251227, 0.037168395363026234, 2.000351225168246, 0.040000000000000001, 0.0, 0.00011111111111095084, 0.00011111111111095084, 1.9999328163074053, 0.14517524697553874, 0.040697216340696882, 0.035638383724830365, 0.037916003030872364]
[-0.016661880832735121, -0.50209701037217813, 1.2630440674832553, -0.024999999375000005, 0.0, 0.00011111111111095084, 0.00011111111111095084, 1.2638778514116908, 0.085450030670348065, -0.48323187773837417, -0.48321291858483623, -0.48337375630372464]
[-0.0096338837042354575, 0.14184197681513117, 0.83481057567101491, 0.022500000000000003, 0.0, 0.00011111111111095084, 0.00011111111111095084, 0.83452967848110005, 0.048409597480088662, 0.1666402643656692, 0.15546048972205123, 0.16172121955408725]
[-0.0020028715003589381, 0.77426357535082369, 1.9166451040631238, 0.040000000000000001, 0.0, 0.00011111111111095084, 0.00011111111111095084, 1.916272876000243, 0.09776280829712658, 0.7802704045394433, 0.7585316875039162, 0.76997762026914496]
[-0.038040201005025143, 0.96260646735814503, 1.2399701454042067, 0.041875000000000002, 0.0, 0.00011111111111095084, 0.00011111111111095084, 1.2393635912498828, 0.22510839183323894, 1.0089005755837814, 0.97987556969482514, 0.99548486540582881]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[-0.02457286432160799, -1.0980402684563757, 0.91004061925461688, 0.041875000000000002, 0.0, 0.00011111111111095084, 0.00011111111111095084, 0.90922878725487433, 0.29527456101758487, -1.0739364141208247, -1.090579108058831, -1.0803321766785285]
[-0.037975592246948908, 0.20009945088468578, 2.6126075524366987, 0.041875000000000002, 0.0, 0.00011111111111095084, 0.00011111111111095084, 2.6122268156619075, 0.53240849010676183, 0.26053712719849226, 0.22793234742489193, 0.2462967925334385]
[-0.023711414213926751, -1.3585222696766319, 2.5856630750233669, 0.041875000000000002, 0.0, 0.00011111111111095084, 0.00011111111111095084, 2.5851809062821305, 0.42378077391596702, -1.344832864861792, -1.3679548985166976, -1.3543068607094648]
[-0.021191672648959048, -0.89503843807199512, -0.075435379521984203, -0.080625000000000002, 0.0, 0.00011111111111095084, 0.00011111111111095084, -0.07357149400175178, -0.08302842757573603, -0.90507085643232532, -0.89169043008156756, -0.8993696576813206]
[-0.027652548456568615, -1.419626601586333, 1.9363611030907952, 0.041875000000000002, 0.0, 0.00011111111111095084, 0.00011111111111095084, 1.9357304211173045, 0.11304610417278782, -1.4124549044129453, -1.4318450446845969, -1.4171496800904302]

[0.0074874371859295907, 0.44062843197071377, 2.0028013824869011, -0.021874999999999999, 0.0, 0.0, 0.0, 2.0038431098262035, -0.28635060462726314, 0.4146558479972362, 0.44331906301179347, 0.4262522128530567]
[0.0, 0.57626052471018907, 1.3321667948649178, -0.0081250000000000003, 0.0, 0.0, 0.0, 1.3327073975115522, -0.19796810039206469, 0.54868059229903798, 0.55740193530869486, 0.55141630966487409]
[-0.0058291457286432369, 1.1352086638194021, 1.0903106059136289, -0.0018749999999999999, 0.0, 0.0, 0.0, 1.0907040290525309, -0.15009931404204613, 1.1146336304615216, 1.1262174917836614, 1.1182481797094008]
[0.0079109834888728692, 0.59594325808419768, 0.35300344822863838, -0.066874999375000008, 0.0, 0.0, 0.0, 0.35464906415681652, -0.2098245303472368, 0.59070453638245057, 0.60736618947399468, 0.59695842037480396]
[0.014938980617372533, 1.239882245271507, -0.075230043583601969, -0.019375, 0.0, 0.0, 0.0, -0.074699108773774281, -0.24686496353749621, 1.240576678486494, 1.2460395977808822, 1.2420533962326159]
[0.022569992821249052, 1.8723038438071995, 1.0066044848085069, -0.0018749999999999999, 0.0, 0.0, 0.0, 1.0070440887453687, -0.19751175272045829, 1.854206818660268, 1.8491107955627473, 1.8503097969476734]
[-0.013467336683417153, 2.0606467358145206, 0.32992952614958981, 0.0, 0.0, 0.0, 0.0, 0.3301348039950085, -0.070166169184345928, 2.0828369897046062, 2.0704546777536561, 2.0758170420843571]
[0.02457286432160799, 1.0980402684563757, -0.91004061925461688, -0.041875000000000002, 0.0, -0.00011111111111095084, -0.00011111111111095084, -0.90922878725487433, -0.29527456101758487, 1.0739364141208247, 1.090579108058831, 1.0803321766785285]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[-0.013402727925340918, 1.2981397193410615, 1.7025669331820819, 0.0, 0.0, 0.0, 0.0, 1.7029980284070332, 0.23713392908917691, 1.3344735413193169, 1.3185114554837229, 1.326628969211967]
[0.00086145010768123864, -0.26048200122025622, 1.67562245576875, 0.0, 0.0, 0.0, 0.0, 1.6759521190272562, 0.12850621289838215, -0.27089645074096724, -0.27737579045786664, -0.27397468403093628]
[0.0033811916726489422, 0.20300183038438069, -0.98547599877660108, -0.1225, 0.0, 0.0, 0.0, -0.98280028125662611, -0.3783029885933209, 0.16886555768849942, 0.1988886779772634, 0.18096251899720794]
[-0.0030796841349606252, -0.32158633312995732, 1.0263204838361784, 0.0, 0.0, 0.0, 0.0, 1.0265016338624302, -0.18222845684479705, -0.33851849029212056, -0.34126593662576599, -0.33681750341190164]

[0.020890165111270509, -0.85751128737034776, 0.30023444930481924, -0.021874999999999999, 0.0, 0.0, 0.0, 0.30084508141917027, -0.52348453371643999, -0.91981769332208074, -0.87519239247192937, -0.90037675635891035]
[0.013402727925340918, -0.72187919463087247, -0.37040013831716412, -0.0081250000000000003, 0.0, 0.0, 0.0, -0.37029063089548109, -0.4351020294812416, -0.78579294902027896, -0.76110952017502798, -0.77521265954709295]
[0.0075735821966976813, -0.16293105552165954, -0.61225632726845303, -0.0018749999999999999, 0.0, 0.0, 0.0, -0.61229399935450235, -0.38723324313122304, -0.21983991085779536, -0.19229396370006158, -0.20838078950256614]
[0.021313711414213787, -0.70219646125686386, -1.3495634849534435, -0.066874999375000008, 0.0, 0.0, 0.0, -1.3483489642502167, -0.44695845943641371, -0.74376900493686637, -0.71114526600972816, -0.7296705488371632]
[0.028341708542713451, -0.058257474069554602, -1.7777969767656838, -0.019375, 0.0, 0.0, 0.0, -1.7776971371808075, -0.48399889262667312, -0.093896862832823058, -0.072471857702840703, -0.084575572979351255]
[0.03597272074658997, 0.57416412446613796, -0.69596244837357502, -0.0018749999999999999, 0.0, 0.0, 0.0, -0.69595393966166463, -0.4346456818096352, 0.51973327734095109, 0.53059934007902432, 0.52368082773570646]
[-6.4608758076234452e-05, 0.76250701647345931, -1.3726374070324923, 0.0, 0.0, 0.0, 0.0, -1.3728632244120247, -0.30730009827352284, 0.74836344838528923, 0.75194322226993326, 0.74918807287239031]
[0.037975592246948908, -0.20009945088468578, -2.6126075524366987, -0.041875000000000002, 0.0, -0.00011111111111095084, -0.00011111111111095084, -2.6122268156619075, -0.53240849010676183, -0.26053712719849226, -0.22793234742489193, -0.2462967925334385]
[0.013402727925340918, -1.2981397193410615, -1.7025669331820819, 0.0, 0.0, 0.0, 0.0, -1.7029980284070332, -0.23713392908917691, -1.3344735413193169, -1.3185114554837229, -1.326628969211967]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.014264178033022157, -1.5586217205613178, -0.026944477413332057, 0.0, 0.0, 0.0, 0.0, -0.027045909379777133, -0.10862771619079475, -1.6053699920602842, -1.5958872459415896, -1.6006036532429033]
[0.01678391959798986, -1.095137888956681, -2.6880429319586829, -0.1225, 0.0, 0.0, 0.0, -2.6857983096636593, -0.61543691768249786, -1.1656079836308175, -1.1196227775064596, -1.1456664502147591]
[0.010323043790380293, -1.6197260524710189, -0.67624644934590361, 0.0, 0.0, 0.0, 0.0, -0.67649639454460309, -0.41936238593397396, -1.6729920316114375, -1.6597773921094889, -1.6634464726238687]

[0.0066259870782483521, 0.70111043319096999, 0.3271789267181513, -0.021874999999999999, 0.0, 0.0, 0.0, 0.3278909907989474, -0.41485681752564529, 0.68555229873820345, 0.72069485346966011, 0.70022689688399298]
[-0.00086145010768123864, 0.83674252593044529, -0.34345566090383206, -0.0081250000000000003, 0.0, 0.0, 0.0, -0.34324472151570395, -0.32647431329044685, 0.81957704304000523, 0.83477772576656151, 0.82539099369581037]
[-0.0066905958363244755, 1.3956906650396583, -0.58531184985512097, -0.0018749999999999999, 0.0, 0.0, 0.0, -0.58524808997472522, -0.27860552694042828, 1.3855300812024889, 1.403593282241528, 1.3922228637403371]
[0.0070495333811916305, 0.8564252593044539, -1.3226190075401116, -0.066874999375000008, 0.0, 0.0, 0.0, -1.3213030548704396, -0.33833074324561896, 0.86160098712341782, 0.88474197993186132, 0.87093310440574023]
[0.014077530509691294, 1.5003642464917633, -1.750852499352352, -0.019375, 0.0, 0.0, 0.0, -1.7506512278010304, -0.37537117643587836, 1.5114731292274612, 1.5234153882387489, 1.5160280802635522]
[0.021708542713567813, 2.1327858450274557, -0.66901797096024296, -0.0018749999999999999, 0.0, 0.0, 0.0, -0.6689080302818875, -0.32601796561884044, 2.1251032694012353, 2.1264865860206137, 2.1242844809786097]
[-0.014328786791098391, 2.3211287370347771, -1.34569292961916, 0.0, 0.0, 0.0, 0.0, -1.3458173150322477, -0.19867238208272808, 2.3537334404455734, 2.347830468211523, 2.3497917261152939]
[0.023711414213926751, 1.3585222696766319, -2.5856630750233669, -0.041875000000000002, 0.0, -0.00011111111111095084, -0.00011111111111095084, -2.5851809062821305, -0.42378077391596702, 1.344832864861792, 1.3679548985166976, 1.3543068607094648]
[-0.00086145010768123864, 0.26048200122025622, -1.67562245576875, 0.0, 0.0, 0.0, 0.0, -1.6759521190272562, -0.12850621289838215, 0.27089645074096724, 0.27737579045786664, 0.27397468403093628]
[-0.014264178033022157, 1.5586217205613178, 0.026944477413332057, 0.0, 0.0, 0.0, 0.0, 0.027045909379777133, 0.10862771619079475, 1.6053699920602842, 1.5958872459415896, 1.6006036532429033]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[0.0025197415649677035, 0.46348383160463691, -2.6610984545453511, -0.1225, 0.0, 0.0, 0.0, -2.6587524002838823, -0.50680920149170305, 0.43976200842946667, 0.47626446843513004, 0.45493720302814422]
[-0.0039411342426418638, -0.061104331909701104, -0.64930197193257155, 0.0, 0.0, 0.0, 0.0, -0.64945048516482595, -0.3107346697431792, -0.067622039551153312, -0.063890146167899342, -0.062842819380965365]

[0.0041062455132806486, 0.23762660158633309, 2.9882773812635022, 0.10062499999999999, 0.0, 0.0, 0.0, 2.9866433910828296, 0.09195238396605776, 0.24579029030873678, 0.24443038503453007, 0.24528969385584876]
[-0.0033811916726489422, 0.37325869432580838, 2.3176427936415189, 0.114375, 0.0, 0.0, 0.0, 2.3155076787681783, 0.1803348882012562, 0.37981503461053856, 0.35851325733143147, 0.37045379066766615]
[-0.009210337401292179, 0.93220683343502131, 2.0757866046902302, 0.120625, 0.0, 0.0, 0.0, 2.0735043103091568, 0.22820367455127477, 0.94576807277302211, 0.92732881380639787, 0.93728566071219299]
[0.004529791816223927, 0.39294142769981699, 1.3384794470052395, 0.05562500062499999, 0.0, 0.0, 0.0, 1.3374493454134426, 0.1684784582460841, 0.42183897869395109, 0.40847751149673128, 0.41599590137759596]
[0.01155778894472359, 1.0368804148871262, 0.91024595519299911, 0.10312499999999999, 0.0, 0.0, 0.0, 0.90810117248285183, 0.13143802505582469, 1.0717111207979944, 1.0471509198036189, 1.061090877235408]
[0.01918880114860011, 1.6693020134228189, 1.992080483585108, 0.120625, 0.0, 0.0, 0.0, 1.9898443700019948, 0.18079123587286261, 1.6853412609717686, 1.6502221175854839, 1.6693472779504654]
[-0.016848528356066095, 1.8576449054301403, 1.3154055249261909, 0.1225, 0.0, 0.0, 0.0, 1.3129350852516346, 0.30813681940897497, 1.9139714320161068, 1.8715659997763927, 1.8948545230871494]
[0.021191672648959048, 0.89503843807199512, 0.075435379521984203, 0.080625000000000002, 0.0, -0.00011111111111095084, -0.00011111111111095084, 0.07357149400175178, 0.08302842757573603, 0.90507085643232532, 0.89169043008156756, 0.8993696576813206]
[-0.0033811916726489422, -0.20300183038438069, 0.98547599877660108, 0.1225, 0.0, 0.0, 0.0, 0.98280028125662611, 0.3783029885933209, -0.16886555768849942, -0.1988886779772634, -0.18096251899720794]
[-0.01678391959798986, 1.095137888956681, 2.6880429319586829, 0.1225, 0.0, 0.0, 0.0, 2.6857983096636593, 0.61543691768249786, 1.1656079836308175, 1.1196227775064596, 1.1456664502147591]
[-0.0025197415649677035, -0.46348383160463691, 2.6610984545453511, 0.1225, 0.0, 0.0, 0.0, 2.6587524002838823, 0.50680920149170305, -0.43976200842946667, -0.47626446843513004, -0.45493720302814422]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
[-0.0064608758076095674, -0.52458816351433801, 2.0117964826127794, 0.1225, 0.0, 0.0, 0.0, 2.0093019151190563, 0.19607453174852385, -0.50738404798061998, -0.54015461460302938, -0.51778002240910959]

[0.010567121320890216, 0.7622147651006711, 0.97648089865072285, -0.021874999999999999, 0.0, 0.0, 0.0, 0.9773414759637733, -0.10412214778246609, 0.75317433828935676, 0.78458499963755945, 0.76306971626495834]
[0.0030796841349606252, 0.8978468578401464, 0.30584631102873949, -0.0081250000000000003, 0.0, 0.0, 0.0, 0.306205763649122, -0.015739643547267645, 0.88719908259115854, 0.89866787193446085, 0.88823381307677574]
[-0.0027494615936826117, 1.4567949969493594, 0.063990122077450584, -0.0018749999999999999, 0.0, 0.0, 0.0, 0.064202395190100736, 0.032129142802750921, 1.4531521207536422, 1.4674834284094274, 1.4550656831213025]
[0.010990667623833494, 0.917529591214155, -0.67331703560753997, -0.066874999375000008, 0.0, 0.0, 0.0, -0.67185256970561369, -0.027596073502439755, 0.92922302667457113, 0.94863212609976066, 0.9337759237867056]
[0.018018664752333158, 1.5614685784014644, -1.1015505274197803, -0.019375, 0.0, 0.0, 0.0, -1.1012007426362045, -0.064636506692699158, 1.5790951687786143, 1.5873055344066482, 1.5788708996445175]
[0.025649676956209677, 2.193890176937157, -0.019715999027671405, -0.0018749999999999999, 0.0, 0.0, 0.0, -0.019457545117061548, -0.01528329587566124, 2.1927253089523884, 2.190376732188513, 2.1871273003595753]
[-0.010387652548456527, 2.3822330689444779, -0.69639095768658854, 0.0, 0.0, 0.0, 0.0, -0.69636682986742171, 0.11206228766045112, 2.421355479996727, 2.4117206143794219, 2.412634545496259]
[0.027652548456568615, 1.419626601586333, -1.9363611030907952, -0.041875000000000002, 0.0, -0.00011111111111095084, -0.00011111111111095084, -1.9357304211173045, -0.11304610417278782, 1.4124549044129453, 1.4318450446845969, 1.4171496800904302]
[0.0030796841349606252, 0.32158633312995732, -1.0263204838361784, 0.0, 0.0, 0.0, 0.0, -1.0265016338624302, 0.18222845684479705, 0.33851849029212056, 0.34126593662576599, 0.33681750341190164]
[-0.010323043790380293, 1.6197260524710189, 0.67624644934590361, 0.0, 0.0, 0.0, 0.0, 0.67649639454460309, 0.41936238593397396, 1.6729920316114375, 1.6597773921094889, 1.6634464726238687]
[0.0039411342426418638, 0.061104331909701104, 0.64930197193257155, 0.0, 0.0, 0.0, 0.0, 0.64945048516482595, 0.3107346697431792, 0.067622039551153312, 0.063890146167899342, 0.062842819380965365]
[0.0064608758076095674, 0.52458816351433801, -2.0117964826127794, -0.1225, 0.0, 0.0, 0.0, -2.0093019151190563, -0.19607453174852385, 0.50738404798061998, 0.54015461460302938, 0.51778002240910959]
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

[0.0, 3.613151855288971e-17, 2.364972123461872e-17, 6.5693670096163107e-19, 0.0, 0.0, 0.0, 3.1532961646158293e-17, 8.2117087620203889e-18, -7.3576910507702688e-17, -1.6423417524040777e-16, -5.6496556282700279e-17]

In [32]:
plot(data[1][:len(states)], states, '-')
for i in range(8):
    print data[0][i*5000]


"2011-10-12 13:30:00"
"2011-12-03 15:30:00"
"2012-01-24 17:30:00"
"2012-03-16 19:30:00"
"2012-05-07 21:30:00"
"2012-06-28 23:30:00"
"2012-08-20 01:30:00"
"2012-10-11 03:45:00"

In [64]:
def plotColorStatesNoNumber(states, data):
    fig = figure(figsize=(9.0,6))
    for i in range(len(states)):
        if states[i] == -1:   
            plot(i, 0, "ko", hold=True)
        elif states[i] == 0:
            plot(i, 1, "|", color="LawnGreen")
        elif states[i] == 1:
            plot(i, 1, "|", color="LimeGreen")
        elif states[i] == 2:
            plot(i, 1, "|", color="teal")
        elif states[i] == 7:
            plot(i, 1, "|", color="DarkGreen")
        elif states[i] == 4:
            plot(i, 1, "b|")
        elif states[i] == 5:
            plot(i, 1, "|", color="DarkBlue")
        elif states[i] == 6:
            plot(i, 1, "|", color="purple")
        elif states[i] == 3:
            plot(i, 1, "|", color="green")
        elif states[i] == 8:
            plot(i, 1, "|", color="yellow")
        elif states[i] == 9:
            plot(i, 1, "|", color="navy")
        elif states[i] == 11:
            plot(i, 1, "|", color="GreenYellow")
        elif states[i] == 10:
            plot(i, 1, "|", color="orange")
        elif states[i] == 12:
            plot(i, 1, "|", color="red")
        else:
            plot(i, 1, "-")
            print i
            
plotColorStatesNoNumber(states, data)



In [63]:
def plotColorStates(states, data):
    fig = figure(figsize=(9.0,6))
    for i in range(len(states)):
        if states[i] == -1:   
            plot(i, 0, "ko", hold=True)
        elif states[i] == 0:
            plot(i, 9, "|", color="LawnGreen")
        elif states[i] == 1:
            plot(i, 8, "|", color="LimeGreen")
        elif states[i] == 2:
            plot(i, 5, "|", color="teal")
        elif states[i] == 7:
            plot(i, 6, "|", color="DarkGreen")
        elif states[i] == 4:
            plot(i, 4, "b|")
        elif states[i] == 5:
            plot(i, 2, "|", color="DarkBlue")
        elif states[i] == 6:
            plot(i, 1, "|", color="purple")
        elif states[i] == 3:
            plot(i, 7, "|", color="green")
        elif states[i] == 8:
            plot(i, 11, "|", color="yellow")
        elif states[i] == 9:
            plot(i, 3, "|", color="navy")
        elif states[i] == 11:
            plot(i, 10, "|", color="GreenYellow")
        elif states[i] == 10:
            plot(i, 12, "|", color="orange")
        elif states[i] == 12:
            plot(i, 13, "|", color="red")
        else:
            plot(i, 1, "-")
            print i
            
plotColorStates(states, data)



In [59]:
def plotColorStates(states, data):
    fig = figure(figsize=(9.0,6))
    plotlist = []
    for i in range(len(states)):
        if states[i] == -1:   
            plot(i, 0, "o", hold=True)
            plotlist.append(0)
        elif states[i] == 0:
            plot(i, 9, "*")
            plotlist.append(9)
        elif states[i] == 1:
            plot(i, 8, "*")
            plotlist.append(8)
        elif states[i] == 2:
            plot(i, 5, "*")
            plotlist.append(5)
        elif states[i] == 7:
            plot(i, 6, "*")
            plotlist.append(6)
        elif states[i] == 4:
            plot(i, 4, "*")
            plotlist.append(4)
        elif states[i] == 5:
            plot(i, 2, "*")
            plotlist.append(2)
        elif states[i] == 6:
            plot(i, 1, "*")
            plotlist.append(1)
        elif states[i] == 3:
            plot(i, 7, "*")
            plotlist.append(7)
        elif states[i] == 8:
            plot(i, 12, "*")
            plotlist.append(12)
        elif states[i] == 9:
            plot(i, 3, "*")
            plotlist.append(3)
        elif states[i] == 11:
            plot(i, 10, "*")
            plotlist.append(10)
        elif states[i] == 10:
            plot(i, 12, "*")
            plotlist.append(12)
        elif states[i] == 12:
            plot(i, 13, "*")
            plotlist.append(13)
        else:
            
            plot(i, 1, "-")
            print i
    plot(plotlist,"k-")
            
plotColorStates(states, data)



In [69]:
stateCounts = []
for i in range(len(r.models)+1):
    stateCounts.append(0)

for state in states:
    stateCounts[state] += 1
sumtot=0
for i in range(len(stateCounts)):
    print 100*stateCounts[i]/float(len(states)), "percent of time in state", i-1
    sumtot+=100*stateCounts[i]/float(len(states))
print sumtot, len(states)


6.33397843517 percent of time in state -1
17.7080453414 percent of time in state 0
13.8374343378 percent of time in state 1
12.3168371579 percent of time in state 2
12.4578379873 percent of time in state 3
2.49930881946 percent of time in state 4
1.8744816146 percent of time in state 5
0.94277025159 percent of time in state 6
7.53110312414 percent of time in state 7
2.84489908764 percent of time in state 8
6.83715786563 percent of time in state 9
1.25518385402 percent of time in state 10
13.2844899088 percent of time in state 11
0.276472214542 percent of time in state 12
100.0 36170

In [66]:
for i in range(1,len(states)):
    if states[i-1] != states[i]:
        print data[0][i], ":", states[i-1], "->", states[i]


"2011-10-13 14:30:00" : -1 -> 0
"2011-10-17 07:45:00" : 0 -> 1
"2011-10-29 18:00:00" : 1 -> 2
"2011-11-02 07:30:00" : 2 -> 1
"2011-11-04 21:15:00" : 1 -> 2
"2011-11-06 15:15:00" : 2 -> 1
"2011-11-11 21:30:00" : 1 -> 2
"2011-11-13 11:30:00" : 2 -> 1
"2011-11-17 20:30:00" : 1 -> 2
"2011-11-20 15:45:00" : 2 -> 1
"2011-11-21 15:15:00" : 1 -> 2
"2011-11-28 11:00:00" : 2 -> 1
"2011-12-01 01:00:00" : 1 -> 3
"2011-12-02 06:30:00" : 3 -> 2
"2011-12-02 11:00:00" : 2 -> 3
"2011-12-02 12:45:00" : 3 -> 2
"2011-12-02 22:15:00" : 2 -> 3
"2011-12-03 19:45:00" : 3 -> 2
"2011-12-04 22:15:00" : 2 -> 3
"2011-12-09 02:15:00" : 3 -> 4
"2011-12-21 01:45:00" : 4 -> 2
"2011-12-25 15:15:00" : 2 -> 5
"2011-12-26 08:45:00" : 5 -> 2
"2011-12-29 05:00:00" : 2 -> 4
"2011-12-29 09:00:00" : 4 -> 5
"2011-12-31 00:15:00" : 5 -> 4
"2011-12-31 16:00:00" : 4 -> 2
"2012-01-01 00:15:00" : 2 -> 3
"2012-01-02 16:15:00" : 3 -> 4
"2012-01-03 19:45:00" : 4 -> 5
"2012-01-04 15:15:00" : 5 -> 6
"2012-01-05 15:15:00" : 6 -> 4
"2012-01-14 21:45:00" : 4 -> 6
"2012-01-17 05:15:00" : 6 -> 4
"2012-01-19 06:00:00" : 4 -> 6
"2012-01-20 04:00:00" : 6 -> 4
"2012-01-21 02:45:00" : 4 -> 6
"2012-01-23 03:45:00" : 6 -> 4
"2012-01-28 07:15:00" : 4 -> 7
"2012-01-30 14:15:00" : 7 -> 4
"2012-01-31 04:15:00" : 4 -> 5
"2012-01-31 23:15:00" : 5 -> 2
"2012-02-03 10:30:00" : 2 -> 5
"2012-02-03 20:45:00" : 5 -> 2
"2012-02-05 02:00:00" : 2 -> 5
"2012-02-06 04:30:00" : 5 -> 2
"2012-02-08 07:45:00" : 2 -> 5
"2012-02-08 23:45:00" : 5 -> 2
"2012-02-12 06:00:00" : 2 -> 5
"2012-02-14 04:15:00" : 5 -> 2
"2012-02-26 02:45:00" : 2 -> 4
"2012-02-26 15:15:00" : 4 -> 5
"2012-02-27 23:00:00" : 5 -> 4
"2012-02-28 04:30:00" : 4 -> 2
"2012-02-29 00:15:00" : 2 -> 4
"2012-03-06 00:45:00" : 4 -> 6
"2012-03-06 19:45:00" : 6 -> 4
"2012-03-08 03:30:00" : 4 -> 3
"2012-03-09 16:15:00" : 3 -> 4
"2012-03-12 06:15:00" : 4 -> 3
"2012-03-15 02:15:00" : 3 -> 4
"2012-03-17 14:15:00" : 4 -> 3
"2012-03-21 10:30:00" : 3 -> 8
"2012-03-22 00:15:00" : 8 -> 1
"2012-03-22 08:30:00" : 1 -> 0
"2012-03-25 16:45:00" : 0 -> 1
"2012-03-26 14:15:00" : 1 -> 2
"2012-03-27 19:30:00" : 2 -> 9
"2012-04-02 06:15:00" : 9 -> 1
"2012-04-02 15:45:00" : 1 -> 9
"2012-04-04 03:30:00" : 9 -> 1
"2012-04-05 14:00:00" : 1 -> 9
"2012-04-09 08:45:00" : 9 -> 1
"2012-04-15 09:30:00" : 1 -> 0
"2012-04-17 08:30:00" : 0 -> 10
"2012-04-18 04:00:00" : 10 -> 0
"2012-04-18 21:00:00" : 0 -> 1
"2012-04-19 08:30:00" : 1 -> 0
"2012-04-21 00:30:00" : 0 -> 10
"2012-04-21 18:30:00" : 10 -> 0
"2012-04-22 11:45:00" : 0 -> 1
"2012-04-25 04:45:00" : 1 -> 2
"2012-04-25 09:15:00" : 2 -> 1
"2012-04-27 16:15:00" : 1 -> 2
"2012-04-30 14:30:00" : 2 -> 1
"2012-05-01 14:45:00" : 1 -> 3
"2012-05-09 23:30:00" : 3 -> 8
"2012-05-10 19:30:00" : 8 -> 3
"2012-05-12 12:30:00" : 3 -> 8
"2012-05-18 02:00:00" : 8 -> 7
"2012-05-18 08:30:00" : 7 -> 8
"2012-05-30 07:15:00" : 8 -> 11
"2012-06-01 16:45:00" : 11 -> 8
"2012-06-02 01:30:00" : 8 -> 3
"2012-06-02 03:00:00" : 3 -> 1
"2012-06-02 08:15:00" : 1 -> 10
"2012-06-02 09:15:00" : 10 -> 0
"2012-06-03 06:45:00" : 0 -> 1
"2012-06-10 13:00:00" : 1 -> 10
"2012-06-13 18:30:00" : 10 -> 1
"2012-06-14 10:30:00" : 1 -> 8
"2012-06-15 01:00:00" : 8 -> 1
"2012-06-15 11:45:00" : 1 -> 8
"2012-06-15 16:00:00" : 8 -> 1
"2012-06-16 07:45:00" : 1 -> 10
"2012-06-16 17:45:00" : 10 -> 1
"2012-06-19 23:30:00" : 1 -> 10
"2012-06-20 14:00:00" : 10 -> 12
"2012-06-25 21:00:00" : 12 -> 1
"2012-06-26 13:15:00" : 1 -> 3
"2012-06-28 10:45:00" : 3 -> 12
"2012-08-06 22:45:00" : 12 -> 8
"2012-08-08 05:30:00" : 8 -> 12
"2012-08-10 02:00:00" : 12 -> 8
"2012-08-11 03:30:00" : 8 -> 11
"2012-08-13 10:30:00" : 11 -> 8
"2012-08-13 19:45:00" : 8 -> 12
"2012-08-14 02:45:00" : 12 -> 10
"2012-08-19 02:45:00" : 10 -> 0
"2012-08-20 15:00:00" : 0 -> 10
"2012-08-20 15:30:00" : 10 -> 0
"2012-08-20 23:15:00" : 0 -> 10
"2012-08-22 01:15:00" : 10 -> 0
"2012-08-23 05:15:00" : 0 -> 10
"2012-08-29 07:30:00" : 10 -> 0
"2012-08-30 22:00:00" : 0 -> 10
"2012-09-02 18:00:00" : 10 -> 0
"2012-09-03 09:15:00" : 0 -> 10
"2012-09-04 12:30:00" : 10 -> 0
"2012-09-05 06:45:00" : 0 -> 10
"2012-09-09 00:30:00" : 10 -> 12
"2012-09-09 16:15:00" : 12 -> 1
"2012-09-13 08:15:00" : 1 -> 12
"2012-09-15 15:30:00" : 12 -> 1
"2012-09-19 04:45:00" : 1 -> 12
"2012-09-19 08:30:00" : 12 -> 3
"2012-09-19 11:15:00" : 3 -> 8
"2012-09-19 21:30:00" : 8 -> 3
"2012-09-23 04:00:00" : 3 -> 8
"2012-09-23 18:15:00" : 8 -> 3
"2012-10-02 12:00:00" : 3 -> 8
"2012-10-07 01:45:00" : 8 -> 3
"2012-10-12 13:15:00" : 3 -> 4
"2012-10-14 09:15:00" : 4 -> 7
"2012-10-15 09:00:00" : 7 -> 11
"2012-10-15 10:00:00" : 11 -> 3
"2012-10-15 22:45:00" : 3 -> 1
"2012-10-16 07:00:00" : 1 -> 0
"2012-10-21 03:30:00" : 0 -> 1

In [ ]:
def parallel_coordinates(data_sets, style=None):

    dims = len(data_sets[0])
    x    = range(dims)
    fig, axes = subplots(1, dims-1, sharey=False)

    
    
    if style is None:
        style = ['r-']*len(data_sets)

    # Calculate the limits on the data
    min_max_range = list()
    for m in zip(*data_sets):
        mn = min(m)
        mx = max(m)
        #print mx, mn
        if mn == mx:
            mn -= 0.5
            mx = mn + 1

        r  = float(mx - mn)
        min_max_range.append((mn, mx, r))

    # Normalize the data sets
    norm_data_sets = list()
    for ds in data_sets:
        nds = [(value - min_max_range[dimension][0]) / 
                min_max_range[dimension][2] 
                for dimension,value in enumerate(ds)]
        norm_data_sets.append(nds)
    data_sets = norm_data_sets

    # Plot the datasets on all the subplots
    for i, ax in enumerate(axes):
        for dsi, d in enumerate(data_sets):
            ax.plot(x, d, style[dsi])
        ax.set_xlim([x[i], x[i+1]])

    # Set the x axis ticks 
    for dimension, (axx,xx) in enumerate(zip(axes, x[:-1])):
        axx.xaxis.set_major_locator(FixedLocator([xx]))
        ticks = len(axx.get_yticklabels())
        labels = list()
        step = min_max_range[dimension][2] / (ticks - 1)
        mn   = min_max_range[dimension][0]
        for i in xrange(ticks):
            v = mn + i*step
            labels.append('%4.2f' % v)
        axx.set_yticklabels(labels)


    # Move the final axis' ticks to the right-hand side
    axx = twinx(axes[-1])
    dimension += 1
    axx.xaxis.set_major_locator(FixedLocator([x[-2], x[-1]]))
    ticks = len(axx.get_yticklabels())
    step = min_max_range[dimension][2] / (ticks - 1)
    mn   = min_max_range[dimension][0]
    labels = ['%4.2f' % (mn + i*step) for i in xrange(ticks)]
    axx.set_yticklabels(labels)

    # Stack the subplots 
    subplots_adjust(wspace=0)

    return plt

In [ ]:
"""
minidata = []
for j in range(500):
    minidata.append([])
    for i in range(1, len(data)):
        minidata[j].append(data[i][j])

print minidata
"""
vectors = []
for model in r.models:
    vectors.append(model.vector)
print vectors[0][0]
    
colors = ['r'] * len(vectors[0])
"""
colors.extend(['b'] * len(vectors[0]))
colors.extend(['g'] * len(vectors[0]))
colors.extend(['r'] * len(vectors[0]))
colors.extend(['s'] * len(vectors[0]))
colors.extend(['d'] * len(vectors[0]))
colors.extend(['m'] * len(vectors[0]))
colors.extend(['p'] * len(vectors[0]))
colors.extend(['t'] * len(vectors[0]))
colors.extend(['f'] * len(vectors[0]))
"""

colors = ['r']
colors.extend(['b'])
colors.extend(['g'])
colors.extend(['r'])
colors.extend(['s'])
colors.extend(['d'])
colors.extend(['m'])
colors.extend(['p'])
colors.extend(['r'])
colors.extend(['r']*(len(vectors)))

parallel_coordinates(vectors, style=colors).show()

In [ ]:
r2 = ARAVQ(100, 1, .9, 2, .2)

#print data
states = []
maxes = []
for i in range(len(data)):
    m = max([data[i][j] for j in range(500)])
    maxes.append(m)


for i in range(len(data[0])):
    r.input(getVec(data, maxes, i))
    #print getVec(data, maxes, i)
    states.append(r.newWinnerIndex)
    #if len(states) > 10000:
        #break
print states

In [10]:
import pandas as pd

def readin(files):
    openFiles = []
    data = []
    sensorStreams = []
    lineLen = 0
    labels = []

    for i in range(len(files)):
        openFiles.append(open(files[i], "r"))
        firstline = openFiles[i].readline()
        firstline = firstline.split(",")
        data.append([])
        for item in firstline:
            labels.append(item)
            sensorStreams.append([])
        
        for line in openFiles[i]:
            line = line.split(",")
            line = [j.strip(",.\n\r ") for j in line]
            for j in range(len(line)):
                try:
                    line[j] = float(line[j])
                except:
                    line[j] = -1
            data[i].append(line)
    
    
    catData = []
    for i in range(len(data)):
        catData += data[i]
    print labels
    pd.DataFrame(array(catData), columns=labels)

In [11]:
data = readin(["wxsta1_alldat.csv", "weir1_Weir.dat"])


---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
/home/emily/Code/cs97Project/<ipython-input-11-4ceed99a5138> in <module>()
----> 1 data = readin(["wxsta1_alldat.csv", "weir1_Weir.dat"])

/home/emily/Code/cs97Project/<ipython-input-10-fe11e113f92e> in readin(files)
     32         catData += data[i]
     33     print labels
---> 34     pd.DataFrame(array(catData), columns=labels)

/usr/lib/pymodules/python2.7/pandas/core/frame.pyc in __init__(self, data, index, columns, dtype, copy)
    296             else:
    297                 mgr = self._init_ndarray(data, index, columns, dtype=dtype,
--> 298                                          copy=copy)
    299         elif isinstance(data, list):
    300             if len(data) > 0:

/usr/lib/pymodules/python2.7/pandas/core/frame.pyc in _init_ndarray(self, values, index, columns, dtype, copy)
    396 
    397         columns = _ensure_index(columns)
--> 398         block = make_block(values.T, columns, columns)
    399         return BlockManager([block], [columns, index])
    400 

/usr/lib/pymodules/python2.7/pandas/core/internals.pyc in make_block(values, items, ref_items, do_integrity_check)
    252 
    253     return klass(values, items, ref_items, ndim=values.ndim,
--> 254                  do_integrity_check=do_integrity_check)
    255 
    256 # TODO: flexible with index=None and/or items=None


/usr/lib/pymodules/python2.7/pandas/core/internals.pyc in __init__(self, values, items, ref_items, ndim, do_integrity_check)
     23 
     24         assert(values.ndim == ndim)
---> 25         assert(len(items) == len(values))
     26 
     27         self.values = values

AssertionError: 
['"DATETIME"', '"V"', '"PCP_Depth"', '"PCP"', '"RH"', '"minAirTC"', '"maxAirTC"', '"avgAirTC"\n', '"TOA5"', '"weir1"', '"CR1000"', '"35388"', '"CR1000.Std.20"', '"CPU:weir1.CR1"', '"47646"', '"Weir"\r\n']

In [ ]: