Professional Documents
Culture Documents
Figure 1. Emission lines from (a) Argon source, (b) Mercury-Neon sources, (c) Merged Argon
and Mercury-Neon source and (d) Selected top 15 emission lines for the merged Argon and
Mercury sources.
The dark noise spectrum was subtracted from the combined spectral data in order to remove and
minimize the contributions of the possible dead pixels or the stray light. The chosen spectral
lines were analyzed in terms of pixels and their respective “true wavelengths” computed using
the spectral source emission line table
Table 2. Selected data point and their respective spectral analysis
The average of the difference between the true wavelength and USB650 wavelength was
determined using the expression
∑(True value − USB650 value)
Mean wavelength =
n
Mean wavelength = 3.7355
From table 2, the true wavelength and USB650 wavelength have a linear relationship with the
pixel number. A comparison between these wavelengths was graphically determined as shown
in Figure 2.
The correlation coefficient (r) between th
e two wavelengths and their average slop
e (∆y) was determined using a programm
ed routine
r = 0.987229248
Slope: 1.0076052
Figure 2. Comparison between the true wavelength and the USB650 wavelength.
The relationship between pixel number and wavelength was determined using an n-degree
polynomial.
The polynomial takes the form;
λ(p) = α1 p + α2 p2 + α3 p3 + ⋯ αn pn + b
Figure 3. Regression models (a) the scatter plot, (b) the linear model, (c) the quadratic model
and (d) the 3rd order polynomial, LUT mapping pixel to wavelength.
The polynomial of degree three which take on the form,
λ(p) = α1 p + α2 p2 + α3 p3 + b
had the best prediction of the of the wavelengths with the R2 = 0.98863 = 98.8663%
Table 4. The difference between true wavelength and predicted wavelength
True Predicted True wavelength-
wavelength[nm] wavelength[nm] Predicted wavelength
435.835 445.3081 9.473066
546.074 555.3081 9.234066
546.074 556.3081 10.23407
696.543 649.3081 -47.2349
751.765 760.3081 8.543066
763.51 772.3081 8.798066
763.51 773.3081 9.798066
763.51 774.3081 10.79807
772.421 781.3081 8.887066
772.421 782.3081 9.887066
801.479 810.3081 8.829066
811.531 820.3081 8.777066
811.531 821.3081 9.777066
842.531 851.3081 8.777066
912.297 921.3081 9.011066
The average of the difference between the true wavelength and predicted wavelength was
determined using the expression
∑(True wavelength − Predicted wavelength)
Mean wavelenght =
n
Mean wavelength = 5.5726
4. CONCLUSION
USB650 spectrometer spectral calibration was performed using Argon and Mercury-Neon
emission line lamps. The best fitting results for the calibration process was determined using
regression models. Polynomial regression of degree three proved to be more accurate
compared with quadratic and linear regression models. The level of accuracy of the models
increased with the number of degrees of the polynomial. Therefore, more accurate results may
be obtained with a higher order polynomial. Some uncertainties as realized between the
predicted wavelengths and the true wavelength. This may be due to the presence of stray light
or dead pixels that affect the emission lines, non-uniform illumination system. Also the
temperature variation of the emission sources were considered in the analysis. If these factors
are considered and a uniform illumination source used in calibration process, repeatability will
be achieved.
APPENDIX
###CYRIL OTIENO.
#1. plotting the sppectral lines and top 15 points selection
import matplotlib.pyplot as plt
import pandas as pd
var = pd.read_excel("C:/Users/Cyril/Desktop/Radiomery.xlsx")
x = list(var["wave"])
y = list(var["Argon"])
p = list(var["HgNe"])
fig, ax = plt.subplots()
ax.plot(x,y,'-b')
ax.set(xlabel = "Wavelength", ylabel = "Intensity", title = "Argon Spectrum")
ax.grid()
fig1, ax1 = plt.subplots()
ax1.plot(x, p, linewidth = 1, color = "r")
ax1.set(xlabel = "Wavelength", ylabel = "Intensity", title = "HgNe Spectrum")
ax1.grid()
plt.show()
fig2, ax2 = plt.subplots()
ax2.plot(x, y, linewidth = 1, color = "r",)
ax2.plot(x, p, linewidth = 1, color = "b")
ax2.set(xlabel = "Wavelength", ylabel = "Intensity", title = "HgNe+Argon")
ax2.grid()
plt.show()
fig3, ax3 = plt.subplots()
plt.ylim(960,3700)
ax3.plot(x, y, linewidth = 1, color = "r",marker ="*", markerfacecolor = "g", markersize = 10)
ax3.plot(x, p, linewidth = 1, color = "b",marker ="*", markerfacecolor = "g", markersize = 10)
ax3.set(xlabel = "Wavelength", ylabel = "Intensity", title = "HgNe+Argon")
ax3.grid()
plt.show()
#2.
x = np.array(var["True wavelength"]).reshape((-1,1))
y = np.array(var["Pixel"])
z = np.array(var["USB 650 wavelength"])
model = LinearRegression().fit(x, y)
r_sq = model.score(x,y)
print(f"coeficient correlation:{r_sq}")
print(f"intercept:{model.intercept_}")
print(f"slope:{model.coef_}")
plt.axes(ylabel = "Wavelength[nm]", xlabel = "Pixel")
plt.grid()
plt.title("Wavelength Comparison", size = 10)
plt.plot(x, y, c ="r", linewidth = 2, linestyle = "", marker =".", markerfacecolor = "r", markersize =
20)
plt.plot(z, y,c="b", linewidth = 2, linestyle = "--", marker =".", markerfacecolor = "b", markersize =
15)
plt.show()
#3.REGRESSION CODE
####1.Linear model
from sklearn.linear_model import LinearRegression
x = np.array(var["True wavelength"]).reshape((-1,1))
y = np.array(var["Pixel"])
model = LinearRegression().fit(x, y)
r_sq = model.score(x,y)
print(f"coeficient of determination:{r_sq}")
print(f"intercept:{model.intercept_}")
print(f"slope:{model.coef_}")
print(f"coefficient: {model.coef_}")
y_pred = model.intercept_ + model.coef_* x
print(f"predicted response:\n{y_pred}")
plt.axes(ylabel = "True Wavelength[nm]", xlabel = "Pixel")
plt.grid()
plt.title("Linear Model", size = 10)
plt.scatter(y,x, c="b")
plt.plot(y_predicted,x, c="b", linewidth = 2, linestyle = "--", marker =".", markerfacecolor = "b",
markersize = 15)
"""coeficient of determination:0.9872292488619414
intercept:-357.30806635425597
slope:[1.0076052]
coefficient: [1.0076052]"""
####2.Quadratic model
from sklearn.preprocessing import PolynomialFeatures
x = np.array(var["True wavelength"]).reshape((-1,1))
y = np.array(var["Pixel"])
transformer = PolynomialFeatures(degree = 2, include_bias = False)
transformer.fit(x)
x_ = transformer.transform (x)
model = LinearRegression().fit(x_, y)
r_sq = model.score(x_,y)
print(f"coeficient of determination:{r_sq}")
print(f"intercept:{model.intercept_}")
print(f"coefficients: {model.coef_}")
y_pred = model.intercept_ + model.coef_* x
print(f"predicted response:\n{y_pred}")
plt.axes(ylabel = "True Wavelength[nm]", xlabel = "Pixel")
plt.grid()
plt.title("Quadratic Model", size = 10)
plt.scatter(y,x, c="b")
plt.plot(y_predicted,x, c="b", linewidth = 2, linestyle = "--", marker =".", markerfacecolor = "b",
markersize = 15)
plt.show()
"""coeficient of determination:0.9883917498443353
intercept:-246.23997641984965
coefficients: [6.58207821e-01 2.62572015e-04]"""
####3.polunomial of orde 3
x = np.array(var["True wavelength"]).reshape((-1,1))
y = np.array(var["Pixel"])
transformer = PolynomialFeatures(degree = 3, include_bias = False)
transformer.fit(x)
x_ = transformer.transform (x)
model = LinearRegression().fit(x_, y)
r_sq = model.score(x_,y)
print(f"coeficient of determination:{r_sq}")
print(f"coefficients: {model.coef_}")
print(f"intercept:{model.intercept_}")
y_pred = model.intercept_ + model.coef_* x
print(f"predicted response:\n{y_pred}")
plt.axes(ylabel = "True Wavelength[nm]", xlabel = "Pixel")
plt.title("3rd Order Polynomial", size = 10)
plt.grid()
plt.scatter(y,x,c = "b")
plt.plot(y_predicted,x, c="b", linewidth = 2, linestyle = "--", marker =".", markerfacecolor = "b",
markersize = 20)
plt.show()
"""coeficient of determination:0.9886328304815492
coefficients: [-4.46579929e-01 1.91513730e-03 -8.01620492e-07]
intercept:-8.601640995575451"""
REFERENCES
[6] S. R. D. H. K. &. K. M. Kalidindi, " Spectral calibration of crystal plasticity models. Acta
Materialia," vol. 54(7), pp. 1795-1804, 2006.