-
Notifications
You must be signed in to change notification settings - Fork 0
/
merged_plot.py
100 lines (80 loc) · 2.49 KB
/
merged_plot.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
96
97
98
99
100
import plotly.offline as py
from plotly import tools
import plotly.graph_objs as go
import plotly.figure_factory as FF
import numpy as np
import pandas as pd
# df_car = pd.read_csv('test.csv')
# df_ecu = pd.read_csv('5-27-airport_024.csv')
def filterValue(frame, data, offset):
return list(zip(*[(x + offset,y) for x, y in zip(frame['Time (sec)'], frame[data])
if not np.isnan(y)
]))
def filterTransformValue(frame, data, beg, end, offset):
return list(zip(*[(x+offset,y) for x, y in zip(frame['Time (sec)'], frame[data])
if x + offset> beg and x + offset < end
and x+offset > 0]))
def plot(csvfile_name, fout):
df_merged = pd.read_csv(csvfile_name)
rpm_car = filterValue(df_merged, 'rpm', 0)
speed_car = filterValue(df_merged, 'speed', 0)
# rpm_ecu = filterTransformValue(df_ecu, 'RPM', 0, 100, 0)
# tps_ecu = filterTransformValue(df_ecu, 'TPS (%)', 0, 100, 0)
rpm_ecu = filterValue(df_merged, 'RPM', 0)
tps_ecu = filterValue(df_merged, 'TPS (%)', 0)
fig = tools.make_subplots(rows=3, cols=1, shared_xaxes=True)
fig.append_trace(
go.Scatter(
x=rpm_car[0],
y=rpm_car[1],
name='rpm-car'
), 1, 1
)
fig.append_trace(
go.Scatter(
x=rpm_ecu[0],
y=rpm_ecu[1],
name='rpm-ecu'
), 1, 1
)
fig.append_trace(
go.Scatter(
x=speed_car[0],
y=speed_car[1],
name='speed'
), 1, 1
)
fig.append_trace(
go.Scatter(
x=tps_ecu[0],
y=tps_ecu[1],
name='tps-ecu'
), 2, 1
)
fig.append_trace(
go.Scatter(
x=speed_car[0],
y=speed_car[1],
name='speed'
), 3, 1
)
print(fig['layout'])
fig['layout']['yaxis1'].update(title='RPM')
fig['layout']['yaxis2'].update(title='TPS')
fig['layout']['yaxis3'].update(title='Speed')
fig['data'][2].update(yaxis='y4')
fig['layout']['yaxis4'] =dict(
autorange=True,
overlaying= 'y1',
side='right',
title='Speed (MPH)'
)
py.plot(fig, filename=fout)
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("fn", help="path to merged file")
parser.add_argument("fout", help="path for output file")
parser.add_argument("offset", help="offset for second file time series")
args = parser.parse_args()
combine(args.fn, args.fout)