-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_plots.py
More file actions
220 lines (166 loc) · 10.8 KB
/
create_plots.py
File metadata and controls
220 lines (166 loc) · 10.8 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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
"""Plots to illustrate Kramers Kronig relations"""
import sys
import matplotlib.pyplot as plt
import numpy as np
import core_functions
"""Set text sizes"""
SMALL_SIZE = 8
MEDIUM_SIZE = 10
BIGGER_SIZE = 12
plt.rc('font', size=SMALL_SIZE) # controls default text sizes
plt.rc('axes', titlesize=SMALL_SIZE) # fontsize of the axes title
plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels
plt.rc('xtick', labelsize=SMALL_SIZE) # fontsize of the tick labels
plt.rc('ytick', labelsize=SMALL_SIZE) # fontsize of the tick labels
plt.rc('legend', fontsize=SMALL_SIZE) # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title
def get_inds(energy, start_eV, end_eV):
start_ind = np.argmin(np.abs(energy-start_eV))
end_ind = np.argmin(np.abs(energy-end_eV))
return(start_ind,end_ind)
if __name__ == "__main__":
"""Henke data from https://henke.lbl.gov/optical_constants/"""
path='sample_data/Fe.nff' # Henke data
sf = core_functions.parse_data(path, remove_first_line=True)
ind_0 = 100
energy_Fe = sf[:,0][ind_0:]
f_p_Fe = sf[:,1][ind_0:]
f_dp_Fe = sf[:,2][ind_0:]
energy_interp,f_p_pred,_,_,f_in = core_functions.get_f_p(energy_Fe, f_dp_Fe, padn=5000,
trim=24500,
Z = 26, # atomic number
include_Z_term=True,
window_type='cosine',
)
start_eV = 500
end_eV = 25000
start_ind,end_ind = get_inds(energy_Fe, start_eV, end_eV)
start_ind_interp,end_ind_interp = get_inds(energy_interp, energy_Fe[start_ind], energy_Fe[end_ind])
plt.figure()
plt.plot(energy_Fe[start_ind:end_ind],f_dp_Fe[start_ind:end_ind],linewidth=2,label='Table Value')
plt.savefig('plots/henke_f_dp.png',dpi=300, pad_inches=0.0)
plt.figure()
plt.plot(energy_Fe[start_ind:end_ind],f_p_Fe[start_ind:end_ind],linewidth=2,label='Table Value')
plt.plot(energy_interp[start_ind_interp:end_ind_interp],
f_p_pred[start_ind_interp:end_ind_interp],linewidth=2, label='Computed from Kramers Kronig')
plt.legend()
plt.savefig('plots/henke_f_p.png',dpi=300, pad_inches=0.0)
"""Reproduction of Fig 1 in Sauter (2020), https://doi.org/10.1107/S2059798320000418"""
start_eV = 7070
end_eV = 7170
path='sample_data/Fe_fake.dat' # Henke data
sf_fe_0 = core_functions.parse_data(path, remove_first_line=False)
start_ind_fe_0, end_ind_fe_0 = get_inds(sf_fe_0[:,0], start_eV, end_eV)
path='sample_data/pf-rd-red_fftkk.out'
sf_fe_2 = core_functions.parse_data(path)
start_ind_fe_2, end_ind_fe_2 = get_inds(sf_fe_2[:,0], start_eV, end_eV)
path = 'sample_data/pf-rd-ox_fftkk.out'
sf_fe_3 = core_functions.parse_data(path)
start_ind_fe_3, end_ind_fe_3 = get_inds(sf_fe_3[:,0], start_eV, end_eV)
plt.figure()
plt.plot(sf_fe_0[:,0][start_ind_fe_0:end_ind_fe_0],sf_fe_0[:,2][start_ind_fe_0:end_ind_fe_0],'m', label="Fe0")
plt.plot(sf_fe_2[:,0][start_ind_fe_2:end_ind_fe_2],sf_fe_2[:,2][start_ind_fe_2:end_ind_fe_2],'r', label="Fe2+")
plt.plot(sf_fe_3[:,0][start_ind_fe_3:end_ind_fe_3],sf_fe_3[:,2][start_ind_fe_3:end_ind_fe_3],'b', label="Fe3+")
plt.legend()
plt.savefig('plots/sherrell_f_dp.png',dpi=300, pad_inches=0.0)
plt.figure()
plt.plot(sf_fe_0[:,0][start_ind_fe_0:end_ind_fe_0],sf_fe_0[:,1][start_ind_fe_0:end_ind_fe_0],'m', label="Fe0")
plt.plot(sf_fe_2[:,0][start_ind_fe_2:end_ind_fe_2],sf_fe_2[:,1][start_ind_fe_2:end_ind_fe_2],'r', label="Fe2+")
plt.plot(sf_fe_3[:,0][start_ind_fe_3:end_ind_fe_3],sf_fe_3[:,1][start_ind_fe_3:end_ind_fe_3],'b', label="Fe3+")
plt.ylim([-8.5, -2.5])
plt.legend()
plt.savefig('plots/sherrell_f_p.png',dpi=300, pad_inches=0.0)
"""Previous plot overlaid with calculated f_p from Kramers Kronig"""
padn = 5000
window_type = 'cosine'
trim = 6000
path='sample_data/Fe.dat'
sf = core_functions.parse_data(path, remove_first_line=False)
known_response_energy=sf[:,0]
known_response_f_p=sf[:,1]
known_response_f_dp=sf[:,2]
energy_interp_0,f_p_pred_0,_,_,_ = core_functions.get_f_p(sf_fe_0[:,0],sf_fe_0[:,2],
trim=trim,
padn=padn,
Z=26, # atomic number
include_Z_term=False,
window_type=window_type,
known_response_energy=known_response_energy,
known_response_f_p=known_response_f_p,
known_response_f_dp=known_response_f_dp,
)
start_ind_fe_interp_0, end_ind_fe_interp_0 = get_inds(energy_interp_0, start_eV, end_eV)
energy_interp_2,f_p_pred_2,_,_,_ = core_functions.get_f_p(sf_fe_2[:,0],sf_fe_2[:,2],
trim=trim,
padn=padn,
Z = 26, # atomic number
include_Z_term=False,
window_type=window_type,
known_response_energy=known_response_energy,
known_response_f_p=known_response_f_p,
known_response_f_dp=known_response_f_dp,
)
start_ind_fe_interp_2, end_ind_fe_interp_2 = get_inds(energy_interp_2, start_eV, end_eV)
energy_interp_3,f_p_pred_3,_,_,_ = core_functions.get_f_p(sf_fe_3[:,0],sf_fe_3[:,2],
trim=trim,
padn=padn,
Z = 26, # atomic number
include_Z_term=False,
window_type=window_type,
known_response_energy=known_response_energy,
known_response_f_p=known_response_f_p,
known_response_f_dp=known_response_f_dp,
)
start_ind_fe_interp_3, end_ind_fe_interp_3 = get_inds(energy_interp_3, start_eV, end_eV)
plt.figure()
plt.plot(sf_fe_0[:,0][start_ind_fe_0:end_ind_fe_0],sf_fe_0[:,1][start_ind_fe_0:end_ind_fe_0],'m', label="Fe0")
plt.plot(sf_fe_2[:,0][start_ind_fe_2:end_ind_fe_2],sf_fe_2[:,1][start_ind_fe_2:end_ind_fe_2],'r', label="Fe2+")
plt.plot(sf_fe_3[:,0][start_ind_fe_3:end_ind_fe_3],sf_fe_3[:,1][start_ind_fe_3:end_ind_fe_3],'b', label="Fe3+")
plt.plot(energy_interp_0[start_ind_fe_interp_0:end_ind_fe_interp_0],f_p_pred_0[start_ind_fe_interp_0:end_ind_fe_interp_0],'m--', label="Fe0 calculated")
plt.plot(energy_interp_2[start_ind_fe_interp_2:end_ind_fe_interp_2],f_p_pred_2[start_ind_fe_interp_2:end_ind_fe_interp_2],'r--', label="Fe2+ calculated")
plt.plot(energy_interp_3[start_ind_fe_interp_3:end_ind_fe_interp_3],f_p_pred_3[start_ind_fe_interp_3:end_ind_fe_interp_3],'b--', label="Fe3+ calculated")
# plt.ylim([-8.5, -2.5])
plt.legend()
plt.savefig('plots/sherrell_f_p_overlaid.png',dpi=300, pad_inches=0.0)
"""How does estimate for f_p change with different window LENGTHS for the range 7070-7170eV"""
start_eV = 7070
end_eV = 7170
energy = sf_fe_2[:,0]
start_ind, end_ind = get_inds(energy, start_eV, end_eV)
energy = energy[start_ind:end_ind]
f_p = sf_fe_2[:,1][start_ind:end_ind]
f_dp = sf_fe_2[:,2][start_ind:end_ind]
padn_vec = np.arange(0,5)
padn_vec = 10**padn_vec
plt.figure()
for padn in padn_vec:
energy_interp,f_p_pred,_,_,_ = core_functions.get_f_p(energy,f_dp,
trim=0,
padn=padn,
Z = 26, # atomic number
include_Z_term=False,
window_type='cosine',
known_response_energy=known_response_energy,
known_response_f_p=known_response_f_p,
known_response_f_dp=known_response_f_dp,
)
plt.plot(energy_interp,f_p_pred,label=str(padn))
plt.legend()
plt.savefig('plots/f_p_window_lengths.png',dpi=300, pad_inches=0.0)
"""How does estimate for f_p change with different window TYPES for the range 7070-7170eV"""
window_vec = ['boxcar', 'triang', 'blackman', 'hamming', 'cosine', 'tukey']
plt.figure()
for window_type in window_vec:
energy_interp,f_p_pred,_,_,_ = core_functions.get_f_p(energy,f_dp,
trim=0,
padn=5000,
Z = 26, # atomic number
include_Z_term=False,
window_type=window_type,
known_response_energy=known_response_energy,
known_response_f_p=known_response_f_p,
known_response_f_dp=known_response_f_dp,
)
plt.plot(energy_interp,f_p_pred,label=window_type)
plt.legend()
plt.savefig('plots/f_p_window_types.png',dpi=300, pad_inches=0.0)