fleshed out the resolution study script
This commit is contained in:
parent
b952a4a0c8
commit
c85164769d
@ -1,45 +1,58 @@
|
|||||||
import sys
|
import sys
|
||||||
import numpy as np
|
import pickle
|
||||||
from interp.grid.delaunay import dgrid
|
|
||||||
from interp.tools import baker_exact_3D
|
import time
|
||||||
from interp.tools import rms
|
|
||||||
from progressbar import *
|
from progressbar import *
|
||||||
|
|
||||||
attempts = 1000
|
from interp.grid.DD import *
|
||||||
|
from interp.tools import *
|
||||||
|
from interp import bootstrap
|
||||||
|
|
||||||
|
EXTRA_POINTS = 95
|
||||||
|
|
||||||
|
RES_START = 10
|
||||||
|
RES_END = 100
|
||||||
|
RES_DELTA = 10
|
||||||
|
|
||||||
|
ORDER_START = 5
|
||||||
|
ORDER_END = 8
|
||||||
|
|
||||||
|
dest_verts, output_filename = sys.argv[1:]
|
||||||
|
dest_verts = pickle.load(open(dest_verts, 'r'))
|
||||||
|
|
||||||
|
output_file = open(output_filename, 'w')
|
||||||
|
|
||||||
|
count = len(dest_verts) * len(xrange(RES_START,RES_END + 1, RES_DELTA)) * len(xrange(ORDER_START, ORDER_END + 1))
|
||||||
|
|
||||||
widgets = ['submit jobs: ', Percentage(), ' ', Bar(), ' ', ETA()]
|
widgets = ['submit jobs: ', Percentage(), ' ', Bar(), ' ', ETA()]
|
||||||
results = {}
|
pbar = ProgressBar(widgets = widgets, maxval = count)
|
||||||
|
|
||||||
for r in xrange(2,8):
|
|
||||||
resolution = float("1e%d" % r)
|
|
||||||
|
|
||||||
v = np.random.random((resolution,3))
|
|
||||||
q = [baker_exact_3D(x) for x in v]
|
|
||||||
g = dgrid(v,q)
|
|
||||||
|
|
||||||
|
|
||||||
pbar = ProgressBar(widgets = widgets, maxval = attempts)
|
|
||||||
pbar.start()
|
pbar.start()
|
||||||
start = time.time()
|
|
||||||
|
|
||||||
errors = []
|
|
||||||
i=0
|
i=0
|
||||||
outside = 0
|
for resolution in xrange(RES_START,RES_END + 1, RES_DELTA):
|
||||||
while i < attempts:
|
r = rect_grid(resolution, resolution)
|
||||||
try:
|
|
||||||
X = np.random.random((1,3))[0]
|
|
||||||
e = g.run_baker(X)['final'] - baker_exact_3D(X)
|
|
||||||
errors.append(e)
|
|
||||||
pbar.update(i+1)
|
|
||||||
i += 1
|
|
||||||
except Exception as e:
|
|
||||||
# print X, i, resolution
|
|
||||||
outside += 1
|
|
||||||
|
|
||||||
pbar.finish()
|
for v in xrange(len(r.verts)):
|
||||||
print "\n"
|
r.q[v] = baker_exact_2D(r.verts[v])
|
||||||
|
|
||||||
|
output_file.write("%f" % (1.0 / resolution))
|
||||||
|
|
||||||
|
for order in xrange(ORDER_START, ORDER_END + 1):
|
||||||
|
errors = []
|
||||||
|
|
||||||
|
start = time.time()
|
||||||
|
for X in dest_verts:
|
||||||
|
a = r.run_baker(X, order, EXTRA_POINTS)
|
||||||
|
cur_exact = baker_exact_2D(X)
|
||||||
|
e = a['final'] - cur_exact
|
||||||
|
errors.append(e)
|
||||||
|
i+=1
|
||||||
|
pbar.update(i)
|
||||||
end = time.time()
|
end = time.time()
|
||||||
|
|
||||||
rmserror = rms(errors)
|
rmserror = rms(errors)
|
||||||
results[resolution] = rmserror
|
output_file.write(" %e" % rmserror)
|
||||||
|
output_file.write("\n")
|
||||||
print resolution, rmserror, outside, end - start
|
output_file.flush()
|
||||||
|
pbar.finish()
|
||||||
|
Loading…
Reference in New Issue
Block a user