moved teh grid code into the grid class
by next friday i need to have implemented a way to select between normal kdtree point lookups, and nearest-neighbor lookups. Hopefully i'll have that done tonight.
This commit is contained in:
+7
-24
@@ -4,9 +4,7 @@ import sys
|
||||
from optparse import OptionParser
|
||||
|
||||
import numpy as np
|
||||
import scipy.spatial
|
||||
|
||||
import baker
|
||||
from tools import rms, exact_func
|
||||
import grid
|
||||
|
||||
@@ -72,36 +70,21 @@ if __name__ == '__main__':
|
||||
help = "verbosity")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
print >> sys.stderr, "options: %s, args: %s" % (options, args)
|
||||
|
||||
|
||||
(mesh_source, mesh_dest) = get_mesh(options.source_total, options.destination_total, options.structured)
|
||||
|
||||
|
||||
(mesh_source, mesh_dest) = get_mesh(options.source_total, options.destination_total, options.structured)
|
||||
|
||||
tree = scipy.spatial.KDTree(mesh_source.points)
|
||||
open(options.output, 'w').write(mesh_source.for_qhull())
|
||||
print >> sys.stderr, "wrote source mesh output to %s" % options.output
|
||||
if options.verbose:
|
||||
print >> sys.stderr, "options: %s, args: %s" % (options, args)
|
||||
print >> sys.stderr, "wrote source mesh output to %s" % options.output
|
||||
|
||||
errors = []
|
||||
success = 0
|
||||
|
||||
for X in mesh_dest.points:
|
||||
|
||||
(dist, indicies) = tree.query(X, 3 + options.extra)
|
||||
|
||||
|
||||
# get the containing simplex
|
||||
R = [mesh_source.points[i] for i in indicies[:3] ]
|
||||
Rq = [mesh_source.q[i] for i in indicies[:3] ]
|
||||
r_mesh = grid.grid(R, Rq)
|
||||
|
||||
# and some extra points
|
||||
S = [mesh_source.points[i] for i in indicies[3:] ]
|
||||
Sq = [mesh_source.q[i] for i in indicies[3:] ]
|
||||
s_mesh = grid.grid(S, Sq)
|
||||
|
||||
answer = baker.run_baker(X, r_mesh, s_mesh, options.verbose)
|
||||
answer = mesh_source.run_baker(X)
|
||||
|
||||
if answer['a'] == None:
|
||||
errors.append(0)
|
||||
@@ -114,9 +97,9 @@ if __name__ == '__main__':
|
||||
if options.verbose:
|
||||
print "current point : %s" % X
|
||||
print "exact : %0.4f" % exact
|
||||
print "qlin : %0.4f" % answer['lin']
|
||||
print "qlin : %0.4f" % answer['qlin']
|
||||
print "q_final : %0.4f" % answer['final']
|
||||
print "qlinerr : %1.4f" % (exact - anser['lin'],)
|
||||
print "qlinerr : %1.4f" % (exact - answer['qlin'],)
|
||||
print "q_final_err : %0.4f" % (exact - answer['final'],)
|
||||
cur_error = np.abs(answer['final'] - exact)
|
||||
errors.append(cur_error)
|
||||
|
||||
Reference in New Issue
Block a user