1 """
2 Class that implements common functionality for plotting options
3 """
4
5 from optparse import OptionGroup
6 import string
7
9 """ The class that adds plot options
10 """
11
13 self.persistDefault=persist
14
16 behaveGroup=OptionGroup(self.parser,
17 "Plot Behaviour",
18 "How the plots should behave (most of these options are passed to gnuplot)")
19
20 behaveGroup.add_option("--frequency",
21 type="float",
22 dest="frequency",
23 default=1.,
24 help="The frequency with which output should be generated (in seconds)")
25 behaveGroup.add_option("--persist",
26 action="store_true",
27 dest="persist",
28 default=self.persistDefault,
29 help="Gnuplot windows stay after interrupt")
30 behaveGroup.add_option("--non-persist",
31 action="store_false",
32 dest="persist",
33 help="Gnuplot windows close after interrupt")
34 behaveGroup.add_option("--raise",
35 action="store_true",
36 dest="raiseit",
37 help="Raise the Gnuplot windows after every replot")
38 self.parser.add_option_group(behaveGroup)
39
40 writeDGroup=OptionGroup(self.parser,
41 "Write plot data",
42 "How data and the plots themself should be written to disk")
43 writeDGroup.add_option("--write-files",
44 action="store_true",
45 default=False,
46 dest="writeFiles",
47 help="Writes the parsed data to files")
48 writeDGroup.add_option("--hardcopy",
49 action="store_true",
50 default=False,
51 dest="hardcopy",
52 help="Writes hardcopies of the plot at the end of the run")
53 hcChoices=["postscript","png","pdf","svg","eps"]
54 writeDGroup.add_option("--format-of-hardcopy",
55 type="choice",
56 action="store",
57 default="png",
58 dest="hardcopyformat",
59 choices=hcChoices,
60 help="File-format the hardcopy should be written in (Formats: "+string.join(hcChoices,", ")+") Default: %default")
61
62 self.parser.add_option_group(writeDGroup)
63
64 plotItGroup=OptionGroup(self.parser,
65 "What to plot",
66 "Predefined quantities that the program looks for and plots")
67 plotItGroup.add_option("--no-default",
68 action="store_true",
69 default=False,
70 dest="nodefault",
71 help="Switch off the default plots (linear, continuity and bound)")
72 plotItGroup.add_option("--no-linear",
73 action="store_false",
74 default=True,
75 dest="linear",
76 help="Don't plot the linear solver convergence")
77 plotItGroup.add_option("--no-continuity",
78 action="store_false",
79 default=True,
80 dest="cont",
81 help="Don't plot the continuity info")
82 plotItGroup.add_option("--no-bound",
83 action="store_false",
84 default=True,
85 dest="bound",
86 help="Don't plot the bounding of variables")
87 plotItGroup.add_option("--with-iterations",
88 action="store_true",
89 default=False,
90 dest="iterations",
91 help="Plot the number of iterations of the linear solver")
92 plotItGroup.add_option("--with-courant",
93 action="store_true",
94 default=False,
95 dest="courant",
96 help="Plot the courant-numbers of the flow")
97 plotItGroup.add_option("--with-execution",
98 action="store_true",
99 default=False,
100 dest="execution",
101 help="Plot the execution time of each time-step")
102 plotItGroup.add_option("--with-deltat",
103 action="store_true",
104 default=False,
105 dest="deltaT",
106 help="'Plot the timestep-size time-step")
107 plotItGroup.add_option("--with-all",
108 action="store_true",
109 default=False,
110 dest="withAll",
111 help="Switch all possible plots on")
112 self.parser.add_option_group(plotItGroup)
113
115 if self.opts.nodefault:
116 self.opts.linear=False
117 self.opts.cont=False
118 self.opts.bound=False
119
120 if self.opts.withAll:
121 self.opts.linear=True
122 self.opts.cont=True
123 self.opts.bound=True
124 self.opts.iterations=True
125 self.opts.courant=True
126 self.opts.execution=True
127 self.opts.deltaT=True
128