~fluidity-core/fluidity/sea-ice-branch

« back to all changes in this revision

Viewing changes to tests/mms_rans_p2p1_keps/function_printer.py

  • Committer: Simon Mouradian
  • Date: 2012-10-19 10:35:59 UTC
  • mfrom: (3520.32.371 fluidity)
  • Revision ID: simon.mouradian06@imperial.ac.uk-20121019103559-y36qa47phc69q8sc
mergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from mms_rans_p2p1_keps_tools import *
 
2
from numpy import *
 
3
import matplotlib
 
4
import matplotlib.pyplot as plt
 
5
import sys
 
6
 
 
7
'''
 
8
run using:
 
9
python function_printer.py AA BB CC DD .. n_rows
 
10
where:
 
11
        AA, BB, CC, DD are names of functions in mms_rans_p2p1_keps_tools.py (any number can be entered)
 
12
        n_rows is the number of rows to display the functions on
 
13
'''
 
14
 
 
15
functions = []
 
16
for arg in sys.argv[1:-1]:
 
17
    functions.append(arg)
 
18
n_rows = int(sys.argv[-1])
 
19
 
 
20
matplotlib.rcParams['xtick.direction'] = 'out'
 
21
matplotlib.rcParams['ytick.direction'] = 'out'
 
22
plt.subplots_adjust(left=None, bottom=None, right=None, top=None,
 
23
                    wspace=0.2, hspace=0.2)
 
24
   
 
25
res = 50
 
26
X = linspace(0.0, pi, res)
 
27
Y = linspace(0.0, pi, res)
 
28
x = [0,0]
 
29
 
 
30
data = empty([len(functions), res, res])
 
31
for z, function in enumerate(functions):
 
32
    for j, x[0] in enumerate(X):
 
33
        for i, x[1] in enumerate(Y):
 
34
            data[z,i,j] = eval(function + '(x)')
 
35
    plt.subplot(n_rows, len(functions)/n_rows + 1, z+1)
 
36
    CS = plt.contour(X, Y, data[z])
 
37
    plt.clabel(CS, inline=1, fontsize=10)
 
38
    plt.title(functions[z])
 
39
    
 
40
plt.show()