X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=research%2FTCS%2Fpoll.sh;h=08a6277ef0b747aad4581a944d32d88d97a9ad13;hb=71e2a0e6df66523363f5ff95a3e6ff172b0f4cec;hp=243e3706a86ce61fda8b81a2b35ad4f23e9dbf8c;hpb=3e0bbeaa77f2305ae77c99654c3e46474fe0a0e2;p=matches%2Fhonours.git diff --git a/research/TCS/poll.sh b/research/TCS/poll.sh index 243e3706..08a6277e 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="3" +ylabel="Counts" +style="l" +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 @@ -11,8 +63,6 @@ else output_style="" fi - - sed -e "s:\$file:$1:g" plot.template > plot gnuplot --persist -e "set term x11; t = 0; dt = $dt; load \"plot\"" 2>&1 >> /dev/null