-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoplot.py
executable file
·87 lines (48 loc) · 1.7 KB
/
autoplot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import os
import sys
import glob
path_dir = os.path.abspath(sys.argv[1])
if os.path.isfile(path_dir):
print "dir only, bro !"
exit(1)
os.mkdir("%s/plots" % path_dir)
tex_file = open('%s/plots/main.tex' % path_dir, 'w')
tex_file.write('\\documentclass{article}\n')
tex_file.write('\\usepackage{graphicx}\n')
tex_file.write('\\begin{document}\n')
lst_dir = os.listdir(path_dir)
#lst_cum = glob.glob(
for each in lst_dir:
plot_file = open('%s/plots/%s.plot' % (path_dir, each), 'w')
plot_file.write('set term postscript eps enhanced\n')
plot_file.write('set output \"%s/plots/%s.eps\"\n' % (path_dir, each))
plot_file.write('plot \"%s/%s\"\n' % (path_dir, each))
plot_file.close()
for each in glob.glob("%s/plots/*.plot" % path_dir):
# print each
os.system("gnuplot %s" % each)
lst_cum = glob.glob("%s/plots/*.cum.eps" % path_dir)
lst_cum.sort()
#print len(lst_cum)
lst_dat = glob.glob("%s/plots/*.dat.eps" % path_dir)
lst_dat.sort()
#print len(lst_dat)
lst_cum_norm = glob.glob("%s/plots/*.cum.norm.eps" % path_dir)
lst_cum_norm.sort()
#print len(lst_cum_norm)
lst_dat_norm = glob.glob("%s/plots/*.dat.norm.eps" % path_dir)
lst_dat_norm.sort()
#print len(lst_dat_norm)
tex_file = open('%s/plots/main.tex' % path_dir, 'a')
for each in range(len(lst_cum)):
tex_file.write('\\includegraphics{%s}\n' % lst_cum[each])
tex_file.write('\\includegraphics{%s}\n' % lst_dat[each])
# if each % 5 == 0 and each != 0:
# for i in range((each - 5), each):
# tex_file.write('\\includegraphics{%s}\n' % lst_cum_norm[i])
# tex_file.write('\\includegraphics[%s}
tex.file.write('\\end{document}\n')
tex_file.close()
#for each in xrange(len(lst_cum)):
# cum_file = open("%s", "a")
# cum_file.write("", "")