5 # Script to plot .dat files
11 dir="/home/sam/Documents/University/honours/research/TCS"
13 title=$(grep "# Title: " $1 | sed 's/# Title: //g')
14 comment=$(grep "# Comment:" $1 | sed 's/# Comment: *//1' | head --bytes=100)
15 labels=$(grep -A 1 "# Data:" $1 | tail --lines=1 | sed 's/#//1')
19 if [ "$2" != "" ]; then
20 stream="< tail --lines=$2 $1"
23 if [ "$title" == "" ]; then
26 title="$title\n$comment"
28 filename=$(echo $1 | sed -e "s:$dir::g")
29 title="$filename\n$title"
31 xlabel=$(echo $labels | tr " " "\n" | head --lines=$x | tail --lines=1)
32 command="set title \"$title\""
33 command="$command; set xlabel \"$xlabel\""
34 command="$command; set ylabel \"$ylabel\""
35 command="$command; set key outside right"
38 lab=$(echo $labels | tr " " "\n" | head --lines=$y | tail --lines=1)
39 if [ "$lab" == "" ]; then
42 plot="$plot \"$stream\" u $x:$y w $style t \"$lab\","
45 plot=$(echo $plot | sed -e "s/,//$(echo $toplot | wc -w)")
46 command="$command; $plot; pause 0.5; reread"
48 echo "$command" | tr ";" "\n" > plot.template
50 gnuplot plot.template 2>&1 >> /dev/null
61 output_style="set term png size \"640, 480\"; set output sprintf(\"%d.png\", i)"
66 sed -e "s:\$file:$1:g" plot.template > plot
67 gnuplot --persist -e "set term x11; t = 0; dt = $dt; load \"plot\"" 2>&1 >> /dev/null
70 #frame_rate=$(python -c "print str(min(int(float($steps) / float($tMax)), 40))")
72 ffmpeg -r $frame_rate -b 1024k -i %d.png animate.mp4