def test_batch_apply(points_1): c = Calibraxis(verbose=False) c.add_points(points_1) c.calibrate_accelerometer() out = c.batch_apply(points_1) normed = np.sqrt((np.array(out) ** 2).sum(axis=1)) np.testing.assert_array_almost_equal(normed, 1.0, 2)
def test_batch_apply(points_1): c = Calibraxis(verbose=False) c.add_points(points_1) c.calibrate_accelerometer() out = c.batch_apply(points_1) normed = np.sqrt((np.array(out)**2).sum(axis=1)) np.testing.assert_array_almost_equal(normed, 1.0, 2)
import numpy as np from calibraxis import Calibraxis c = Calibraxis() points = np.array([[-4772.38754098, 154.04459016, -204.39081967], [3525.0346179, -68.64924886, -34.54604833], [-658.17681729, -4137.60248854, -140.49377865], [-564.18562092, 4200.29150327, -130.51895425], [-543.18289474, 18.14736842, -4184.43026316], [-696.62532808, 15.70209974, 3910.20734908], [406.65271419, 18.46827992, -4064.61085677], [559.45926413, -3989.69513798, -174.71879106], [597.22629169, -3655.54153041, -1662.83257031], [1519.02616089, -603.82472204, 3290.58469588]]) # Add points to calibration object's storage. c.add_points(points) # Run the calibration parameter optimization. c.calibrate_accelerometer() # Applying the calibration parameters to the calibration data. c.apply(points[0:]) c.batch_apply(points)
print(np.array([jug.ax.mean(), jug.ay.mean(), jug.az.mean()])) print(np.array([jug.gx.mean(), jug.gy.mean(), jug.gz.mean()])) r = open('raw_juggle_data.csv') r_lines = r.readlines() r_lines = r_lines[:-1] raw_data = genfromtxt(r_lines, delimiter=',')[1:, 1:-1] print(raw_data.T.mean(axis=1)) #CALIBRATION ROUTINE points = np.zeros((len(jug.t), 3)) points[:, 0] = jug.ax points[:, 1] = jug.ay points[:, 2] = jug.az new_points = np.array(c.batch_apply(points)) #new_points = points '''c = Calibraxis() # Add points to calibration object's storage. c.add_points(points) # Run the calibration parameter optimization. c.calibrate_accelerometer() c.batch_apply(points)''' jug.ax = new_points[:, 0] jug.ay = new_points[:, 1] jug.az = new_points[:, 2] f, axarr = plt.subplots(6, sharex=True) axarr[0].plot(jug.t, jug.ax) axarr[1].plot(jug.t, jug.ay)