-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathframework_penalty.py
55 lines (43 loc) · 1.3 KB
/
framework_penalty.py
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
55
import math
import sys
import numpy
import h5py
import pandas
from uncertainties import ufloat, UFloat
with h5py.File("./data.h5", mode="r") as data:
cedata = []
for step in [5, 10]:
group = data[f"/serpent/ce/{step}"]
cedata.extend(group["cpuTime"])
hdata = []
for step in [5, 10]:
group = data[f"hybrid/{step}"]
hdata.extend(group["cpuTime"][group["hfFlags"][:]])
framework_time = numpy.multiply(2, data["reference/hybrid/cpuTime"])
cedata = numpy.array(cedata)
hdata = numpy.array(hdata)
times = pandas.Series(
[
ufloat(cedata.mean(), cedata.std()),
ufloat(framework_time.mean(), framework_time.std()),
ufloat(hdata.mean(), hdata.std()),
],
index=["Base", "Depletion", "SFV"],
)
times *= 28 / (60 * 60)
times.name = "Time [CPU h]"
times.index.name = "Case"
penalties = times.copy()
penalties.name = "Penalty"
penalties["Base"] = numpy.nan
penalties["Depletion"] = times["Depletion"] / times["Base"] - 1
penalties["SFV"] = times["SFV"] / times["Depletion"] - 1
frame = pandas.concat([times, penalties], axis="columns")
def prefmt(u) -> float:
if isinstance(u, UFloat):
return u.n
return u
if len(sys.argv) == 1:
print(frame)
else:
frame.applymap(prefmt).to_latex(sys.argv[1], float_format="%.4f", na_rep="-")