""" Laser_plots.py data_dir fig_dir Read the following data files: LaserLP5 Simulated laser data for figure LaserLP5 LaserLogLike Dependence of LL on s and b for figure LaserLogLike LaserStates Sequence of 250 states from EKF for figure LaserStates LaserForecast Sequence of 400 scalar values for figure LaserForecast LaserHist Histogram 600 values for figure LaserHist in Chap 3 and make the following figures: In Chapter 1: LaserLP5.pdf Figure 1.1 LaserLogLike.pdf Figure 1.2 LaserStates.pdf Figure 1.3 LaserForecast.pdf Figure 1.4 In Chapter 3: LaserHist.pdf Figure 3.1 """ import matplotlib, sys, os, os.path, numpy matplotlib.use('PDF') import pylab params = {'axes.labelsize': 12, 'text.fontsize': 10, 'legend.fontsize': 10, 'text.usetex': True, 'xtick.labelsize': 11, 'ytick.labelsize': 11} pylab.rcParams.update(params) data_dir, fig_dir = sys.argv[1:3] GP = os.popen("gnuplot","w") GP.write(""" set terminal postscript eps color set output "%s" set hidden set contour set xtics .02 set ytics 0.001 set xlabel 's' set ylabel 'b' set ztics 5 splot "data/LaserLogLike" with lines t "LogLikelihood" """%(fig_dir+'/LaserLogLike.eps')) def read_data(name): # Read in "data_file" as an array f = file(data_dir+'/'+name, 'r') data = [[float(x) for x in line.split()] for line in f.xreadlines()] f.close() return numpy.array(data).T LP5 = read_data('LaserLP5') States = read_data('LaserStates') Forecast = read_data('LaserForecast') Hist = read_data('LaserHist') pylab.plot(LP5[0],LP5[1],'r-') pylab.plot(LP5[0],LP5[2],'b-') pylab.ylabel(r'$y(t)$') pylab.xlabel(r'$t$') pylab.axis(xmin=0,xmax=250) pylab.legend(('Laser','Simulation')) pylab.savefig(fig_dir+'/LaserLP5.pdf') pylab.clf() # Clear figure window pylab.plot(States[0],States[1],'r-') pylab.xlabel(r'$x_1$') pylab.ylabel(r'$x_3$') pylab.savefig(fig_dir+'/LaserStates.pdf') pylab.clf() # Clear figure window pylab.plot(Forecast[0],Forecast[1],'r-') pylab.plot(Forecast[0],Forecast[2],'b-') pylab.ylabel(r'$y(t)$') pylab.xlabel(r'$t$') pylab.savefig(fig_dir+'/LaserForecast.pdf') pylab.clf() # Clear figure window pylab.bar(Hist[0],Hist[1]) pylab.ylabel(r'Counts') pylab.xlabel(r'$x$') pylab.savefig(fig_dir+'/LaserHist.pdf') pylab.clf() # Clear figure window