forked from py1sl/neutron_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfispact_printlib_reader.py
More file actions
72 lines (59 loc) · 2.16 KB
/
fispact_printlib_reader.py
File metadata and controls
72 lines (59 loc) · 2.16 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- coding: utf-8 -*-
"""
Fispact printlib file reader
S Lilley
october 2021
"""
import argparse
import neut_utilities as ut
import pandas as pd
def energy_filter(data, energy):
""" filter emission lines based on energy """
data = data[data["energy_ev"] > energy]
return data
def particle_filter(data, particle):
""" filter emission lines based on emission particle """
data = data[data["particle"] == particle]
return data
def read_fispact_printlib(fpath):
""" processes a fispact printlib file """
averages = []
nucs = []
particle = []
energy = []
intensity = []
in_discrete = False
in_average = False
with open(fpath, 'r') as plf:
for line in plf:
if "fispact run time" in line:
discrete_lines_df = pd.DataFrame()
discrete_lines_df["nuclide"] = nucs
discrete_lines_df["particle"] = particle
discrete_lines_df["energy_ev"] = energy
discrete_lines_df["intensity"] = intensity
break
elif in_discrete:
if ("Type" not in line) and ("no spectral data" not in line):
if line[2] != " ":
cur_nuc = line[2:8]
cur_nuc = cur_nuc.replace(" ", "")
nucs.append(cur_nuc)
part = line[25:34]
part = ut.string_cleaner(part)
particle.append(part)
energy.append(float(line[43:54]))
intensity.append(float(line[71:82]))
elif " FD " in line:
in_average = False
in_discrete = True
elif in_average:
averages.append(line)
elif "A V E R A G E S" in line:
in_average = True
return discrete_lines_df
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="reads Fispact printlib file")
parser.add_argument("input", help="path to the fispact printlib file")
args = parser.parse_args()
read_fispact_printlib(args.input)