data_s = data_s[trim_start:trim_end, :] data_t = data_t[trim_start:trim_end, :] # smooth the position data data_s[:, 1] = compute.smooth(data_s[:, 1], win_size=WIN_SMOOTH_SIZE) data_s[:, 2] = compute.smooth(data_s[:, 2], win_size=WIN_SMOOTH_SIZE) # smooth the position data data_t[:, 1] = compute.smooth(data_t[:, 1], win_size=WIN_SMOOTH_SIZE) data_t[:, 2] = compute.smooth(data_t[:, 2], win_size=WIN_SMOOTH_SIZE) # get the time variable to use in the future T = data_s[:, 0] # compute speed and acceleration (veloc_s, accel_s) = compute.velocity(data_s, win_size=WIN_VELOCITY_SIZE) (veloc_t, accel_t) = compute.velocity(data_t, win_size=WIN_VELOCITY_SIZE) # dchanges = compute.dir_changesX2(data, win_size=100) dchanges_s = compute.dir_changesX3(data_s, win_size=WIN_CHANGE_DIR_SIZE) dchanges_t = compute.dir_changesX3(data_t, win_size=WIN_CHANGE_DIR_SIZE) (fs, es, thy, thv, tha, thdc) = compute.decide3(T, data_s[:, 2], veloc_s, veloc_t, accel_s, accel_t, dchanges_s, THRES_V, THRES_Y, THRESHOLD_DC, THRESHOLD_A) intervals = compute.interval_list(fs, es, T) compute.subtitle(intervals, name_sub) bins = compute.report(fs, es, data_s, 0, name_rep, BIN_SIZE) bins_list[key] = bins if SHOW_3D: utils.plot3d(data_t[:, 1], data_t[:, 2], data_s[:, 2], fs, es, XLIMS, YLIMS, ZLIMS, fname=name_fig2, fdpi=FIG_DPI, style=FIG3D, style_normal=FIG3D_NORMAL, style_erratic=FIG3D_ERRATIC, style_freeze=FIG3D_FREEZE)
data = compute.trim(data, 2) # interpolate some NaN values compute.interpolate(data, 1) compute.interpolate(data, 2) # smooth the position data data_smooth = data data_smooth[:, 1] = compute.smooth(data[:, 1], win_size=25) data_smooth[:, 2] = compute.smooth(data[:, 2], win_size=25) # get the time variable to use in the future T = data[:, 0] # compute speed and acceleration (veloc, accel) = compute.velocity(data_smooth, win_size=125) #dchanges = compute.dir_changesX2(data, win_size=100) dchanges = compute.dir_changesX3(data, win_size=10) #(fs, es) = compute.decide(data, veloc, accel, dchanges) (fs, es) = compute.decide2(T, veloc, data[:, 2], accel, dchanges) intervals = compute.interval_list(fs, es, data, 0) compute.subtitle(intervals, name_sub) compute.report(fs, es, data, 0, name_rep) plt.figure(1) plt.subplot(5, 1, 1) plt.plot(T, data[:, 1]) # X