added scripts for transforming runs into sqlite db, and a file to analyze said db

This commit is contained in:
Stephen McQuay 2011-05-26 16:47:32 -06:00
parent 9a0d0a3e10
commit bc976ffc56
3 changed files with 92 additions and 0 deletions

43
gmsh/01_merge_output.py Normal file
View File

@ -0,0 +1,43 @@
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' ]],
)

View File

@ -0,0 +1,26 @@
import sys
import numpy as np
import sqlite3
from optparse import OptionParser
if __name__ == '__main__':
parser = OptionParser(usage = "usage: %s <input text file> <output db file>")
(options, args) = parser.parse_args()
if len(args) != 2:
parser.print_usage()
sys.exit(1)
data_file_name, sql_file_name = args
data = np.loadtxt(data_file_name)
con = sqlite3.connect(sql_file_name)
cur = con.cursor()
cur.execute('DROP TABLE IF EXISTS results')
cur.execute('CREATE TABLE results (res INTEGER, ord INTEGER, ep INTEGER, final FLOAT, exact FLOAT, time FLOAT)')
cur.executemany("insert into results values(?,?,?,?,?,?)", data)
con.commit()
cur.close()
con.close()

23
gmsh/03_plotter.py Normal file
View File

@ -0,0 +1,23 @@
import sqlite3
import numpy as np
con = sqlite3.connect('data.db')
cur = con.cursor()
orders = np.array(cur.execute('select distinct ord from results').fetchall())[:,0]
eps = np.array(cur.execute('select distinct ep from results').fetchall())[:,0]
print "#", orders, eps
with open('time.out', 'w') as time_file:
for ep in eps:
time_file.write("%d " % ep)
for order in orders:
cur_results = cur.execute('select time from results where res = 1 and ep = ? and ord = ?',
(int(ep),int(order)))
cur_time = np.array(cur_results.fetchall()).mean()
time_file.write("%e " % cur_time)
time_file.write("\n")
print "%e" % np.array(cur.execute('select abs(exact - final) from results').fetchall()).mean()