#!/bin/bash

if ! which gnuplot > /dev/null 2>&1
then
    echo 'gnuplot not found - skipping graph creation' >&2
    exit 1
fi

gnuplot<<EOF

    R = 0.0256

    set terminal pngcairo color enhanced size 800,600
    set grid
    set key top left

    #---graph---
    PATH = '../postProcessing/graph/'

    LIST = system("ls -1 ".PATH." | sort -g")
    NUM = words(LIST)
    TIMES(n) = word(LIST,n)

    FILE = PATH.TIMES(NUM)."/line.csv"
    RFILE = 'graph/2/line.csv'

    set xlabel 'r/R [-]'

    set output 'graph_alphaAir.png'

    set yrange [0:]
    set ylabel '{/Symbol a}_{air} [-]'

    plot  FILE u (\$1/R):2 w l t 'current', \
         RFILE u (\$1/R):2 w l t 'reference'

    set autoscale y


    set output 'graph_UAir.png'

    set ylabel 'U_{air} [m s^{-1}]'

    plot  FILE u (\$1/R):3 w l t 'current', \
         RFILE u (\$1/R):3 w l t 'reference'

EOF

#------------------------------------------------------------------------------
