diff --git a/bin/driver.py b/bin/driver.py deleted file mode 100644 index bba1160..0000000 --- a/bin/driver.py +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env python - -import sys -from optparse import OptionParser - -import numpy as np - -from interp.tools import rms, baker_exact_2D as exact_func -from interp.grid.DD import random_grid, rect_grid - - -def get_mesh(source, destination, use_structured_grid = False): - mesh_source = None - mesh_dest = None - if use_structured_grid: - mesh_source = rect_grid(source, source) - mesh_dest = rect_grid(destination, destination) - else: - mesh_source = random_grid(source) - mesh_dest = random_grid(destination) - - if not (mesh_dest and mesh_source): - raise smberror('problem creating mesh objects') - else: - return mesh_source, mesh_dest - - -if __name__ == '__main__': - parser = OptionParser() - - parser.add_option("-o", - "--order", - dest="order", - type='int', - default = 3, - help = "how many extra verts (%default)") - - parser.add_option("-e", - "--extra-verts", - dest="extra", - type='int', - default = 3, - help = "how many extra verts (%default)") - - parser.add_option("-s", - "--source-total", - dest="source_total", - type='int', - default = 100, - help = "total number of source verts for random, resolution for structured (%default)") - - parser.add_option("-d", - "--destination-total", - dest="destination_total", - type='int', - default = 100, - help = "total number of destination verts, resolution for structured (%default)") - - parser.add_option("-r", - "--structured", - action = 'store_true', - default = False, - help = "use a structured grid instead of random point cloud (%default)") - - parser.add_option("-v", - "--verbose", - action = 'store_true', - default = False, - help = "verbosity (%default)") - - (options, args) = parser.parse_args() - - - (mesh_source, mesh_dest) = get_mesh(options.source_total, options.destination_total, options.structured) - - - errors = [] - success = 0 - - for X in mesh_dest.verts: - - answer = mesh_source.run_baker(X, order = options.order, extra_points = options.extra) - - if answer['abc'] == None: - print "None" - errors.append(0) - continue - - exact = exact_func(X) - if np.abs(exact - answer['final']) <= np.abs(exact - answer['qlin']): - success += 1 - - if options.verbose: - print "current point : %s" % X - print "exact : %0.4f" % exact - print "qlin : %0.4f" % answer['qlin'] - print "q_final : %0.4f" % answer['final'] - print "error w/o : %1.4f" % (exact - answer['qlin'],) - print "error w/ : %0.4f" % (exact - answer['final'],) - print - cur_error = np.abs(answer['final'] - exact) - errors.append(cur_error) - - print rms(errors) - print >>sys.stderr, "%s of %s won" % (success, len(mesh_dest.verts))