def test_stair_freeyaw(self): """ """ fname = '/home/dave/Repositories/public/0_davidovitch/' fname += 'freeyaw-ojf-wt-tests/data/calibrated/DataFrame/' fname += '0212_run_064_9.0ms_dc1_freeyawplaying_stiffblades' fname += '_coning_pwm1000_highrpm.h5' res = pd.read_hdf(fname, 'table') time = res.time.values sps = 1.0 / np.diff(time).mean() ff = Filters() cutoff_hz = 1.0 order = 2 Wn = cutoff_hz*2.0/sps B, A = sp.signal.butter(order, Wn, output='ba') yawf = sp.signal.filtfilt(B, A, res.yaw_angle.values) # YAW plt.figure('yaw') plt.plot(res.time, res.yaw_angle, 'r-') plt.plot(res.time, yawf, 'b-') B, A = sp.signal.butter(order, 1.0*2.0/sps, output='ba') yawf2 = sp.signal.filtfilt(B, A, res.yaw_angle.values) plt.plot(res.time, yawf2, 'k--') # RPM data = res.rpm.values data_f = ff.butter_lowpass(sps, data, order=2, cutoff_hz=1.0) plt.figure('rpm') plt.plot(res.time, data, 'r-') plt.plot(res.time, data_f, 'b-') # filtered_x, N, delay = ff.fir(time, res.rpm, cutoff_hz=1.0, # freq_trans_width=1.0, ripple_db=50.0) # plt.plot(res.time, filtered_x, 'k--') smooth_window = 2.0 ws = int(smooth_window*sps) data_s = ff.smooth(res.rpm, window_len=ws, window='hanning') NN = len(data_s) - len(time) data_s = data_s[NN:] # time_s = time[NN:] plt.plot(time+(smooth_window/2.0), data_s, 'k--') # and up again in order not to brake the plotting further down time_down = np.arange(time[0], time[-1], 0.1) data_f_down = sp.interpolate.griddata(time, data_f, time_down) plt.plot(time_down, data_f_down, 'm-', alpha=0.7) # # and upsampling again # data = sp.interpolate.griddata(time_down, data_down, time) slope, intercept, r_value, p_value, std_err \ = sp.stats.linregress(data_f_down, y=time_down)
def test_linregress(self): """ """ fname = '/home/dave/Repositories/public/0_davidovitch/' fname += 'freeyaw-ojf-wt-tests/data/calibrated/DataFrame/' fname += '0212_run_064_9.0ms_dc1_freeyawplaying_stiffblades' fname += '_coning_pwm1000_highrpm.h5' res = pd.read_hdf(fname, 'table') time = res.time.values sps = 1.0 / np.diff(time).mean() freq_down = 0.1 window = 4.0 ff = Filters() data = res.rpm.values data_f = ff.butter_lowpass(sps, data, order=2, cutoff_hz=1.0) time_down = np.arange(time[0], time[-1], freq_down) data_f_down = sp.interpolate.griddata(time, data_f, time_down) regress = ff.linregress(time_down, data_f_down, int(window/freq_down)) diff = np.diff(data_f_down) / freq_down plt.figure('rpm') plt.plot(time, data, 'r-') plt.plot(time_down, data_f_down, 'k--') plt.twinx() plt.plot(time_down[:-int(window/freq_down)], np.abs(regress[:,0]), 'b--') plt.plot(time_down[:-1], np.abs(diff), 'g--') plt.ylim([0, 5]) plt.grid() data = res.yaw_angle.values data_f = ff.butter_lowpass(sps, data, order=2, cutoff_hz=1.0) data_f_down = sp.interpolate.griddata(time, data_f, time_down) regress = ff.linregress(time_down, data_f_down, int(window/freq_down)) diff = np.diff(data_f_down) / freq_down plt.figure('yaw') plt.plot(time, data, 'r-') plt.plot(time_down, data_f_down, 'k--') plt.twinx() plt.plot(time_down[:-int(window/freq_down)], np.abs(regress[:,0]), 'b--') plt.plot(time_down[:-1], np.abs(diff), 'g--') plt.ylim([0, 5]) plt.grid()