def dump(): h5file = tables.openFile(DATA_FILE, mode='r') data = h5file.root.ramppi11.rawdata[:] sids = SESSIONS[-3:-1] #sids = np.unique(data['session_id'])#[-2:] sbends = [BENDS[1], BENDS[3]] for sid in sids: datapath = dirs[sid] ls = os.listdir(datapath) vids = [file for file in ls if file.lower().endswith('.mp4')] print sid, vids if len(vids) > 1: vid = os.path.join(datapath, vids[1]) else: vid = os.path.join(datapath, vids[0]) frame_to_vid = sync_smarteye_video.se_timestamp_fit(vid) print frame_to_vid dir1 = os.path.join(naksudir, str(sid)) if not os.path.exists(dir1): os.mkdir(dir1) for bend in sbends: dir2 = os.path.join(dir1, 'bend'+str(BENDS.index(bend)+1)) if not os.path.exists(dir2): os.mkdir(dir2) bdata = get_segment_data(sid, bend, data) laps = np.unique(bdata['lap']) for lap in laps: dir3 = os.path.join(dir2, 'lap'+str(lap)) if not os.path.exists(dir3): os.mkdir(dir3) ldata = bdata[ bdata['lap'] == lap ] videots = np.polyval(frame_to_vid, ldata['se_frame_number']) #plt.figure() #plt.plot(ldata['se_frame_number'], videots, ',b') #plt.show() print lap, videots[0], videots[-1] duration = videots[-1] - videots[0] Popen("avconv -i " + vid + " -qscale 1 -ss " + str(videots[0]) + " -t " + str(duration) + " " + os.path.join(dir3, "image%5d.jpg"), stdout=PIPE, shell=True).communicate()[0] h5file.close()
def plot_naksu_by_sid_and_bend(): data = get_merged_data() ci = 3 pdf_out = PdfPages('/tmp/naksu_by_sid_and_bend_'+str(ci)+'.pdf') for sid in SESSIONS: sdata = data[ data['session_id'] == sid] plt.figure() plt.title(sid) for lap in np.unique(sdata['lap']): ldata = sdata[ sdata['lap'] == lap ] segdata = get_segment_data(sid, CORNERING[ci], ldata) plt.plot(segdata['dist'], segdata['naksu_x'], '-g') pdf_out.savefig() plt.close() pdf_out.close()