-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcross_sections_hignette.py
142 lines (120 loc) · 4.16 KB
/
cross_sections_hignette.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import numpy
from srxraylib.plot.gol import plot, plot_table, plot_show
from orangecontrib.xoppy.util.xoppy_xraylib_util import cross_calc_mix
energy = numpy.linspace(1.0, 300.0, 100) # in keV
density = 1.0
descriptor = "SiO2"
icalculate = 0
iunit = 3
descriptors = [
"C",
"SiO2",
"B4C",
"Al2O3",
"PbO"
]
densities = [
2.26,
2.65,
2.52,
3.95,
9.53,
]
calculate = [
"0: total cross section",
"1: photoelectric cross section",
"2: rayleigh cross serction",
"3: compton cross section",
"4: total minus raileigh cross section",
]
unit = [
"0: barn/atom (Cross Section calculation)",
"1: cm^2 (Cross Section calculation)",
"2: cm^2/g (Mass Attenuation Coefficient)",
"3: cm^-1 (Linear Attenuation Coefficient)",
]
"""
:param parse_or_nist: 0 for compound (default), 1 for name in the NIST compound list
:param density: the material density in g/cm^3
"""
# #
# # cross sections
# #
# out = numpy.zeros((5,energy.size))
# for i,descriptor in enumerate(descriptors):
# density = densities[i]
# for icalc in range(5):
# out[icalc,:] = cross_calc_mix(descriptor,1000*energy,calculate=icalc,unit=iunit,parse_or_nist=0,density=density)
#
#
# plot_table(energy,out,xlog=True,ylog=True,
# xtitle="Photon energy [kev]",ytitle=" %s"%(unit[iunit]),
# title="Material: %s, density=%f"%(descriptor,density),
# legend=calculate,legend_position=(0.98,0.98),
# show=False,
# )
# #
# # ratio compton/total
# #
# out = numpy.zeros((len(descriptors),energy.size))
# for i,descriptor in enumerate(descriptors):
# density = densities[i]
# out[i,:] = \
# cross_calc_mix(descriptor,1000*energy,calculate=3,unit=iunit,parse_or_nist=0,density=density) \
# / cross_calc_mix(descriptor,1000*energy,calculate=0,unit=iunit,parse_or_nist=0,density=density)
#
# plot_table(energy,out,xlog=True,ylog=True,
# xtitle="Photon energy [kev]",ytitle=" %s"%(unit[iunit]),
# title="Ratio Compton/Total",
# legend=descriptors,legend_position=(0.98,0.98),
# show=False,
# )
#
# ratio compton/totalPbO
#
out = numpy.zeros((len(descriptors),energy.size))
for i,descriptor in enumerate(descriptors):
density = densities[i]
out[i,:] = \
cross_calc_mix(descriptor,1000*energy,calculate=3,unit=iunit,parse_or_nist=0,density=density) \
/ \
cross_calc_mix("SiO2",1000*energy,calculate=0,unit=iunit,parse_or_nist=0,density=2.65)
plot_table(energy,out,xlog=True,ylog=False,
xtitle="Photon energy [kev]",ytitle=" %s"%(unit[iunit]),
title="Ratio Compton/TotalSiO2",
legend=descriptors,legend_position=(0.98,0.98),
show=False,
)
# #
# # ratio elastic/total
# #
# out = numpy.zeros((len(descriptors),energy.size))
# for i,descriptor in enumerate(descriptors):
# density = densities[i]
# out[i,:] = \
# cross_calc_mix(descriptor,1000*energy,calculate=2,unit=iunit,parse_or_nist=0,density=density) \
# / cross_calc_mix(descriptor,1000*energy,calculate=0,unit=iunit,parse_or_nist=0,density=density)
#
# plot_table(energy,out,xlog=True,ylog=True,
# xtitle="Photon energy [kev]",ytitle=" %s"%(unit[iunit]),
# title="Ratio Elastic/Total",
# legend=descriptors,legend_position=(0.98,0.98),
# show=False,
# )
# #
# # ratio photoelectric/total
# #
# out = numpy.zeros((len(descriptors),energy.size))
# for i,descriptor in enumerate(descriptors):
# density = densities[i]
# out[i,:] = \
# cross_calc_mix(descriptor,1000*energy,calculate=1,unit=iunit,parse_or_nist=0,density=density) \
# / cross_calc_mix(descriptor,1000*energy,calculate=0,unit=iunit,parse_or_nist=0,density=density)
#
# plot_table(energy,out,xlog=True,ylog=True,
# xtitle="Photon energy [kev]",ytitle=" %s"%(unit[iunit]),
# title="Ratio photoelectric/Total",
# legend=descriptors,legend_position=(0.98,0.98),
# show=False,
# )
plot_show()