From d82f680eed55737aa2cf2672aa28fb362f1c2bf5 Mon Sep 17 00:00:00 2001
From: Chichi Lalescu <Cristian.Lalescu@ds.mpg.de>
Date: Sat, 26 Dec 2015 17:01:38 +0100
Subject: [PATCH] update for new testing approach

---
 tests/test_plain.py | 87 ++++++---------------------------------------
 1 file changed, 11 insertions(+), 76 deletions(-)

diff --git a/tests/test_plain.py b/tests/test_plain.py
index 07d8e2a2..8ada988a 100755
--- a/tests/test_plain.py
+++ b/tests/test_plain.py
@@ -58,84 +58,19 @@ def plain(opt):
     opt.niter_todo = 2*opt.niter_todo//3
     c2 = launch(opt, dt = c0.parameters['dt'])
     c2.compute_statistics()
-    # plot energy and enstrophy
-    fig = plt.figure(figsize = (12, 12))
-    a = fig.add_subplot(221)
-    c0.set_plt_style({'label' : '1',
-                      'dashes' : (None, None),
-                      'color' : (1, 0, 0)})
-    c1.set_plt_style({'label' : '2',
-                      'dashes' : (2, 2),
-                      'color' : (0, 0, 1)})
-    c2.set_plt_style({'label' : '3',
-                      'dashes' : (3, 3),
-                      'color' : (0, 1, 0)})
-    for c in [c0, c1, c2]:
-        a.plot(c.statistics['t'],
-               c.statistics['energy(t)'],
-               label = c.style['label'],
-               dashes = c.style['dashes'],
-               color = c.style['color'])
-    a.set_title('energy')
-    a.legend(loc = 'best')
-    a = fig.add_subplot(222)
-    for c in [c0, c1, c2]:
-        a.plot(c.statistics['t'],
-               c.statistics['enstrophy(t)'],
-               dashes = c.style['dashes'],
-               color = c.style['color'])
-    a.set_title('enstrophy')
-    a = fig.add_subplot(223)
-    for c in [c0, c1, c2]:
-        a.plot(c.statistics['t'],
-               c.statistics['kM']*c.statistics['etaK(t)'],
-               dashes = c.style['dashes'],
-               color = c.style['color'])
-    a.set_title('$k_M \\eta_K$')
-    a = fig.add_subplot(224)
-    for c in [c0, c1, c2]:
-        a.plot(c.statistics['t'],
-               c.statistics['vel_max(t)'] * (c.parameters['dt'] * c.parameters['dkx'] /
-                                             (2*np.pi / c.parameters['nx'])),
-               dashes = c.style['dashes'],
-               color = c.style['color'])
-    a.set_title('$\\frac{\\Delta t \\| u \\|_\infty}{\\Delta x}$')
-    fig.savefig('plain_stats_{0}.pdf'.format(opt.precision), format = 'pdf')
-
-    fig = plt.figure(figsize = (12, 12))
-    a = fig.add_subplot(221)
-    a.plot(c0.statistics['t'],
-           c0.statistics['energy(t)'] - c1.statistics['energy(t)'])
-    a.set_title('energy')
-    a = fig.add_subplot(222)
-    a.plot(c0.statistics['t'],
-           c0.statistics['enstrophy(t)'] - c1.statistics['enstrophy(t)'])
-    a.set_title('enstrophy')
-    a = fig.add_subplot(223)
-    a.plot(c0.statistics['t'],
-           c0.statistics['kM']*c0.statistics['etaK(t)'] - c1.statistics['kM']*c1.statistics['etaK(t)'])
-    a.set_title('$k_M \\eta_K$')
-    a = fig.add_subplot(224)
-    data0 = c0.statistics['vel_max(t)'] * (c0.parameters['dt'] * c0.parameters['dkx'] /
-                                           (2*np.pi / c0.parameters['nx']))
-    data1 = c1.statistics['vel_max(t)'] * (c1.parameters['dt'] * c1.parameters['dkx'] /
-                                           (2*np.pi / c1.parameters['nx']))
-    a.plot(c0.statistics['t'],
-           data0 - data1)
-    a.set_title('$\\frac{\\Delta t \\| u \\|_\infty}{\\Delta x}$')
-    fig.savefig('plain_stat_diffs_{0}.pdf'.format(opt.precision), format = 'pdf')
-
-    # plot trajectory differences
-    for i in range(c0.particle_species):
-        fig = plt.figure(figsize=(12, 4))
-        for j in range(3):
-            a = fig.add_subplot(131 + j)
-            for t in range(c0.parameters['nparticles']):
-                a.plot(c0.trajectories[i][:, t, j] - c1.trajectories[i][:, t, j])
-        fig.savefig('traj_s{0}_{1}.pdf'.format(i, opt.precision), format = 'pdf')
+    compare_stats(opt, c0, c1)
     return None
 
 if __name__ == '__main__':
-    opt = parser.parse_args()
+    opt = parser.parse_args(
+            ['-n', '32',
+             '--run',
+             '--ncpu', '2',
+             '--nparticles', '1000',
+             '--niter_todo', '48',
+             '--precision', 'single',
+             '--multiplejob',
+             '--wd', 'data/single'] +
+            sys.argv[1:])
     plain(opt)
 
-- 
GitLab