Lorentzian fits
[1]:
import nexus as nx
import numpy as np
import matplotlib.pyplot as plt
load a reference spectrum
[2]:
intensity = np.loadtxt('Fe_alpha_spectrum_wide.txt')
plt.plot(intensity)
plt.show()
Calibrate experimental data
[3]:
v = 8.3
shift = 0.0
velocities, offset, scaling, vel_theo, int_theo = nx.data.CalibrateChannelsAlphaFe(
intensity = intensity,
velocity= v,
thickness = 10e3,
Bhf = 33,
B_fwhm = 0,
emission = False,
mode = "constant",
shift = shift)
print("offset: {}".format(offset))
print("scaling: {}".format(scaling))
print("max velocity in experiment: {}".format(v*scaling))
offset: 0.29844467432932387
scaling: 0.9640092539880852
max velocity in experiment: 8.001276808101109
Get all Lorentzian parameters
[4]:
n_lor, indices_lor, velocity_lor, intensities_lor, widths_lor, areas_lor, baseline_lor, fit_curve = nx.data.GetLorentzian(
velocities,
intensity,
n=6,
neg=True,
baseline=None
)
print(n_lor)
print(indices_lor)
print(velocity_lor)
print(intensities_lor)
print(widths_lor)
print(areas_lor)
print(baseline_lor)
plt.plot(velocities, intensity)
plt.plot(velocities, fit_curve)
plt.show()
6
[ 96 166 237 292 363 433]
[-5.32343661 -3.07623348 -0.84988943 0.84587101 3.08106968 5.32568563]
[-980.29961236 -936.81445391 -742.80437577 -741.84551569 -921.26441169
-976.35410283]
[0.70463913 0.46580674 0.271412 0.25158578 0.45156303 0.66741383]
[2170.0785944 1370.91089519 633.36398958 586.33988414 1306.93065309
2047.16303298]
6150.561289921998
Get just the linewidth of each peak
[5]:
widths = nx.data.GetLinewidths(velocities, intensity, n=6, neg=True)
print(widths)
[0.70463913 0.46580674 0.271412 0.25158578 0.45156303 0.66741383]
Get the processed areas of each peak
[6]:
folded_areas, area_ratio = nx.data.GetAreas(velocities,
intensity,
n=6,
neg=True,
norm = "min")
print(folded_areas)
print(area_ratio)
[4217.24162738 2677.84154828 1219.70387372]
[3.45759468 2.19548499 1. ]