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: |
6c573755 | 9 | seconds=60 |
3e5828b5 | 10 | ./sleepcount.sh "$1" "$seconds" |
6c573755 TM |
11 | |
12 | #Approximate size of graph | |
7cd5c7da TM |
13 | size="$(tail -n 1 "$1" | cut -d . -f 1)" |
14 | test $size -gt 3600 && size="$(( $size/10 ))" #For prolonged periods | |
78c13195 | 15 | size="$(( 600 + $size ))" |
7cd5c7da | 16 | |
6c573755 | 17 | #Plot it |
7cd5c7da TM |
18 | gnuplot << EOF |
19 | set output "$1.png" | |
6c573755 | 20 | set terminal png size $size,300 |
7cd5c7da TM |
21 | |
22 | set title "Sleep motions" | |
23 | set xlabel "time" | |
24 | set ylabel "motion" | |
25 | ||
6c573755 | 26 | set yrange [-0.5:3] |
7cd5c7da TM |
27 | |
28 | set xdata time | |
29 | set timefmt "%s" | |
30 | #set format x "%H:%M:%S" | |
31 | ||
7cd5c7da TM |
32 | set grid |
33 | ||
34 | #set pointsize 0.5 | |
3e5828b5 TM |
35 | plot "$1" using 2:5 title "Sensor state" with steps,\ |
36 | "$1.counts.$seconds" using 1:(\$2/5) title "Activations in last $seconds seconds" smooth csplines | |
7cd5c7da TM |
37 | |
38 | EOF | |
39 | ||
40 | ||
41 | ||
42 |