merged the drivers, and am investigating the qdelauney manpage ... should've done this earlier :P
--HG-- rename : bin/driver-random.py => bin/driver.py rename : test/utest.py => test/qhull.test.py
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
|
||||
import numpy as np
|
||||
import scipy.spatial
|
||||
|
||||
from grid import simple_random_grid, exact_func
|
||||
import baker
|
||||
|
||||
def rms(errors):
|
||||
r = 0.0
|
||||
for i in errors:
|
||||
r += np.power(i, 2)
|
||||
r = np.sqrt(r / len(errors))
|
||||
return r
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = OptionParser()
|
||||
parser.add_option("-o", "--output-file", dest="output", type='str', default = '/tmp/for_qhull.txt', help = "qhull output file")
|
||||
parser.add_option("-e", "--extra-points", dest="extra", type='int', default = 3, help = "how many extra points")
|
||||
parser.add_option("-s", "--source-total", dest="source_total", type='int', default = 100, help = "total number of source points")
|
||||
parser.add_option("-d", "--destination-total",dest="destination_total",type='int', default = 100, help = "total number of destination points")
|
||||
parser.add_option("-v", "--verbose", action = 'store_true', default = False, help = "verbosity")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
print >> sys.stderr, options
|
||||
|
||||
mesh_source = simple_random_grid(options.source_total)
|
||||
tree = scipy.spatial.KDTree(mesh_source.points)
|
||||
mesh_dest = simple_random_grid(options.destination_total)
|
||||
|
||||
open(options.output, 'w').write(mesh_source.for_qhull())
|
||||
print >> sys.stderr, "wrote output to %s" % options.output
|
||||
|
||||
errors = []
|
||||
success = 0
|
||||
for x in mesh_dest.points:
|
||||
lin, error, final = baker.run_baker(x, mesh_source, tree, options.extra, options.verbose)
|
||||
exact = exact_func(x[0], x[1])
|
||||
if np.abs(exact - final) < np.abs(exact - lin):
|
||||
success += 1
|
||||
|
||||
if options.verbose:
|
||||
print "current point : %s" % x
|
||||
print "exact : %0.4f" % exact
|
||||
print "qlin : %0.4f" % lin
|
||||
print "q_final : %0.4f" % final
|
||||
print "qlinerr : %0.4f" % (exact - lin,)
|
||||
print "q_final_err : %0.4f" % (exact - final,)
|
||||
cur_error = np.abs(final - exact)
|
||||
errors.append(cur_error)
|
||||
|
||||
print rms(errors)
|
||||
print "%s of %s won" % (success, options.destination_total)
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
|
||||
import numpy as np
|
||||
import scipy.spatial
|
||||
|
||||
from grid import simple_rect_grid, exact_func
|
||||
import baker
|
||||
from tools import rms
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = OptionParser()
|
||||
parser.add_option("-e", "--extra-points", dest="extra", type='int', default = 3, help = "how many extra points")
|
||||
parser.add_option("-s", "--source-density", dest="source", type='int', default = 11, help = "resolution of source mesh")
|
||||
parser.add_option("-d", "--dest-density", dest="dest", type='int', default = 11, help = "resolution of dest mesh")
|
||||
parser.add_option("-t", "--random-total", dest="random_total", type='int', default = 100, help = "total number of random points")
|
||||
parser.add_option("-r", "--random-dest", action = 'store_true', default = False, help = "verbosity")
|
||||
parser.add_option("-v", "--verbose", action = 'store_true', default = False, help = "verbosity")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
print >> sys.stderr, options
|
||||
|
||||
mesh_source = simple_rect_grid(options.source, options.source)
|
||||
tree = scipy.spatial.KDTree(mesh_source.points)
|
||||
|
||||
mesh_dest = simple_rect_grid(options.dest, options.dest)
|
||||
|
||||
if options.random_dest:
|
||||
x = []
|
||||
for i in xrange(options.random_total):
|
||||
rx = np.random.rand() * 2 - 1
|
||||
ry = np.random.rand() * 2 - 1
|
||||
x.append([rx, ry])
|
||||
mesh_dest.points = np.array(x)
|
||||
|
||||
errors = []
|
||||
for x in mesh_dest.points:
|
||||
(final, exact) = baker.run_baker(x, mesh_source, tree, options.extra, options.verbose)
|
||||
cur_error = np.abs(final - exact)
|
||||
errors.append(cur_error)
|
||||
|
||||
print rms(errors)
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
|
||||
import numpy as np
|
||||
import scipy.spatial
|
||||
|
||||
import baker
|
||||
from tools import rms, get_mesh, exact_func
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = OptionParser()
|
||||
parser.add_option("-o", "--output-file", dest="output", type='str', default = '/tmp/for_qhull.txt', help = "qhull output file")
|
||||
parser.add_option("-e", "--extra-points", dest="extra", type='int', default = 3, help = "how many extra points")
|
||||
|
||||
parser.add_option("-s", "--source-total", dest="source_total", type='int', default = 100, help = "total number of source points for random, resolution for structured")
|
||||
parser.add_option("-d", "--destination-total", dest="destination_total", type='int', default = 100, help = "total number of destination points, resolution for structured")
|
||||
|
||||
parser.add_option("-r", "--structured", action = 'store_true', default = False, help = "use a structured grid instead of random point cloud")
|
||||
parser.add_option("-v", "--verbose", action = 'store_true', default = False, help = "verbosity")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
print >> sys.stderr, options
|
||||
|
||||
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
|
||||
|
||||
errors = []
|
||||
success = 0
|
||||
for x in mesh_dest.points:
|
||||
lin, error, final = baker.run_baker(x, mesh_source, tree, options.extra, options.verbose)
|
||||
exact = exact_func(x[0], x[1])
|
||||
if np.abs(exact - final) < np.abs(exact - lin):
|
||||
success += 1
|
||||
|
||||
if options.verbose:
|
||||
print "current point : %s" % x
|
||||
print "exact : %0.4f" % exact
|
||||
print "qlin : %0.4f" % lin
|
||||
print "q_final : %0.4f" % final
|
||||
print "qlinerr : %0.4f" % (exact - lin,)
|
||||
print "q_final_err : %0.4f" % (exact - final,)
|
||||
cur_error = np.abs(final - exact)
|
||||
errors.append(cur_error)
|
||||
|
||||
print rms(errors)
|
||||
print "%s of %s won" % (success, options.destination_total)
|
||||
Reference in New Issue
Block a user