X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=c%2Fgoertzel%2Fsleepplot.sh;h=ea0bac2ac296b138c7aedc24b22e46826723b3d4;hb=3afb9fca6a37d4deea62d7b894fb953e8b538614;hp=6622035f740f5e4eefa7ddf94cae5c6e1ef0b9c1;hpb=42643d9f77b84cdd0b1395da5de16595c16cc331;p=mirrors%2FPrograms.git diff --git a/c/goertzel/sleepplot.sh b/c/goertzel/sleepplot.sh index 6622035..ea0bac2 100755 --- a/c/goertzel/sleepplot.sh +++ b/c/goertzel/sleepplot.sh @@ -9,17 +9,21 @@ in="$1"; graphout="${in%%.*}.png" test -n "$2" && graphout="$2"; +#Last state +last="$(tail -n 1 "$in" | cut -d ' ' -f 5)" +test "$last" -gt 0 && last="motion" || last="peace"; + #Approximate size of graph -size="$(tail -n 1 "$in" | cut -d . -f 1)" +size="$(tail -n 1 "$in" | cut -d . -f 1 | sed -e 's/^0*//' | tee /tmp/lol)" test $size -gt 3600 && size="$(( $size/10 ))" #For prolonged periods size="$(( 600 + $size ))" #Plot it gnuplot << EOF set output "$graphout" -set terminal png size $size,300 +set terminal png size $size,400 -set title "Sleep motions" +set title "Sleep motions (current state: $last)" set xlabel "time" set ylabel "motion" @@ -36,7 +40,9 @@ plot\ "$in" using 2:5 title "Sensor state" with steps,\ "" using 2:(\$6*2) title "Avg. 10s" with lines,\ "" using 2:(\$7*3) title "Avg. 30s" with lines,\ -"" using 2:(\$8*4) title "Avg. 120s" smooth bezier\ +"" using 2:(\$8*3) title "Avg. 60s" with lines,\ +"" using 2:(\$9*3) title "Avg. 90s" with lines,\ +"" using 2:(\$10*4) title "Avg. 120s" smooth bezier\ EOF