forked from python-hydro/pyro2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotvar.py
More file actions
executable file
·54 lines (33 loc) · 1.26 KB
/
Copy pathplotvar.py
File metadata and controls
executable file
·54 lines (33 loc) · 1.26 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
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
import argparse
import mesh.patch as patch
# plot a single variable from an output file
#
# Usage: ./plotvar.py filename variable
def makeplot(plotfile, variable, outfile):
myg, myd = patch.read(plotfile)
plt.figure(num=1, figsize=(6.5,5.25), dpi=100, facecolor='w')
var = myd.get_var(variable)
img = plt.imshow(np.transpose(var.v()),
interpolation="nearest", origin="lower",
extent=[myg.xmin, myg.xmax, myg.ymin, myg.ymax])
plt.colorbar()
plt.xlabel("x")
plt.ylabel("y")
plt.savefig(outfile, bbox_inches="tight")
plt.show()
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("-o", type=str, default="plot.png",
metavar="plot.png", help="output file name")
parser.add_argument("plotfile", type=str, nargs=1,
help="the plotfile you wish to plot")
parser.add_argument("variable", type=str, nargs=1,
help="the name of the solver used to run the simulation")
args = parser.parse_args()
return args
if __name__== "__main__":
args = get_args()
makeplot(args.plotfile[0], args.variable[0], args.o)