-
Notifications
You must be signed in to change notification settings - Fork 0
/
diag_contours.py
83 lines (60 loc) · 2.42 KB
/
diag_contours.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
'''
Created on Apr 06, 2012
@author: Michael Kraus ([email protected])
'''
import argparse
import matplotlib
from vorticity.diagnostics import Diagnostics
class replay(object):
'''
'''
def __init__(self, hdf5_file, nPlot=1, nMax=0, output=False, contours=False):
'''
Constructor
'''
self.diagnostics = Diagnostics(hdf5_file)
if nMax > 0 and nMax < self.diagnostics.nt:
self.nMax = nMax
else:
self.nMax = self.diagnostics.nt
self.nPlot = nPlot
self.plot = PlotVorticity2D(self.diagnostics, output=output)
def run(self):
# for iTime in range(1, self.nMax+1):
for iTime in [5,10,20,30,60]:
if iTime == 0 or iTime % self.nPlot == 0 or iTime == self.nMax:
print(iTime)
self.diagnostics.read_from_hdf5(iTime)
self.diagnostics.update_invariants(iTime)
self.plot.update(iTime, final=(iTime == self.nMax))
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Vorticity Equation Solver in 2D')
parser.add_argument('hdf5_file', metavar='<run.hdf5>', type=str,
help='Run HDF5 File')
parser.add_argument('-np', metavar='i', type=int, default=1,
help='plot every i\'th frame')
parser.add_argument('-nt', metavar='i', type=int, default=0,
help='plot up to i\'th frame')
parser.add_argument('-o', action='store_true', required=False,
help='save plots to file')
parser.add_argument('-c', action='store_true', required=False,
help='plot contours of streaming function in vorticity')
args = parser.parse_args()
print
print("Replay run with " + args.hdf5_file)
print
if args.o == True:
matplotlib.use('AGG')
from vorticity.plot.plot_contours import PlotVorticity2D
pyvp = replay(args.hdf5_file, args.np, args.nt, output=True, contours=args.c)
pyvp.run()
else:
from vorticity.plot.plot_contours import PlotVorticity2D
pyvp = replay(args.hdf5_file, args.np, args.nt, output=False, contours=args.c)
print
input('Hit any key to start replay.')
print
pyvp.run()
print
print("Replay finished.")
print