Bit tuning
[mirrors/Programs.git] / c / goertzel / sleepplot.sh
CommitLineData
7cd5c7da
TM
1#!/bin/bash
2
3test -z "$1" && {
4 echo "Usage: $0 sleeplog.txt"
5 exit 23
6}
7
5769d767
TM
8in="$1";
9graphout="${in%%.*}.png"
10test -n "$2" && graphout="$2";
11
6c573755 12#Approximate size of graph
5769d767 13size="$(tail -n 1 "$in" | cut -d . -f 1)"
7cd5c7da 14test $size -gt 3600 && size="$(( $size/10 ))" #For prolonged periods
78c13195 15size="$(( 600 + $size ))"
7cd5c7da 16
6c573755 17#Plot it
7cd5c7da 18gnuplot << EOF
5769d767 19set output "$graphout"
6c573755 20set terminal png size $size,300
7cd5c7da
TM
21
22set title "Sleep motions"
23set xlabel "time"
24set ylabel "motion"
25
6c573755 26set yrange [-0.5:3]
7cd5c7da
TM
27
28set xdata time
29set timefmt "%s"
30#set format x "%H:%M:%S"
31
7cd5c7da
TM
32set grid
33
34#set pointsize 0.5
5769d767
TM
35plot\
36"$in" using 2:5 title "Sensor state" with steps,\
37"" using 2:(\$6*3) title "Avg. 10s" with lines,\
38"" using 2:(\$7*3) title "Avg. 30s" with lines,\
39"" using 2:(\$8*3) title "Avg. 120s" smooth bezier\
7cd5c7da
TM
40
41EOF
42
43
44
45
This page took 0.15776 seconds and 4 git commands to generate.