-
Notifications
You must be signed in to change notification settings - Fork 1
/
selfenergy.py
53 lines (41 loc) · 1.5 KB
/
selfenergy.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
import sys
import re
def plot_gw(plot_file, plot_data):
sigma = plot_data
#top/bottom/efstate:=highest/lowest/valence band top
top = 13
efstate = 10
bottom = 2
plot = open(plot_file,'w')
#print >> plot, "unset key"
print >> plot, "plot '%s' u 1:%d w lp pt 7 lt -1" %(sigma, bottom)
for i in range(bottom+1, efstate):
print >> plot, "replot '%s' u 1:%d w lp pt 7 lt -1" %(sigma, i)
print >> plot, "replot '%s' u 1:%d w lp pt 7 lt 3" %(sigma, efstate)
for i in range(efstate+1, top+1):
print >> plot, "replot '%s' u 1:%d w lp pt 7 lt 1" %(sigma, i)
return
f = open(sys.argv[1]).read()
res = open('resigma.dat', 'w')
ims = open('imsigma.dat', 'w')
aspec = open('aspec.dat', 'w')
sigma_regex = re.compile(r'GW qp renorm.*?\n\n(.*?)\Z', re.M | re.S)
sigmare_regex = re.compile(r'REsigma\n(.*?)IMsigma', re.M | re.S)
sigmaim_regex = re.compile(r'IMsigma\n(.*?)ASpec', re.M | re.S)
sigmaspec_regex = re.compile(r'ASpec\n(.*?)\n\s{0,}\n', re.M | re.S)
#blocks_text = sigma_regex.findall(f)
block = sigmare_regex.findall(f)
#for line in block[0].split('\n'):
#print block[0]
for line in block[0].split('\n'):
print >>res, line
block = sigmaim_regex.findall(f)
for line in block[0].split('\n'):
print >>ims, line
block = sigmaspec_regex.findall(f)
for line in block[0].split('\n'):
print >>aspec, line
datafiles = ['resigma.dat', 'imsigma.dat', 'aspec.dat']
plotfiles = ['plotre.gnu', 'plotim.gnu', 'plotaspec.gnu']
for a, b in zip(plotfiles,datafiles):
plot_gw(a,b)