#!/bin/bash

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

gnuplot<<EOF
    set grid

    #---PNG---
    set term pngcairo size 800,600
    FType = '.png'

    #---graph---
    LIST =      system('ls -1 ../postProcessing/graph/ | sort -g')
    NUM =       words(LIST)
    TIMES(n) =  word(LIST,n)

    FILE(n)="../postProcessing/graph/".TIMES(n)."/line.csv"

    set xlabel 'x'
    set ylabel '{/Symbol a}_{air}'

    set yrange [0:0.45]

    set output 'alphaLatest'.FType
    plot FILE(NUM) u 1:(\$2+\$3) w l lw 2 t 'air'   , \
         FILE(NUM) u 1:2         w l lw 4 t 'air1'  , \
         FILE(NUM) u 1:3         w l lw 2 t 'air2'

EOF

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