Example #1
0
# Fields from "charactercurves.py" extracted from raw data to use for
# training.  Currently: avg, rms, freq, periodicity
inputfields = ['rms', 'periodicity']

########## Load and calculate data

minibees, fields = read_minibees()
mbIds = sort(minibees.keys())

offsets = [find_offsets(minibees[mb]) for mb in mbIds]
ds = [split_data_on_offsets(minibees[mb], o)
      for mb, o in zip(mbIds, offsets)]

curves = [calc_curves((d[VIDEO][:,4]-d[VIDEO][0,4])/30.0,
                      mag(d[VIDEO][:,5:8]), 0.1)
          for d in ds]

tags = read_tags()

frames = curves[1]['time']*30
frametags = [tags.frame_tags(int(ds[1][1][0,3]), f) for f in frames]

def normalized(x):
    return (x - min(x)) / (max(x)-min(x))

def avg_curves(curves):
    end = min([len(c) for c in curves[0]])
    output = [zeros(end) for x in range(len(curves))]
    inputs = range(len(curves[0]))
    for f, field in enumerate(curves):
Example #2
0
def unwrap_time(time, timediff):
    brks = [n for n,d in enumerate((time[1:]-time[:-1])) if d < -timediff]
    idx = arange(time.size)
    return sum([time] + [(idx > b)*time[b] for b in brks], axis=0)

time_range = (0,100000000000)
all_interp = {}
for m in minibees.keys():
    time = unwrap_time(minibees[m][:,4]/30.0, 500)
    time_range = (max(time_range[0], time[0]),
                  min(time_range[1], time[-1]))

for m in minibees.keys():
    time = unwrap_time(minibees[m][:,4]/30.0, 500)
    all_interp[m] = interp1d(time, mag(minibees[m][:,5:8]))

subsamp = 3
time = arange((time_range[1]-time_range[0])*subsamp)/subsamp+time_range[0]
hopsize = 20
length = 100
hopidx = arange(time.size)[:-length:hopsize]
hoptime = array([time[i] for i in hopidx])
all_mag = array([all_interp[m](time) for m in sort(minibees.keys())])

ccorr = [sum(corrcoef(all_mag[:,i:i+length])) for i in hopidx]
ccov = [sum(cov(all_mag[:,i:i+length])) for i in hopidx]

rc('legend',fontsize=8)

clf()
Example #3
0
minibees, fields = read_minibees()
ion()
clf()
draw()

hopsize = 20
smoothing = 0.05
sr = 10.0
L1 = 1000
L2 = 500

final_results = {}
for m in minibees.keys():
    print m
    data = mag(minibees[m][:,5:8])

    final_results[m] = plot_f0(data, sr, m, hopsize, L1, L2, smoothing)

    savefig('workshop_autocorr_10hz_m%d.png'%m)
    draw()

def unwrap_time(time, timediff):
    brks = [n for n,d in enumerate((time[1:]-time[:-1])) if d < -timediff]
    idx = arange(time.size)
    return sum([time] + [(idx > b)*time[b] for b in brks], axis=0)

clf()
time_range = (0,100000000000)
freqs = []
frdiffs = []