Private Pages

out

#
import sys
args = sys.argv
filename = args[1]
fp = open(filename)
lines = fp.readlines()
fp.close()
kpts = {}
energies = {}
for line in lines:
  tokens = line.split()
  if len(tokens) == 0:
    continue
  if tokens[0] == 'KPT:':
    if len(tokens) == 6:
      if tokens[1].isdigit():
        kpt = int(tokens[1])
        kpts[kpt] = [float(tokens[2]), float(tokens[3]), float(tokens[4])]
        energies[kpt] = []
  if tokens[0] == 'EIG':
    if tokens[2].isdigit():
      kpt = int(tokens[2])
      energies[kpt].append(float(tokens[3]))
nbands = list(range(1, len(energies[1]) + 1))
print('"kpt","kx","ky","kz"', *nbands, sep = ',')
for kpt in kpts.keys():
  print(kpt, *kpts[kpt], *energies[kpt], sep = ',')