-
Notifications
You must be signed in to change notification settings - Fork 0
/
JTR_plotting.py
53 lines (43 loc) · 1.3 KB
/
JTR_plotting.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
import matplotlib.pyplot as plt
import json
import math
import easygui
import numpy as np
import os
path = easygui.fileopenbox()
jet_current = []
thrust = []
efficiency = []
def load_log():
global jet_current
global thrust
global efficiency
with open(path, "r") as log_file:
for line in log_file.readlines():
obj = json.loads(line)
jet_current.append(obj["current"])
thrust.append(obj["thrust"])
efficiency.append(obj["thrust"]/obj["current"])
def plot():
fig, ax1 = plt.subplots()
ax1.plot(jet_current, label="Jet Current", color = 'g')
ax2 = ax1.twinx() #second y axis
ax2.plot(thrust, label="Thrust", color="r")
ax2.legend(loc = 'upper right')
plt.title("Jet Current Draw and Thrust vs. Throttle Request")
ax1.set_xlabel("Throttle Request")
ax1.set_ylabel("Jet Current Draw (Amps)")
ax1.legend(loc = 'lower right')
ax2.set_ylabel("Thrust (grams-force)")
ax1.grid()
#plt.figure()
fig, ax3 = plt.subplots()
ax3.plot(efficiency, label="Jet Efficiency", color = 'b')
plt.title("Efficiency (grams-force/Amp)")
ax3.set_xlabel("Throttle Request")
ax3.set_ylabel("Efficiency (grams-force/Amp)")
ax3.legend(loc = 'lower right')
ax3.grid()
plt.show()
load_log()
plot()