7import matplotlib.pyplot
as plt
8from matplotlib.ticker
import ScalarFormatter, FuncFormatter
9from matplotlib.backends.backend_pgf
import FigureCanvasPgf
11import exahype2.postprocessing
14preamble =
r"\usepackage{amsmath,amssymb}"
19 "font.family":
"sans-serif",
20 "pgf.texsystem":
"pdflatex",
21 "pgf.preamble": preamble,
25if __name__ ==
"__main__":
26 parser = argparse.ArgumentParser(
27 description=
"ExaHyPE 2 Degrees-of-Freedom-Updates Plotter"
32 help=
"Filename of the file to parse. You can specify multiple files.",
37 help=
"Increase output verbosity",
52 help=
"Label of dataset (optional; if used, you have to add --label/-l after the actual files and you have to embed the labels into hyphens)",
56 "--degrees-of-freedom",
58 help=
"Number of degrees-of-freedom one cell holds.",
62 "-nc",
"--number-of-cells", type=int, help=
"Number of cells.", required=
True
65 "-o",
"--output-file", help=
"Name of output file", default=
"output"
71 choices=[
"png",
"pdf",
"pgf"],
74 args = parser.parse_args()
78 args.label = [f
"Dataset {i+1}" for i
in range(len(args.file))]
81 dof_updates_per_second = []
82 for file, label
in zip(args.file, args.label):
84 performance_data = exahype2.postprocessing.PerformanceData(
85 file_name=file, verbose=args.verbose
87 time_per_time_step_in_seconds = performance_data.time_per_time_step()
88 dof_updates_per_second.append(
89 (args.degrees_of_freedom * args.number_of_cells)
90 / time_per_time_step_in_seconds
97 fig, ax = plt.subplots(figsize=(10, 6))
99 colors = plt.cm.viridis(np.linspace(0, 1, len(labels)))
104 dof_updates_per_second,
113 axis=
"y", linestyle=
"--", alpha=1, linewidth=1, zorder=1
116 plt.xticks(fontsize=15)
117 plt.yticks(fontsize=15)
119 plt.ylabel(
"Degrees of Freedom Updates per Second", fontsize=15)
121 ax.yaxis.set_major_formatter(ScalarFormatter(useMathText=
True))
122 ax.ticklabel_format(axis=
"y", style=
"sci", scilimits=(0, 0))
123 ax.yaxis.get_offset_text().set_fontsize(15)
130 "{} Degrees of Freedom".format(args.number_of_cells * args.degrees_of_freedom),
134 if args.output_format ==
"pdf":
135 plt.savefig(args.output_file +
".pdf", bbox_inches=
"tight", transparent=
False)
136 elif args.output_format ==
"png":
137 plt.savefig(args.output_file +
".png", bbox_inches=
"tight", transparent=
False)
138 elif args.output_format ==
"pgf":
140 fig.patch.set_alpha(0)
141 canvas = FigureCanvasPgf(fig)
143 args.output_file +
".pgf",
147 if args.output_file ==
"output":
149 "default file name output.{} written. Change file name with -o or --output-file".format(