forked from jack-duval/helmet-data-viz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
79 lines (60 loc) · 1.99 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import firebase_admin
from firebase_admin import credentials
from firebase_admin import db
import matplotlib.pyplot as plt
import numpy as np
from dotenv import dotenv_values
if __name__ == "__main__":
# Fetch the service account key JSON file contents
config = dotenv_values(".env")
path = config["PATH"]
# print(path)
cred = credentials.Certificate(path)
# Initialize the app with a service account, granting admin privileges
firebase_admin.initialize_app(cred, {
'databaseURL': 'https://nu-capstone-db-default-rtdb.firebaseio.com/'
})
sheet = '/impact_testing_throw/4faf183e-1fb5-459e-8fcc-c5c9c331914b/'
ref = db.reference(sheet)
test_ref = '/impact_testing_throw/'
helmets = test_ref.order_by_key().get()
times = ref.order_by_key().get()
# print(times)
a1 = {"x": [], "y": [], "z": []}
a2 = {"x": [], "y": [], "z": []}
a3 = {"x": [], "y": [], "z": []}
t = []
i = 0
for key, value in times.items():
t.append(i)
i += 1
a1.get("x").append(value.get("x1"))
a1.get("y").append(value.get("y1"))
a1.get("z").append(value.get("z1"))
a2.get("x").append(value.get("x2"))
a2.get("y").append(value.get("y2"))
a2.get("z").append(value.get("z2"))
a3.get("x").append(value.get("x3"))
a3.get("y").append(value.get("y3"))
a3.get("z").append(value.get("z3"))
plt.plot(t, a1.get('x')) # blue
plt.plot(t, a1.get('y')) # orange
plt.plot(t, a1.get('z')) # green
plt.xlabel('time')
plt.ylabel('accel')
plt.title('a1')
plt.show()
plt.plot(t, a2.get('x')) # blue
plt.plot(t, a2.get('y')) # orange
plt.plot(t, a2.get('z')) # green
plt.xlabel('time')
plt.ylabel('accel')
plt.title('a2')
plt.show()
plt.plot(t, a3.get('x')) # blue
plt.plot(t, a3.get('y')) # orange
plt.plot(t, a3.get('z')) # green
plt.xlabel('time')
plt.ylabel('accel')
plt.title('a3')
plt.show()