-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkippyParser.py
More file actions
199 lines (179 loc) · 5.25 KB
/
SkippyParser.py
File metadata and controls
199 lines (179 loc) · 5.25 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
"""
Frances O'Leary, 8/8/2020 - SkippyParser.py
This program is meant to be used with the following command:
'python SkippyParser.py path\FLIGHTXX.csv' in conjunction
with the Project Skippy model rocket flight computer that
generates these .csv files. After executing this command,
this program should open up a series of graphs depicting the data
from the FLIGHTXX.csv file in a browser.
"""
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import pandas as pd
import re
import sys
# get file via user input and read the data
filename = sys.argv[-1]
df = pd.read_csv(filename)
# define layout for subplots
fig = make_subplots(
rows=8, cols=1,
shared_xaxes=True,
vertical_spacing=0.03,
specs=[[{"type": "scatter"}],
[{"type": "scatter"}],
[{"type": "scatter"}],
[{"type": "scatter"}],
[{"type": "scatter"}],
[{"type": "scatter"}],
[{"type": "scatter"}],
[{"type": "table"}]],
subplot_titles=("Pressure (Pa) vs Time (sec)",
"Altitude (m) vs Time (sec)",
"Temperature (C) vs Time (sec)",
"Acceleration (m/s^2) vs Time (sec)",
"X Acceleration (m/s^2) vs Time (sec)",
"Y Acceleration (m/s^2) vs Time (sec)",
"Z Acceleration (m/s^2) vs Time (sec)",
"Raw Data Table")
)
# Update xaxis labels
fig.update_xaxes(title_text="Time (seconds)", row=1, col=1)
fig.update_xaxes(title_text="Time (seconds)", row=2, col=1)
fig.update_xaxes(title_text="Time (seconds)", row=3, col=1)
fig.update_xaxes(title_text="Time (seconds)", row=4, col=1)
fig.update_xaxes(title_text="Time (seconds)", row=5, col=1)
fig.update_xaxes(title_text="Time (seconds)", row=6, col=1)
fig.update_xaxes(title_text="Time (seconds)", row=7, col=1)
# Update yaxis labels
fig.update_yaxes(title_text="Pressure (Pa)", row=1, col=1)
fig.update_yaxes(title_text="Altitude (m)", row=2, col=1)
fig.update_yaxes(title_text="Temperature (C)", row=3, col=1)
fig.update_yaxes(title_text="Acceleration (m/s^2)", row=4, col=1)
fig.update_yaxes(title_text="Acceleration (m/s^2)", row=5, col=1)
fig.update_yaxes(title_text="Acceleration (m/s^2)", row=6, col=1)
fig.update_yaxes(title_text="Acceleration (m/s^2)", row=7, col=1)
# add pressure graph
fig.add_trace(
go.Scatter(
x=df["time(sec)"],
y=df["pressure(pa)"],
mode="lines",
name="pressure",
line=dict(color="#007EA7")
),
row=1, col=1
)
# add altitude graph
fig.add_trace(
go.Scatter(
x=df["time(sec)"],
y=df["altitude(m)"],
mode="lines",
name="altitude",
line=dict(color="#4AAD52")
),
row=2, col=1
)
# add temperature graph
fig.add_trace(
go.Scatter(
x=df["time(sec)"],
y=df["temperature(C)"],
mode="lines",
name="temperature",
line=dict(color="#F8C630")
),
row=3, col=1
)
# add xacceleration standalone graph
fig.add_trace(
go.Scatter(
x=df["time(sec)"],
y=df["xAcceleration(m/s^2)"],
mode="lines",
name="xAcceleration",
line=dict(color="#724E91")
),
row=5, col=1
)
# add yacceleration standalone graph
fig.add_trace(
go.Scatter(
x=df["time(sec)"],
y=df["yAcceleration(m/s^2)"],
mode="lines",
name="yAcceleration",
line=dict(color="#66B3FF")
),
row=6, col=1
)
# add zacceleration standalone graph
fig.add_trace(
go.Scatter(
x=df["time(sec)"],
y=df["zAcceleration(m/s^2)"],
mode="lines",
name="zAcceleration",
line=dict(color="#EDE7E3")
),
row=7, col=1
)
# add xacceleration to combined acceleration graph
fig.add_trace(
go.Scatter(
x=df["time(sec)"],
y=df["xAcceleration(m/s^2)"],
mode="lines",
name="xAcceleration",
line=dict(color="#724E91")
),
row=4, col=1
)
# add yacceleration to combined acceleration graph
fig.add_trace(
go.Scatter(
x=df["time(sec)"],
y=df["yAcceleration(m/s^2)"],
mode="lines",
name="yAcceleration",
line=dict(color="#66B3FF")
),
row=4, col=1
)
# add zacceleration to combined acceleration graph
fig.add_trace(
go.Scatter(
x=df["time(sec)"],
y=df["zAcceleration(m/s^2)"],
mode="lines",
name="zAcceleration",
line=dict(color="#EDE7E3")
),
row=4, col=1
)
# add table of raw data
fig.add_trace(
go.Table(
header=dict(
values=["time(sec)", "pressure(pa)", "altitude(m)", "temperature(C)",
"xAcceleration(m/s^2)", "yAcceleration(m/s^2)", "zAcceleration(m/s^2)"],
font=dict(size=11),
align="left"
),
cells=dict(
values=[df[k].tolist() for k in df.columns[0:]],
align = "left")
),
row=8, col=1
)
# update and set additional styles
fig.update_layout(
height=4000,
showlegend=False,
title_text="<b>Project Skippy Flight Data Readout</b>",
font_family="Courier New",
template="plotly_dark"
)
#render in the browser
fig.write_html('skippy_data.html', auto_open=True)