smbinterp/gmsh/01_merge_output.py

44 lines
851 B
Python

import sys
import numpy as np
indexes = {
2: {
'order' : 0,
'ep' : 1,
'final' : 6,
'exact' : 7,
'time' : 8,
},
3: {
'order' : 0,
'ep' : 1,
'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" % (
resolution,
line[indexes[dim]['order']],
line[indexes[dim]['ep' ]],
line[indexes[dim]['final']],
line[indexes[dim]['exact']],
line[indexes[dim]['time' ]],
)