#! /bin/bash

f1="frequencies.dat"

cat > plotta << EOF

set term x11
set zero 1.E-30
set style data lines
set style line 1 lt 1 lw 4 lc rgb "blue" pt 1 ps 1
set style line 2 lt 1 lw 4 lc rgb "green" pt 1 ps 1
set style line 3 lt 1 lw 4 lc rgb "yellow" pt 1 ps 1
set style line 4 lt 1 lw 4 lc rgb "orange" pt 1 ps 1
set style line 5 lt 1 lw 4 lc rgb "red" pt 1 ps 1
set style line 6 lt 1 lw 4 lc rgb "brown" pt 1 ps 1
set style line 8 lt 8 lw 4 pt 1 ps 1
set style line 10 lt 0 lw 3 lc rgb "black" pt 1 ps 1
set style line 11 lt -1 lw 3 lc rgb "gray" pt 1 ps 1

set term png enhanced font "arial, 16" size 800,800 linewidth 1
set output "rose.png"
set polar

unset border
unset tics 
set rrange [ ]
unset raxis
set rtics format " " (0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3)
unset parametric

set angles degrees
#set grid polar 22.50 front lw 2
set grid polar 22.50 lw 2 lc rgb "black"
set key box opaque 
set xtics axis nomirror
set ytics axis nomirror
set xrange [-0.28:0.28]
set yrange [-0.28:0.28]
#set title "Wind Rose"
set label "N" at screen 0.5,0.98
set label "W" at screen 0.01,0.5
set label "E" at screen 0.95,0.5
set label "S" at screen 0.5,0.02
set zeroaxis

plot \\
 "$f1" using (90-\$1):((\$3+\$4+\$5+\$6+\$7+\$8)*\$2) t"u: >5 (m/s)" with filledcurve ls 6, \\
 "$f1" using (90-\$1):((\$3+\$4+\$5+\$6+\$7)*\$2) t"u: 4-5 (m/s)"  with filledcurve ls 5, \\
 "$f1" using (90-\$1):((\$3+\$4+\$5+\$6)*\$2) t"u: 3-4 (m/s)"  with filledcurve ls 4, \\
 "$f1" using (90-\$1):((\$3+\$4+\$5)*\$2) t"u: 2-3 (m/s)"  with filledcurve ls 3, \\
 "$f1" using (90-\$1):((\$3+\$4)*\$2) t"u: 1-2 (m/s)"  with filledcurve ls 2, \\
 "$f1" using (90-\$1):((\$3)*\$2) t"u: 0-1 (m/s)"  with filledcurve ls 1
EOF

gnuplot plotta
rm plotta 
display rose.png &
exit













