2011-05-26 20:35:19 -07:00
|
|
|
import sys
|
2011-05-27 14:06:35 -07:00
|
|
|
import os
|
2011-05-26 15:47:32 -07:00
|
|
|
import sqlite3
|
2011-05-27 14:06:35 -07:00
|
|
|
|
2011-05-27 16:18:44 -07:00
|
|
|
from interp.tools import rms, improved
|
2011-05-27 14:06:35 -07:00
|
|
|
|
2011-05-26 15:47:32 -07:00
|
|
|
import numpy as np
|
|
|
|
|
2011-05-27 14:06:35 -07:00
|
|
|
from optparse import OptionParser
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
parser = OptionParser(usage = "usage: %s [options] <db file>")
|
|
|
|
|
|
|
|
parser.add_option("-R", "--resolution",
|
|
|
|
type="int", dest="res", default=1,
|
|
|
|
help="resolution (for constant resolution charts) (default: %default)")
|
|
|
|
|
|
|
|
parser.add_option("-t", "--time",
|
|
|
|
action="store_true", dest="time", default=False,
|
|
|
|
help="write out timing results (default: %default)")
|
|
|
|
|
2011-05-27 16:18:44 -07:00
|
|
|
parser.add_option("-T", "--truthy",
|
|
|
|
action="store_true", dest="truthy", default=False,
|
|
|
|
help="calculate truthiness plots (default: %default)")
|
2011-05-27 14:06:35 -07:00
|
|
|
|
|
|
|
parser.add_option("-r", "--rms",
|
|
|
|
action="store_true", dest="rms", default=False,
|
|
|
|
help="write out rms output (default: %default)")
|
|
|
|
|
|
|
|
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
if len(args) != 1:
|
|
|
|
parser.print_usage()
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
con = sqlite3.connect(args[0])
|
|
|
|
cur = con.cursor()
|
|
|
|
|
|
|
|
|
|
|
|
resolutions = np.array(cur.execute('select distinct res from results').fetchall())[:,0]
|
|
|
|
orders = np.array(cur.execute('select distinct ord from results').fetchall())[:,0]
|
|
|
|
extrapoints = np.array(cur.execute('select distinct ep from results').fetchall())[:,0]
|
|
|
|
print "# i found these resolutions %s, orders: %s, and extra points: %s" % (resolutions, orders, extrapoints)
|
2011-05-26 15:47:32 -07:00
|
|
|
|
2011-05-27 14:06:35 -07:00
|
|
|
if options.time:
|
|
|
|
for ep in extrapoints:
|
|
|
|
print "%d " % (ep,),
|
|
|
|
for order in orders:
|
|
|
|
for res in resolutions:
|
|
|
|
cur_results = cur.execute('select time from results where res = ? and ep = ? and ord = ?',
|
|
|
|
(int(res), int(ep),int(order)))
|
|
|
|
cur_time = np.array(cur_results.fetchall()).mean()
|
|
|
|
print "%e " % (cur_time,),
|
2011-05-26 15:47:32 -07:00
|
|
|
|
2011-05-27 14:06:35 -07:00
|
|
|
print
|
2011-05-26 15:47:32 -07:00
|
|
|
|
|
|
|
|
2011-05-27 14:06:35 -07:00
|
|
|
# print "%e" % np.array(cur.execute('select abs(exact - final) from results').fetchall()).mean()
|
|
|
|
if options.rms:
|
|
|
|
for ep in extrapoints:
|
|
|
|
print "%d " % (ep,),
|
|
|
|
for order in orders:
|
|
|
|
for res in resolutions:
|
|
|
|
cur_results = cur.execute('select abs(exact - final) from results where res = ? and ep = ? and ord = ?',
|
|
|
|
(int(res), int(ep),int(order)))
|
|
|
|
cur_time = rms(np.array(cur_results.fetchall()))
|
|
|
|
print "%e " % (cur_time,),
|
2011-05-26 15:47:32 -07:00
|
|
|
|
2011-05-27 14:06:35 -07:00
|
|
|
print
|
2011-05-27 16:18:44 -07:00
|
|
|
|
|
|
|
|
|
|
|
if options.truthy:
|
|
|
|
for ep in extrapoints:
|
|
|
|
print "%d " % (ep,),
|
|
|
|
for order in orders:
|
|
|
|
for res in resolutions:
|
|
|
|
cur_results = cur.execute('select qlin, err, final, exact from results where res = ? and ep = ? and ord = ?',
|
|
|
|
(int(res), int(ep),int(order)))
|
|
|
|
cur_array = np.array(cur.fetchall())
|
|
|
|
tf = [improved(*i) for i in cur_array]
|
|
|
|
win_percent = float(tf.count(True)) / len(tf)
|
|
|
|
print "%e " % (win_percent,),
|
|
|
|
|
|
|
|
print
|