#!/usr/bin/env ruby $: << '~/src/eclipse/autopilot/common/ruby/' require 'gnuplot_support' if ARGV.size < 1 then puts "Usage: #{__FILE__} p_log.csv ..." exit(-1) end t_s = [] cov_s = [] target_dirs = [] while file = ARGV.shift file =~ /(.+)\// target_dir = $1 || '.' target_dirs << target_dir p target_dir t = [] cov = [] lines = 0 open(file).each{|line| lines += 1 if lines % 10 != 0 then next end values = line.chop!.split(/\t/).collect!{|item| item.to_f} if t.empty? then (values.size - 1).times{|i| cov << []} end t << values.shift cov.each{|v| v << values.shift} } t_s << t cov_s << cov end # 時間スケールの導出 t_mins = [] t_maxs = [] t_s.each{|t| t_mins << t[0] t_maxs << t[-1] } t_mins.sort!{|a, b| a <=> b} t_maxs.sort!{|a, b| a <=> b} #p t_mins #p t_maxs t_min = (t_mins[0] / 100).to_i * 100 t_max = ((t_maxs[-1] / 100).to_i + 1) * 100 puts "GPSTime from #{t_min} to #{t_max}." rows_s = [] rows_max = 0 cov_s.each{|cov| rows_s << Math::sqrt(cov.size).to_i rows_max = rows_s[-1] if rows_s[-1] > rows_max } #exit #epsファイルの生成 eps_files = [] rows_max.times{|i| (i...rows_max).each{|j| #if i != j then next end #next unless (7..9).include?(i) fname = "cov_P_#{i}_#{j}.eps" Plotter::plot_basic(fname){|plot| #plot.set('size', "0.6, 0.4") plot.set "logscale y" plot.xlabel "'GPS Time [{/Symbol \264}10^{8} msec]'" #plot.xlabel "'GPS Time [{/Symbol \264}10^{5} sec]'" ## #plot.ylabel "'Variance'" plot.set('format', 'x "%3.2t"') #plot.set('format', 'y "10^{%L}"') plot.xrange <<-__STRING__ [#{t_min}:#{t_max}] __STRING__ items = [] cov_s.each_with_index{|cov, cov_index| unless cov[i * rows_s[cov_index] + j] then next end items << Gnuplot::DataSet::new([t_s[cov_index], cov[i * rows_s[cov_index] + j]]){|ds| ds.with = "lines lw 3" ds.title = "#{target_dirs[cov_index].gsub(/\//, '_')} {/Symbol s}^{2} (#{i}, #{j})" #ds.title = "Case (#{[?A + cov_index].pack('c')}) {/Symbol s}^{2} (#{i}, #{j})" } } plot.data = items } eps_files << fname } } #exit #TeXファイルの生成 tex_doc =<<-'__TEX_STRING__' \documentclass[disablejfam]{jsarticle} % pakages \usepackage{times, mathptmx} \usepackage{graphicx} \usepackage{makeidx} \usepackage{bm} \usepackage{amsmath, amssymb} \usepackage{tabularx} \usepackage{slashbox} \usepackage{enumerate} % \usepackage{hyperref} \usepackage{ascmac} \usepackage[dvipdfm,bookmarks=true,bookmarksnumbered=true,bookmarkstype=toc,colorlinks=true,linkcolor=blue]{hyperref} \usepackage[left=20mm,right=20mm,top=20mm,bottom=20mm]{geometry} \begin{document} \title{共分散行列 解析結果} \maketitle \begin{center} \begin{screen} \begin{itemize} \item 共分散行列Pの解析結果 \end{itemize} \end{screen} \end{center} \parindent 0truemm \clearpage __TEX_STRING__ eps_files.sort{|a, b| a[0] <=> b[0]}.each{|fname| tex_doc +=<<-__TEX_STRING__ \\includegraphics[width=80mm]{#{fname}} __TEX_STRING__ } tex_doc +=<<-'__TEX_STRING__' \end{document} __TEX_STRING__ ftex_name = 'cov_P.tex' ftex_p = open(ftex_name, 'w') ftex_p.print tex_doc ftex_p.close print `platex #{ftex_name}` print `platex #{ftex_name}` print `dvipdfmx #{ftex_name.gsub(/\.tex/, '.dvi')}` #print `rm *.eps`