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