forked from python-hydro/pyro2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
executable file
·74 lines (48 loc) · 1.48 KB
/
Copy pathplot.py
File metadata and controls
executable file
·74 lines (48 loc) · 1.48 KB
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
#!/usr/bin/env python
import numpy
import pylab
import sys
import getopt
import mesh.patch as patch
# plot an output file using the solver's dovis script
def makeplot(myd, solverName, outfile, W, H):
exec 'import ' + solverName + ' as solver'
sim = solver.Simulation(None, None)
sim.cc_data = myd
pylab.figure(num=1, figsize=(W,H), dpi=100, facecolor='w')
sim.dovis()
pylab.savefig(outfile)
pylab.show()
def usage():
usage="""
usage: plot.py [-h] [-o image.png] solver filename
positional arguments:
solver required inputs: solver name
filename required inputs: filename to read from
optional arguments:
-h, --help show this help message and exit
-o image.png output image name. The extension .png will generate a PNG
file, .eps will generate an EPS file (default: plot.png).
-W width width in inches
-H height height in inches
"""
print usage
sys.exit()
if __name__== "__main__":
try: opts, next = getopt.getopt(sys.argv[1:], "o:h:W:H:")
except getopt.GetoptError:
sys.exit("invalid calling sequence")
outfile = "plot.png"
W = 8.0
H = 4.5
for o, a in opts:
if o == "-h": usage()
if o == "-o": outfile = a
if o == "-W": W = float(a)
if o == "-H": H = float(a)
try: solver = next[0]
except: usage()
try: file = next[1]
except: usage()
myg, myd = patch.read(file)
makeplot(myd, solver, outfile, W, H)