X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=research%2FTCS%2Fplot.sh~;fp=research%2FTCS%2Fplot.sh~;h=bb95cef92027a4581a2d0fe4bbaeb469ef8be599;hb=93d5acb53e1348ba4e288874837fc6085b74f863;hp=0000000000000000000000000000000000000000;hpb=8f0b1708f52c6321d2703e15fbbfc38a7558485b;p=matches%2Fhonours.git diff --git a/research/TCS/plot.sh~ b/research/TCS/plot.sh~ new file mode 100755 index 00000000..bb95cef9 --- /dev/null +++ b/research/TCS/plot.sh~ @@ -0,0 +1,54 @@ +#!/bin/bash + +# Script to plot .dat files + +x=1 +toplot="2 3 5" +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') + +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) +if [ $2 != "" ]; then + if [ $2 == $1 ]; then + exit 1 + fi + command="set term png size 1024,800; set output \"$2\"" +else + command="" +fi + +command="$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 \"$1\" u $x:$y w $style t \"$lab\"," +done + +plot=$(echo $plot | sed -e "s/,//$(echo $toplot | wc -w)") +command="$command; $plot; exit" + +gnuplot="/usr/bin/gnuplot" +$gnuplot --persist -e "$command" + + + +