Automatic commit. Thu Aug 2 11:00:02 WST 2012
[matches/honours.git] / research / TCS / poll.sh
index 6f3b650..08a6277 100755 (executable)
@@ -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
 

UCC git Repository :: git.ucc.asn.au