Today, in the midst of organizing my data and images to send to Dr. Dai, I accidentally erased over half of my research. I still have the raw data, and the Fortran code to produce it, but I lost my images, sampled data, sampling scripts and gnuplot scripts for making the images possible. That rm utility really removes the shit out of things. I think I can redo all the scripts in three hours.
%%%%%
Scripts in three hours? Perhaps not so much. I wrote a better Ruby script this time for organizing the Fortran data. Its still not beautiful, or even homely, but its better.
%%%%%
Ok, its been about six hours since I thought I could do this in three hours and I've (hopefully) finished writing my Ruby scripts for organizing the Fortran data... now to tackle the gnuplot scripts. Not so frequently asked questions is a great resource for gnuplotery. This is a good site for adding LaTeX magic to your gnuplots.
%%%%%
I just finished tweaking the gnuplot script. It is now 1:32 AM. Fantastic. Just in case something happens again, I'm going to paste my codes here. (I'm kind of embarassed. I know this code is ugly, I know that it can be prettified... but I can't spend time right now making it pretty/readable.)
Ruby:
#!/usr/bin/env ruby
#
# This script takes the .dat files output by the Fortran codes and organizes them into
# several figure .dat files to be turned into figures by the figures.plt gnuplot script.
#
# To run: ruby combine-data.rb
#
def process i1E, i2E, i3E, i1L, i2L, i3L
r = /(\d*\.\d+)(\s+)(\d+\.\d+)/
o1E = i1E.readlines; o1E.map!{|l| l.scan(r)}.flatten!(1); o1E.each{|l| l.delete_at(1)}
o2E = i2E.readlines; o2E.map!{|l| l.scan(r)}.flatten!(1); o2E.each{|l| l.delete_at(1)}
o3E = i3E.readlines; o3E.map!{|l| l.scan(r)}.flatten!(1); o3E.each{|l| l.delete_at(1)}
o1L = i1L.readlines; o1L.map!{|l| l.scan(r)}.flatten!(1); o1L.each{|l| l.delete_at(1)}
o2L = i2L.readlines; o2L.map!{|l| l.scan(r)}.flatten!(1); o2L.each{|l| l.delete_at(1)}
o3L = i3L.readlines; o3L.map!{|l| l.scan(r)}.flatten!(1); o3L.each{|l| l.delete_at(1)}
a = [o1E, o2E, o3E, o1L, o2L, o3L]
end
def print_data a, out1, out2, in1E, in2E, in3E, in1L, in2L, in3L
(0..380).each do |i|
if i%12 == 0 then
out1.print a[0][i][0]+" "+a[0][i][1]+" "+a[1][i][1]+" "+a[2][i][1]+"\n"
out2.print a[3][i][0]+" "+a[3][i][1]+" "+a[4][i][1]+" "+a[5][i][1]+"\n"
else
out1.print a[0][i][0]+" "+a[0][i][1]+"\n"
out2.print a[3][i][0]+" "+a[3][i][1]+"\n"
end
end
in1E.close; in2E.close; in3E.close
in1L.close; in2L.close; in3L.close
out1.close; out2.close
end
idata1E = File.open "ord1_m201_te_results.dat", "r"
idata2E = File.open "ord2_m51_te_results.dat", "r"
idata3E = File.open "ord4_m21_te_results.dat", "r"
idata1L = File.open "ord1_m201_tl_results.dat", "r"
idata2L = File.open "ord2_m51_tl_results.dat", "r"
idata3L = File.open "ord4_m21_tl_results.dat", "r"
out1 = File.open "fig-1.dat", "w"
out2 = File.open "fig-2.dat", "w"
a = process idata1E, idata2E, idata3E, idata1L, idata2L, idata3L
print_data a, out1, out2, idata1E, idata2E, idata3E, idata1L, idata2L, idata3L
idata1E = File.open "ord1_m201_te_dim_results.dat", "r"
idata2E = File.open "ord2_m51_te_dim_results.dat", "r"
idata3E = File.open "ord4_m21_te_dim_results.dat", "r"
idata1L = File.open "ord1_m201_tl_dim_results.dat", "r"
idata2L = File.open "ord2_m51_tl_dim_results.dat", "r"
idata3L = File.open "ord4_m21_tl_dim_results.dat", "r"
out1 = File.open "fig-3.dat", "w"
out2 = File.open "fig-4.dat", "w"
a = process idata1E, idata2E, idata3E, idata1L, idata2L, idata3L
print_data a, out1, out2, idata1E, idata2E, idata3E, idata1L, idata2L, idata3L
idata2E = File.open "ord2_te_peak_results.dat", "r"
idata2L = File.open "ord2_5ps_tl_results.dat", "r"
out1 = File.open "fig-5b.dat", "w"
out2 = File.open "fig-6b.dat", "w"
a = idata2E.readlines
a.each_with_index{|x,i| if i%6 == 0 then out1.print x+"\n" end }
a = idata2L.readlines
a.each_with_index{|x,i| if i%6 == 0 then out2.print x+"\n" end }
idata1E = File.open "ord2_m26_te_results.dat", "r"
idata2E = File.open "ord2_m51_te_results.dat", "r"
idata3E = File.open "ord2_m101_te_results.dat", "r"
idata1L = File.open "ord2_m26_tl_results.dat", "r"
idata2L = File.open "ord2_m51_tl_results.dat", "r"
idata3L = File.open "ord2_m101_tl_results.dat", "r"
out1 = File.open "fig-7.dat", "w"
out2 = File.open "fig-8.dat", "w"
a = process idata1E, idata2E, idata3E, idata1L, idata2L, idata3L
print_data a, out1, out2, idata1E, idata2E, idata3E, idata1L, idata2L, idata3L
idata1E = File.open "ord4_m21_te_results.dat", "r"
idata2E = File.open "ord4_m41_te_results.dat", "r"
idata3E = File.open "ord4_m51_te_results.dat", "r"
idata1L = File.open "ord4_m21_tl_results.dat", "r"
idata2L = File.open "ord4_m41_tl_results.dat", "r"
idata3L = File.open "ord4_m51_tl_results.dat", "r"
out1 = File.open "fig-9.dat", "w"
out2 = File.open "fig-10.dat", "w"
a = process idata1E, idata2E, idata3E, idata1L, idata2L, idata3L
print_data a, out1, out2, idata1E, idata2E, idata3E, idata1L, idata2L, idata3L
Gnuplot:
#
# This is a gnuplot script to produce the .ps and .tex files
# for use in LaTeX. It must be run in the same folder as the
# figure .dat files.
#
# To run: gnuplot figures.plt
#
set term pslatex auxfile
set style line 1 lt -1 lw 1
set style line 2 lt 3 pt 6 ps 2
set style line 3 lt 3 pt 10 ps 2
set output "fig-1.tex"
set size 1,1
set xtics nomirror; set ytics nomirror
set format x "$%g$"; set format y "$%g$"
set xlabel 'Time, (ps)'; set ylabel '$T_{e}\;(K)$'
set xrange [0.1:2]; set yrange [300:1400]
plot "fig-1.dat" u 1:2 t "1st Order, M = 201" w l ls 1, \
"fig-1.dat" u 1:3 t "2nd Order, M = 51" w p ls 2, \
"fig-1.dat" u 1:4 t "4th Order, M = 21" w p ls 3
set output "fig-2.tex"
set size 1,1
set xtics nomirror; set ytics nomirror
set format x "$%g$"; set format y "$%g$"
set xlabel 'Time, (ps)'; set ylabel '$T_{l}\;(K)$'
set xrange [0.1:2]; set yrange [300:310]
plot "fig-2.dat" u 1:2 t "1st Order, M = 201" w l ls 1, \
"fig-2.dat" u 1:3 t "2nd Order, M = 51" w p ls 2, \
"fig-2.dat" u 1:4 t "4th Order, M = 21" w p ls 3
set output "fig-3.tex"
set size 1,1
set xtics nomirror; set ytics nomirror
set format x "$%g$"; set format y "$%g$"
set xlabel 'Time, (ps)'; set ylabel '$T_{e}/(\Delta T_{e})_{max}\;(K)$'
set xrange [0.1:2]; set yrange [0:1.1]
plot "fig-3.dat" u 1:2 t "1st Order, M = 201" w l ls 1, \
"fig-3.dat" u 1:3 t "2nd Order, M = 51" w p ls 2, \
"fig-3.dat" u 1:4 t "4th Order, M = 21" w p ls 3
set output "fig-4.tex"
set size 1,1
set xtics nomirror; set ytics nomirror
set format x "$%g$"; set format y "$%g$"
set xlabel 'Time, (ps)'; set ylabel '$T_{l}/(\Delta T_{l})_{max}\;(K)$'
set xrange [0.1:2]; set yrange [0:1.4]
plot "fig-4.dat" u 1:2 t "1st Order, M = 201" w l ls 1, \
"fig-4.dat" u 1:3 t "2nd Order, M = 51" w p ls 2, \
"fig-4.dat" u 1:4 t "4th Order, M = 21" w p ls 3
set output "fig-5.tex"
set size 1,1
set xtics nomirror; set ytics nomirror
set format x "$%g$"; set format y "$%g$"
set xlabel '$r$, (mm)'; set ylabel '$T_{e}\;(K)$'
set xrange [0:0.0001]; set yrange [750:1400]
plot "fig-5a.dat" u 1:2 t "1st Order, M = 201" w l ls 1, \
"fig-5b.dat" u 1:2 t "2nd Order, M = 51" w p ls 2, \
"fig-5c.dat" u 1:2 t "4th Order, M = 21" w p ls 3
set output "fig-6.tex"
set size 1,1
set xtics nomirror; set ytics nomirror
set format x "$%g$"; set format y "$%g$"
set xlabel '$r$, (mm)'; set ylabel '$T_{l}\;(K)$'
set xrange [0:0.0001]; set yrange [306:310]
plot "fig-6a.dat" u 1:2 t "1st Order, M = 201" w l ls 1, \
"fig-6b.dat" u 1:2 t "2nd Order, M = 51" w p ls 2, \
"fig-6c.dat" u 1:2 t "4th Order, M = 21" w p ls 3
set output "fig-7.tex"
set size 1,1
set xtics nomirror; set ytics nomirror
set format x "$%g$"; set format y "$%g$"
set xlabel 'Time, (ps)'; set ylabel '$T_{e}\;(K)$'
set xrange [0.1:2]; set yrange [300:1400]
plot "fig-7.dat" u 1:2 t "2nd Order, M = 101" w l ls 1, \
"fig-7.dat" u 1:3 t "2nd Order, M = 51" w p ls 2, \
"fig-7.dat" u 1:4 t "2nd Order, M = 26" w p ls 3
set output "fig-8.tex"
set size 1,1
set xtics nomirror; set ytics nomirror
set format x "$%g$"; set format y "$%g$"
set xlabel 'Time, (ps)'; set ylabel '$T_{l}\;(K)$'
set xrange [0.1:2]; set yrange [300:310]
plot "fig-8.dat" u 1:2 t "2nd Order, M = 101" w l ls 1, \
"fig-8.dat" u 1:3 t "2nd Order, M = 51" w p ls 2, \
"fig-8.dat" u 1:4 t "2nd Order, M = 26" w p ls 3
set output "fig-9.tex"
set size 1,1
set xtics nomirror; set ytics nomirror
set format x "$%g$"; set format y "$%g$"
set xlabel 'Time, (ps)'; set ylabel '$T_{e}\;(K)$'
set xrange [0.1:2]; set yrange [300:1400]
plot "fig-9.dat" u 1:2 t "4th Order, M = 51" w l ls 1, \
"fig-9.dat" u 1:3 t "4th Order, M = 41" w p ls 2, \
"fig-9.dat" u 1:4 t "4th Order, M = 21" w p ls 3
set output "fig-10.tex"
set size 1,1
set xtics nomirror; set ytics nomirror
set format x "$%g$"; set format y "$%g$"
set xlabel 'Time, (ps)'; set ylabel '$T_{l}\;(K)$'
set xrange [0.1:2]; set yrange [300:310]
plot "fig-10.dat" u 1:2 t "4th Order, M = 51" w l ls 1, \
"fig-10.dat" u 1:3 t "4th Order, M = 41" w p ls 2, \
"fig-10.dat" u 1:4 t "4th Order, M = 21" w p ls 3
%%%%%
Like I said, its not pretty.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment