3dcfec65f9d6de53ab04f2aa7f13b04c057118ed
[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 #Approximate size of graph
9 size="$(tail -n 1 "$1" | cut -d . -f 1)"
10 test $size -gt 3600 && size="$(( $size/10 ))" #For prolonged periods
11 size="$(( 600 + $size ))"
12
13 #Plot it
14 gnuplot << EOF
15 set output "$1.png"
16 set terminal png size $size,300
17
18 set title "Sleep motions"
19 set xlabel "time"
20 set ylabel "motion"
21
22 set yrange [-0.5:3]
23
24 set xdata time
25 set timefmt "%s"
26 #set format x "%H:%M:%S"
27
28 set grid
29
30 #set pointsize 0.5
31 plot "$1" using 2:5 title "Sensor state" with steps,\
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\
35
36 EOF
37
38
39
40
This page took 0.299105 seconds and 3 git commands to generate.