X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=research%2FTCS%2Fpoll.sh;h=ba75969f3b7a608834be8d9fdfe20627698dfbf8;hb=ac8b78085711ee7a9cc8e3b3569cf7f30ee999bd;hp=6f3b6505ed69bf8f1cef40d421457a9a5d03f17b;hpb=97dc3cc933e551c3e5ce097b1b35d6f3504a2917;p=matches%2Fhonours.git diff --git a/research/TCS/poll.sh b/research/TCS/poll.sh index 6f3b6505..ba75969f 100755 --- a/research/TCS/poll.sh +++ b/research/TCS/poll.sh @@ -1,5 +1,57 @@ #!/bin/bash +#!/bin/bash + +# Script to plot .dat files + +x=1 +toplot="2" +ylabel="Counts" +style="lp lw 2" +dir="/home/sam/Documents/University/honours/research/TCS" + +title=$(grep "# Title: " $1 | sed 's/# Title: //g') +comment=$(grep "# Comment:" $1 | sed 's/# Comment: *//1' | head --bytes=100) +labels=$(grep -A 1 "# Data:" $1 | tail --lines=1 | sed 's/#//1') + + +stream=$1 +if [ "$2" != "" ]; then + stream="< tail --lines=$2 $1" +fi + +if [ "$title" == "" ]; then + title=$comment +else + title="$title\n$comment" +fi +filename=$(echo $1 | sed -e "s:$dir::g") +title="$filename\n$title" + +xlabel=$(echo $labels | tr " " "\n" | head --lines=$x | tail --lines=1) +command="set title \"$title\"" +command="$command; set xlabel \"$xlabel\"" +command="$command; set ylabel \"$ylabel\"" +command="$command; set key outside right" +plot="plot " +for y in $toplot; do + lab=$(echo $labels | tr " " "\n" | head --lines=$y | tail --lines=1) + if [ "$lab" == "" ]; then + lab=$y + fi + plot="$plot \"$stream\" u $x:$y w $style t \"$lab\"," +done + +plot=$(echo $plot | sed -e "s/,//$(echo $toplot | wc -w)") +command="$command; $plot; pause 0.5; reread" + +echo "$command" | tr ";" "\n" > plot.template + +gnuplot plot.template 2>&1 >> /dev/null + +rm -f plot.template + +exit 0 movie=false