-
Notifications
You must be signed in to change notification settings - Fork 20
/
plot.gnuplot
executable file
·134 lines (92 loc) · 2.03 KB
/
plot.gnuplot
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
#!/usr/bin/env -S gnuplot -c
if (ARGC >= 1) {
f = ARG1
} else {
f = "live.txt"
}
LIVE = 0
if (ARGC >= 2) {
if (ARG2 eq "--live") {
LIVE = 1
} else {
print "Unknown second argument. Only supported --live"
exit(1)
}
}
# Interactive
if (LIVE != 0) {
# set terminal wxt size 1850,1750
set terminal wxt size 1900,1000 enhanced
e="every 10"
} else {
e=""
}
f = "<grep -v ^timestamp " . f
while (1) {
if (LIVE == 0) {
# To file
set terminal pngcairo size 1600,1200 noenhanced
set output "plot.png"
}
set lmargin 15
set rmargin 15
set timefmt "%s"
set format x "%H:%M:%S" # %Y-%m-%d
set xdata time
set xlabel "Time"
set ylabel "Voltage [V]"
set y2tics
set y2label "Current [A]"
set grid
set multiplot layout 5,1
set yrange [*<2.0:5.2<*]
set format y2 "%.3s %cA"
plot f u 1:3 @e w steps lw 2 title "Voltage", \
"" u 1:4 @e w steps lw 2 axis x1y2 title "Current"
unset y2label
unset y2tics
unset format y2
set ylabel "Energy [Wh]"
# W⋅s == J
set yrange [0:*]
set format y "%.3s %cWh"
plot f u 1:($8/3600) @e w steps lw 2 title "Energy"
# 1:9 - capacity in A⋅s == C
set ylabel "Power [W]"
set y2tics
set y2label "ESR [Ohm]"
set yrange [0.0:]
set y2range [0.0:*<100]
set format y "%.3s %cW"
plot f u 1:($3*$4) @e w steps lw 2 title "Power", \
f u 1:($4 > 0.01 ? $3/$4 : 10000) @e w steps lw 2 axis x1y2 title "ESR"
unset format y
unset y2label
unset y2tics
set ylabel "Voltage [V]"
set yrange [0.0:0.2<*]
plot f u 1:5 @e w steps lw 2 title "D+", "" u 1:6 w steps lw 3 title "D-"
set ylabel "Temperature [degC]"
set yrange [*:*]
plot f u 1:7 every 10 w steps lw 2 title "Temperature"
unset multiplot
unset output
if (LIVE == 0) {
break
} else {
pause 10 # for interactive redraw
}
}
set terminal pngcairo size 1600,1600 noenhanced
set output "plot-iv.png"
unset y2label
unset y2tics
set xdata # revert set xdata time
set format x "%.3f"
set xlabel "Current [A]"
set format y "%.3f"
set ylabel "Voltage [V]"
set xrange [0:]
set yrange [0:]
plot f u 4:3 w steps lw 2 title "V(I)"
unset output