#!/usr/bin/ruby $: << '~/src/eclipse/autopilot/common/ruby' require 'gnuplot_support' if ARGV.size < 1 then puts "Usage: #{__FILE__} history.csv" exit end data = [] open(ARGV.shift).each{|line| data << line.chop!.split(',').collect!{|item| item.to_f} } data = data.transpose [ # [name, y_label, index] ['V', 'V_{wind} [m/s]', [1, 2]], ['alpha', '{/Symbol a} [deg]', [3, 4]], ['theta', '{/Symbol q} [deg]', [5, 6]], ['q', 'q [deg/s]', [7, 8]] ].each{|item| Plotter::plot_basic("#{item[0]}.eps"){|plot| plot.noxlabel plot.ylabel "'#{item[1]}'" plot.set('size', "1, 0.3") plot.set('lmargin', '10') plot.set('bmargin', '2') plot.set('rmargin', '2') plot.set('tmargin', '1') plot.data = [ Gnuplot::DataSet::new([ data[0].collect{|v| sprintf("%3.2f", v)}, data[item[2][0]].collect{|v| sprintf("%3.3f", v)}]){|ds| ds.with = "lines lw 3 lt 1" ds.title = 'Observed' }, Gnuplot::DataSet::new([ data[0].collect{|v| sprintf("%3.2f", v)}, data[item[2][1]].collect{|v| sprintf("%3.3f", v)}]){|ds| ds.with = "lines lw 3 lt 1 lc 3" ds.title = 'Estimated via FEM' } ] } } Plotter::plot_basic("de.eps"){|plot| plot.xlabel "'Time [s]'" plot.ylabel "'{/Symbol d}_{e} [deg]'" plot.set('size', "1, 0.3") plot.set('lmargin', '10') plot.set('bmargin', '3') plot.set('rmargin', '2') plot.set('tmargin', '1') plot.data = [ Gnuplot::DataSet::new([ data[0].collect{|v| sprintf("%3.2f", v)}, data.last.collect{|v| sprintf("%3.3f", v)}]){|ds| ds.with = "lines lw 3 lt 1" ds.notitle } ] }