smbinterp/gmsh/01_merge_output.py

50 lines
999 B
Python

import sys
import numpy as np
indexes = {
2: {
'order' : 0,
'ep' : 1,
'qlin' : 4,
'err' : 5,
'final' : 6,
'exact' : 7,
'time' : 8,
},
3: {
'order' : 0,
'ep' : 1,
'qlin' : 5,
'err' : 6,
'final' : 7,
'exact' : 8,
'time' : 9,
},
}
if __name__ == '__main__':
files = sys.argv[1:]
prefixes = set((i[0] for i in files))
if len(prefixes) != 1:
print "must only feed either 3- or 2-D files, not mixed"
sys.exit(1)
dim = int(prefixes.pop())
for cur_filename in files:
resolution = int(cur_filename.split('.')[1])
lines = np.loadtxt(cur_filename)
for line in lines:
print "%d %d %d %e %e %e %e %e" % (
resolution,
line[indexes[dim]['order']],
line[indexes[dim]['ep' ]],
line[indexes[dim]['qlin' ]],
line[indexes[dim]['err' ]],
line[indexes[dim]['final']],
line[indexes[dim]['exact']],
line[indexes[dim]['time' ]],
)