Commit | Line | Data |
---|---|---|
7cd5c7da TM |
1 | #!/bin/bash |
2 | ||
3 | test -z "$1" && { | |
4 | echo "Usage: $0 sleeplog.txt" | |
5 | exit 23 | |
6 | } | |
7 | ||
6c573755 | 8 | #Approximate size of graph |
7cd5c7da TM |
9 | size="$(tail -n 1 "$1" | cut -d . -f 1)" |
10 | test $size -gt 3600 && size="$(( $size/10 ))" #For prolonged periods | |
78c13195 | 11 | size="$(( 600 + $size ))" |
7cd5c7da | 12 | |
6c573755 | 13 | #Plot it |
7cd5c7da TM |
14 | gnuplot << EOF |
15 | set output "$1.png" | |
6c573755 | 16 | set terminal png size $size,300 |
7cd5c7da TM |
17 | |
18 | set title "Sleep motions" | |
19 | set xlabel "time" | |
20 | set ylabel "motion" | |
21 | ||
6c573755 | 22 | set yrange [-0.5:3] |
7cd5c7da TM |
23 | |
24 | set xdata time | |
25 | set timefmt "%s" | |
26 | #set format x "%H:%M:%S" | |
27 | ||
7cd5c7da TM |
28 | set grid |
29 | ||
30 | #set pointsize 0.5 | |
3e5828b5 | 31 | plot "$1" using 2:5 title "Sensor state" with steps,\ |
720d982e TM |
32 | "" using 2:(\$6*3) title "Avg last last 10 seconds" with lines,\ |
33 | "" using 2:(\$7*3) title "Avg last last 30 seconds" with lines,\ | |
34 | "" using 2:(\$8*3) title "Avg last last 120 seconds" with lines\ | |
7cd5c7da TM |
35 | |
36 | EOF | |
37 | ||
38 | ||
39 | ||
40 |