-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.py
63 lines (57 loc) · 1.83 KB
/
parse.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
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
import numpy as np
import yaml
with open("settings.yml", 'r') as stream:
#Handle possible YAML errors
try:
data = (yaml.safe_load(stream))
except yaml.YAMLError as exc:
print(exc)
fig = go.Figure()
#Read the primary file.. change the name here, if you seek to use a different sample.
df=pd.read_csv(data["file-name"])
#Add a line to the graph for each object specified in the YAML file
# Row Excluded Code-- depreciated, but still supported through YAML tag
if (data["mode"]== "include"):
for items in data["rows-modified"].split(" "):
print(items[1:])
fig.add_trace(go.Scatter(x=df["elapsed time (s)"], y=df[items[1:]],
mode=data["graph-type"],
name=items[1:]))
if (data["mode"]== "exclude"): # If an item is in rows modified, next iteration. Else, plot it.
for item in df.columns.values:
if (item in data["rows-modified"] or item == "elapsed time (s)" or item== "Unnamed: 0"):
pass
else:
fig.add_trace(go.Scatter(x=df["elapsed time (s)"], y=df[item],
mode=data["graph-type"],
name=item))
fig.update_layout(
title=go.layout.Title(
text="Rocket Data",
x=0
),
xaxis=go.layout.XAxis(
title=go.layout.xaxis.Title(
text="Time",
font=dict(
family="Times New Roman",
size=18,
color="#7f7f7f"
)
)
),
yaxis=go.layout.YAxis(
title=go.layout.yaxis.Title(
text="Value",
font=dict(
family="Times New Roman",
size=18,
color="#7f7f7f"
)
)
)
)
fig.show()