trim_end = end if (trim_end > end or trim_end is None) else trim_end # interpolate some NaN values compute.interpolate3(data, start, end) if "_side" in ftxt: data_s = data elif "_top" in ftxt: data_t = data print "TRIM: ", trim_start, trim_end, trim_end-trim_start 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)
data = np.array(utils.read_txt(name_txt)) # round the data to clean um some noise data = np.round(np.array(utils.read_txt(name_txt)), 2) # trim the initial and final NaN values data = compute.trim(data, 1) 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)