Sleepcount for 300 seconds added. This is when things got riddiculously complicated...
[mirrors/Programs.git] / c / goertzel / sleepplot.sh
1 #!/bin/bash
2
3 test -z "$1" && {
4 echo "Usage: $0 sleeplog.txt"
5 exit 23
6 }
7
8 #Count events:
9 seconds='60 300'
10 for i in $seconds; do
11 ./sleepcount.sh "$1" "$i" &
12 done
13
14 #Approximate size of graph
15 size="$(tail -n 1 "$1" | cut -d . -f 1)"
16 test $size -gt 3600 && size="$(( $size/10 ))" #For prolonged periods
17 size="$(( 600 + $size ))"
18
19 #Plot it
20 gnuplot << EOF
21 set output "$1.png"
22 set terminal png size $size,300
23
24 set title "Sleep motions"
25 set xlabel "time"
26 set ylabel "motion"
27
28 set yrange [-0.5:3]
29
30 set xdata time
31 set timefmt "%s"
32 #set format x "%H:%M:%S"
33
34 set grid
35
36 #set pointsize 0.5
37 #"$1.counts.$seconds" using 1:(\$2/5) title "Activations in last $seconds seconds" smooth csplines
38 plot "$1" using 2:5 title "Sensor state" with steps,\
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\
41
42 EOF
43
44
45
46
This page took 0.274038 seconds and 4 git commands to generate.