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). Default: %default")
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 behaveGroup.add_option("--implementation",
39 default=None,
40 dest="implementation",
41 help="The implementation that should be used for plotting")
42
43 self.parser.add_option_group(behaveGroup)
44
45 writeDGroup=OptionGroup(self.parser,
46 "Write plot data",
47 "How data and the plots themself should be written to disk")
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 writeDGroup.add_option("--prefix-hardcopy",
62 action="store",
63 default=None,
64 dest="hardcopyPrefix",
65 help="Prefix for the hardcopy-files")
66
67 writeDGroup.add_option("--no-pickled-file",
68 action="store_false",
69 default=True,
70 dest="writePickled",
71 help="Do not write a pickled file with the plot data")
72
73 self.parser.add_option_group(writeDGroup)
74
75 plotItGroup=OptionGroup(self.parser,
76 "What to plot",
77 "Predefined quantities that the program looks for and plots")
78 plotItGroup.add_option("--no-default",
79 action="store_true",
80 default=False,
81 dest="nodefault",
82 help="Switch off the default plots (linear, continuity and bound)")
83 plotItGroup.add_option("--no-linear",
84 action="store_false",
85 default=True,
86 dest="linear",
87 help="Don't plot the linear solver convergence")
88 plotItGroup.add_option("--no-continuity",
89 action="store_false",
90 default=True,
91 dest="cont",
92 help="Don't plot the continuity info")
93 plotItGroup.add_option("--no-bound",
94 action="store_false",
95 default=True,
96 dest="bound",
97 help="Don't plot the bounding of variables")
98 plotItGroup.add_option("--with-iterations",
99 action="store_true",
100 default=False,
101 dest="iterations",
102 help="Plot the number of iterations of the linear solver")
103 plotItGroup.add_option("--with-courant",
104 action="store_true",
105 default=False,
106 dest="courant",
107 help="Plot the courant-numbers of the flow")
108 plotItGroup.add_option("--with-execution",
109 action="store_true",
110 default=False,
111 dest="execution",
112 help="Plot the execution time of each time-step")
113 plotItGroup.add_option("--with-deltat",
114 action="store_true",
115 default=False,
116 dest="deltaT",
117 help="'Plot the timestep-size time-step")
118 plotItGroup.add_option("--with-all",
119 action="store_true",
120 default=False,
121 dest="withAll",
122 help="Switch all possible plots on")
123 self.parser.add_option_group(plotItGroup)
124
126 if self.opts.nodefault:
127 self.opts.linear=False
128 self.opts.cont=False
129 self.opts.bound=False
130
131 if self.opts.withAll:
132 self.opts.linear=True
133 self.opts.cont=True
134 self.opts.bound=True
135 self.opts.iterations=True
136 self.opts.courant=True
137 self.opts.execution=True
138 self.opts.deltaT=True
139