#!/usr/bin/python import sys import time import os nfiles = len(sys.argv[3:]) print "number of files = ", nfiles eta = float(sys.argv[1]) # value of the lorentzian broadening ntics = int(sys.argv[2]) # number of tick intervals desired on the vertical axis ltime = time.localtime() date = ' (' + str(ltime[2]) + '/' + str(ltime[1]) + '/' + str(ltime[0]) + ')' print date for f in sys.argv[3:]: if f[-3:] == "_sp": stub = f[:-3] else: print "file " + f + " does not have the right suffix!" continue fin = open(f,'r') fout = open(stub + ".plt",'w') param = fin.readline()[1:] param = param[:-1] print "processing " + f + ": " + param klist = fin.readline().split(); klist = klist[1:] nk = len(klist) print nk, "wavevectors\n" fout.writelines("set title '" + param + date + "'\n") fout.writelines("a = " + str(1.0/(eta*nk))) fout.writelines("\nset output '" + stub + ".ps'") out = """ set nokey set terminal postscript solid set arrow from 0, graph 0 to 0, graph 1 nohead\n""" fout.writelines(out) # Here we set the ticks on the y axis skip = nk//ntics j=0; out = "set ytics (" j = 0 while j < nk : out = out + "'" + klist[j] + "' " + str(j) + "*a," j += skip out = out + "'' 0)\n"; fout.writelines(out) # then plotting each column out = "plot '" + f + "' u 1:2 w l lt 1" j=1; while j < nk : out = out + ",\\\n '' u 1:($" + str(j+2) + "+a*" + str(j) + ") w l lt 1" j += 1 fout.writelines(out) fout.close() os.system("gnuplot " + stub + ".plt") os.system("cat " + stub + ".ps >> spectre.ps") os.system("rm -f " + stub + ".ps") os.system("rm -f " + f + ".plt") os.system("ps2pdf spectre.ps") os.system("rm -f spectre.ps")