From cbe1a778c92155643f42d9dbbe780f9ad9ddcb42 Mon Sep 17 00:00:00 2001 From: Stephen Mardson McQuay Date: Fri, 6 May 2011 11:02:24 -0600 Subject: [PATCH] added resolution study script --- bin/resolution.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 bin/resolution.py diff --git a/bin/resolution.py b/bin/resolution.py new file mode 100644 index 0000000..0cfe5dd --- /dev/null +++ b/bin/resolution.py @@ -0,0 +1,45 @@ +import sys +import numpy as np +from interp.grid.delaunay import dgrid +from interp.tools import baker_exact_3D +from interp.tools import rms +from progressbar import * + +attempts = 1000 +widgets = ['submit jobs: ', Percentage(), ' ', Bar(), ' ', ETA()] +results = {} + +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() + start = time.time() + + errors = [] + i = 0 + outside = 0 + while i < attempts: + 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() + print "\n" + end = time.time() + + rmserror = rms(errors) + results[resolution] = rmserror + + print resolution, rmserror, outside, end - start