#! /bin/bash
# Last edited on 2018-06-17 13:52:28 by jstolfi

gnuplot <<EOF
set term x11
set xrange [-13:119]
set yrange [0:55]
# set logscale x
# set logscale y

ta2 = 0.00
tb2 = 32.00
tmin2 = -60.00 # -5.215
cmin2 =  2.349
tref2 = 32.00
cref2 = 42.27
expo2 = 5.18
func2(t) = cmin2 + (cref2-cmin2)*(abs(t-tmin2)/abs(tref2-tmin2))**expo2

ta1 = 35.37
tb1 = 109.27
tmin1 = 96.20
cmin1 = 44.00
tref1 = 35.37
cref1 = 50.40
expo1 = 1.45
func1(t) = cmin1 + (cref1-cmin1)*(abs(t-tmin1)/abs(tref1-tmin1))**expo1

func(t) = ((t >= ta1) && (t <= tb1) ? func1(t) : ((t >= ta2) && (t <= tb2) ? func2(t) : 0/0))

plot \
  ".breaks.txt" using 1:(55) notitle with impulses lt 1 lw 2 lc rgb '#ffaa66', \
  (func(x)) notitle with lines lt 1 lw 1 lc rgb '#997700', \
  ".solub_Synth.txt"  using 1:4 title "Synth"  with linespoints lt 1 lw 2 pt 7 ps 1.0 lc rgb '#ff3300', \
  ".solub_WPprop.txt" using 1:4 title "WPprop" with linespoints lt 1 lw 1 pt 7 ps 1.0 lc rgb '#cc00ff'
pause 120
EOF

# , \
#  ".solub_GGraph.txt" using 1:4 title "GGraph" with linespoints lt 1 lw 1 pt 7 ps 1.0 lc rgb '#ff0000', \
#  ".solub_RUSsol.txt" using 1:4 title "RUSsol" with linespoints lt 1 lw 1 pt 7 ps 1.0 lc rgb '#008800', \
#  ".solub_Solvay.txt" using 1:4 title "Solvay" with linespoints lt 1 lw 2 pt 6 ps 1.5 lc rgb '#5577ff', \
#  ".solub_WPcurr.txt" using 1:4 title "WPcurr" with linespoints lt 1 lw 1 pt 7 ps 1.0 lc rgb '#cc00ff', \
#  (func2(x+tmin2)-cmin2) with lines, \
#  ".solub_Solvay.txt"  using (column(1)-tmin2):(column(4)-cmin2) title "Solvay"  with linespoints lt 1 lw 2 pt 7 ps 1.0 lc rgb '#5577ff'
