-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyse.py
More file actions
54 lines (39 loc) · 1.69 KB
/
Copy pathanalyse.py
File metadata and controls
54 lines (39 loc) · 1.69 KB
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
import argparse
from pathlib import Path
import json
from typing import Optional
import numpy as np
def create_prop_matrix_from_output(file_path: Path, prop: Optional[str] = "atoms", sorted_by: Optional[str] = "atoms", ntop: Optional[int] = 20) -> np.array:
# we just take the top 20 nuclides by atoms per timestep
# and construct a 3-d tensor for this.
# nrofrows = 20, nrofcols = len(timesteps), nrofz = 3
output_content = file_path.read_text()
data = json.loads(output_content)
inv_data = data['inventory_data']
result = np.zeros(shape=(ntop, len(inv_data), 3))
for j, timestep in enumerate(inv_data):
nuclides = timestep['nuclides']
irrad_time = timestep['irradiation_time']
cool_time = timestep['cooling_time']
total_time = irrad_time + cool_time
sorted_nuclides = sorted(nuclides, key=lambda x: x[sorted_by])
top_nuclides = sorted_nuclides[:ntop]
result[:len(top_nuclides), j, 0] = [ x[prop] for x in top_nuclides ]
result[:len(top_nuclides), j, 1] = [ x['zai'] for x in top_nuclides ]
result[:, j, 2] = total_time
return result
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--results")
args = parser.parse_args()
results_content = Path(args.results).read_text()
results = json.loads(results_content)
test_suites = results.keys()
for test_suite in test_suites:
for k, v in results[test_suite].items():
if not v["has_failure"]:
out_file = Path(v["json_file"])
matrix = create_prop_matrix_from_output(out_file, prop="atoms")
print(matrix)
if __name__ == '__main__':
main()