-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_them_all.py
95 lines (70 loc) · 4.01 KB
/
plot_them_all.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import pandas as pd
import matplotlib.pyplot as plt
test_ids = ["CF-O1", "CF-O2", "CF-O3", "CF-O4", "CF-O5"]
SENSOR_FILE = "compiled\\sensors_selected.csv"
ACTUATOR_FILE = "compiled\\actuators_selected.csv"
def main():
global sensors_dfs, actuators_dfs
sensors_dfs = []
actuators_dfs = []
for test_id in test_ids:
setup(test_id)
flow_study()
def setup(test_id):
global sensors_dfs, actuators_dfs
sensors_df = pd.read_csv("Data\\" + test_id + "\\" + SENSOR_FILE)
actuators_df = pd.read_csv("Data\\" + test_id + "\\" + ACTUATOR_FILE)
if (test_id == "CF-O1"):
# Rename the sensors ("OXGS-PT-002", "OXGS-PT-001", "OXFL-PT-001", "OXFL-LC-001", "OXCC-PT-001") to ("PGS", "PGSO", "POTT", "MOT", "POTB")
sensors_df.rename(columns={"OXGS-PT-002": "PGS", "OXGS-PT-001": "PGSO", "OXFL-PT-001": "POTT", "OXFL-LC-001": "MOT", "OXCC-PT-001": "POTB"}, inplace=True)
# Rename the actuators ("OXGS-O-FILL", "OXGS-P-FILL", "ENABLE OXFL-A-FILL", "OXFL-A-FILL", "OXFL-A-VENT", "OXFL-A-DUMP", "OXGS-A-FILL", "OXGS-MOV", "OXGS-A-DUMP")
# to ("BVGSO", "BVGSP", "ENABLE_BVOTP", "BVOTP", "SVOTV", "SVOTD", "BVGS", "SVMOV", "SVGSD")
actuators_df.rename(columns={"OXGS-O-FILL": "BVGSO", "OXGS-P-FILL": "BVGSP", "ENABLE OXFL-A-FILL": "ENABLE_BVOTP", "OXFL-A-FILL": "BVOTP", "OXFL-A-VENT": "SVOTV", "OXFL-A-DUMP": "SVOTD", "OXGS-A-FILL": "BVGS", "OXGS-MOV": "SVMOV", "OXGS-A-DUMP": "SVGSD"}, inplace=True)
if (test_id == "CF-O2"):
# Rename the sensors ("OXGS-PT-002", "OXGS-PT-001", "OXFL-PT-001", "OXFL-LC-001", "OXCC-PT-001") to ("PGS", "PGSO", "POTB", "MOT", "PCC")
sensors_df.rename(columns={"OXGS-PT-002": "PGS", "OXGS-PT-001": "PGSO", "OXFL-PT-001": "POTB", "OXFL-LC-001": "MOT", "OXCC-PT-001": "PCC"}, inplace=True)
# Rename the actuators ("OXGS-O-FILL", "OXGS-P-FILL", "ENABLE OXFL-A-FILL", "OXFL-A-FILL", "OXFL-A-VENT", "OXFL-A-DUMP", "OXGS-A-FILL", "OXGS-MOV", "OXGS-A-DUMP")
# to ("BVGSO", "BVGSP", "ENABLE_BVOTP", "BVOTP", "SVOTV", "SVOTD", "BVGS", "SVMOV", "SVGSD")
actuators_df.rename(columns={"OXGS-O-FILL": "BVGSO", "OXGS-P-FILL": "BVGSP", "ENABLE OXFL-A-FILL": "ENABLE_BVOTP", "OXFL-A-FILL": "BVOTP", "OXFL-A-VENT": "SVOTV", "OXFL-A-DUMP": "SVOTD", "OXGS-A-FILL": "BVGS", "OXGS-MOV": "SVMOV", "OXGS-A-DUMP": "SVGSD"}, inplace=True)
# Determine when the actuator "SVMOV" assumes the value 1
sv_mov = actuators_df[actuators_df["SVMOV"] == 1]
print(sv_mov)
# Normalize all times to be referenced to the time of sv_mov
time_offset = sv_mov["Time"].values[0]
sensors_df["Time"] -= time_offset
actuators_df["Time"] -= time_offset
sensors_dfs.append(sensors_df)
def flow_study():
global sensors_dfs
fig, ax1 = plt.subplots(5, 1)
ax2 = []
for ax in ax1:
ax2.append(ax.twinx())
for i in range(5):
sensors_df = sensors_dfs[i]
lns1 = ax1[i].plot(sensors_df["Time"], sensors_df["POTB"], color="blue")
if (test_ids[i] == "CF-O1"):
lns2 = ax1[i].plot(sensors_df["Time"], sensors_df["POTT"], color="navy")
else:
lns2 = ax1[i].plot(sensors_df["Time"], sensors_df["PCC"], color="purple")
ax1[i].set_ylabel("Pressure (psi)")
ax1[i].set_ylim(0, 1000)
lns3 = ax2[i].plot(sensors_df["Time"], sensors_df["MOT"], color="red")
ax2[i].set_ylabel("Tank Mass (kg)")
ax2[i].set_ylim(0, 6.6)
if (test_ids[i] == "CF-O1"):
ax1[i].legend(lns1+lns2+lns3, ["POTB", "POTT", "MOT"], loc="upper right")
else:
ax1[i].legend(lns1+lns2+lns3, ["POTB", "PCC", "MOT"], loc="upper right")
ax1[i].set_xlim(0, 14)
ax1[i].set_xlabel("Time (s)")
ax1[i].set_title(test_ids[i] + " Flow Study")
# Minor gridlines
ax1[i].minorticks_on()
ax1[i].grid(which="both", linestyle="--", linewidth=0.5)
plt.gcf().set_size_inches(12, 25)
plt.tight_layout()
plt.savefig("flow_study.png", dpi=500)
#plt.show()
if __name__ == "__main__":
main()