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