import os.path as p

import numpy as np
import matplotlib.pyplot as plt

self_path = p.dirname(p.abspath(__file__))
root_path = p.dirname(self_path)

import sys
sys.path.append(p.join(root_path, 'test'))
import output_preservation_test as opt


grid_points = np.array([10, 20, 40, 60, 80, 100, 150, 200, 300, 400, 500])

def benchmark_gaussian_bump_red_grav():
    run_time_O1 = np.zeros(len(grid_points))
    run_time_Ofast = np.zeros(len(grid_points))

    with opt.working_directory(p.join(self_path, "beta_plane_bump_red_grav")):
        aro_exec = "aronnax_test"
        for counter, nx in enumerate(grid_points):
            run_time_O1[counter] = opt.run_experiment(
                opt.write_input_beta_plane_bump_red_grav, nx, nx, 1, aro_exec)

        aro_exec = "aronnax_core"
        for counter, nx in enumerate(grid_points):
            run_time_Ofast[counter] = opt.run_experiment(
                opt.write_input_beta_plane_bump_red_grav, nx, nx, 1, aro_exec)

        plt.figure()
        plt.plot(grid_points, run_time_O1, '-*', label='Aronnax run time -O1')
        plt.plot(grid_points, run_time_Ofast,
            '-*', label='Aronnax run time -Ofast')
        plt.plot(grid_points,
            (run_time_O1[-7]/(grid_points[-7]**2))*grid_points**2,
            '-*', label='O(nx*nx)')
        plt.legend()
        plt.xlabel('nx')
        plt.ylabel('run time (s)')
        plt.savefig('beta_plane_bump_red_grav scaling.png', dpi=150)


def benchmark_gaussian_bump():
    run_time_O1 = np.zeros(len(grid_points))
    run_time_Ofast = np.zeros(len(grid_points))

    with opt.working_directory(p.join(self_path, "beta_plane_bump")):
        aro_exec = "aronnax_test"
        for counter, nx in enumerate(grid_points[:7]):
            run_time_O1[counter] = opt.run_experiment(
                  opt.write_input_beta_plane_bump, nx, nx, 2, aro_exec)

        aro_exec = "aronnax_core"
        for counter, nx in enumerate(grid_points[:7]):
            run_time_Ofast[counter] = opt.run_experiment(
                  opt.write_input_beta_plane_bump, nx, nx, 2, aro_exec)

        plt.figure()
        plt.plot(grid_points[:7], run_time_O1[:7],
            '-*', label='Aronnax run time -O1')
        plt.plot(grid_points[:7], run_time_Ofast[:7], '-*',
            label='Aronnax run time -Ofast')
        plt.plot(grid_points[:7],
            (run_time_O1[-6]/(grid_points[-6]**2))*grid_points[:7]**2,
            '-*', label='O(nx**2)')
        plt.plot(grid_points[:7],
            (run_time_O1[-6]/(grid_points[-6]**3))*grid_points[:7]**3,
            '-*', label='O(nx**3)')
        plt.legend()
        plt.xlabel('nx')
        plt.ylabel('run time (s)')
        plt.savefig('beta_plane_bump scaling.png', dpi=150)

if __name__ == '__main__':
    benchmark_gaussian_bump_red_grav()
    benchmark_gaussian_bump()

@@ -1294,18 +1294,18 @@
 l='O(nx*
-nx
+*2
 )')%0A    
@@ -1450,16 +1450,137 @@
 pi=150)%0A
+        filename = p.join(root_path, 'docs/beta_plane_bump_red_grav_scaling.png')%0A        plt.savefig(filename, dpi=150)%0A
 %0A%0Adef be
@@ -1844,33 +1844,33 @@
 te(grid_points%5B:
-7
+6
 %5D):%0A            
@@ -2069,17 +2069,17 @@
 points%5B:
-7
+6
 %5D):%0A    
@@ -2248,33 +2248,33 @@
 ot(grid_points%5B:
-7
+6
 %5D, run_time_O1%5B:
@@ -2273,17 +2273,17 @@
 ime_O1%5B:
-7
+6
 %5D,%0A     
@@ -2355,17 +2355,17 @@
 points%5B:
-7
+6
 %5D, run_t
@@ -2375,17 +2375,17 @@
 _Ofast%5B:
-7
+6
 %5D, '-*',
@@ -2452,33 +2452,33 @@
 ot(grid_points%5B:
-7
+6
 %5D,%0A            (
@@ -2481,34 +2481,33 @@
    (run_time_O1%5B
--6
+3
 %5D/(grid_points%5B-
@@ -2505,18 +2505,17 @@
 _points%5B
--6
+3
 %5D**2))*g
@@ -2526,17 +2526,17 @@
 points%5B:
-7
+6
 %5D**2,%0A  
@@ -2599,17 +2599,17 @@
 points%5B:
-7
+6
 %5D,%0A     
@@ -2628,18 +2628,17 @@
 time_O1%5B
--6
+3
 %5D/(grid_
@@ -2648,10 +2648,9 @@
 nts%5B
--6
+3
 %5D**3
@@ -2665,17 +2665,17 @@
 points%5B:
-7
+6
 %5D**3,%0A  
@@ -2849,16 +2849,129 @@
 pi=150)%0A
+        filename = p.join(root_path, 'docs/beta_plane_bump_scaling.png')%0A        plt.savefig(filename, dpi=150)%0A%0A
 %0Aif __na

save figures to documentation folder