-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheigenconvert.py
More file actions
27 lines (22 loc) · 791 Bytes
/
eigenconvert.py
File metadata and controls
27 lines (22 loc) · 791 Bytes
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
"""
name: eigenconvert.py
usage: eigenconvert.py <inputfile>
author: Sean Anderson (https://github.com/roguephysicist)
This is a standalone script that converts an unformatted EIG file produced by
ABINIT to a plottable file.
"""
import sys
import re
infile=sys.argv[1]
outfile=sys.argv[2]
def eigenformat(inputfile, outputfile):
""" formats ABINIT eig file for easy plotting """
print("Reading file {0}".format(inputfile))
with open(inputfile, "r") as ifile:
text = ifile.read().replace('\n', '').replace('kpt#', '\n')
sub = re.sub(r',.*\)', "", text)
final = '\n'.join(sub.split('\n')[1:])
with open(outputfile, "w") as ofile:
ofile.write(final)
print("Created formatted eigenvalue file {0}".format(outputfile))
eigenformat(infile, outfile)