summaryrefslogtreecommitdiff
path: root/tutorials
diff options
context:
space:
mode:
Diffstat (limited to 'tutorials')
-rw-r--r--tutorials/module_4/Spectroscopy problem.md4
-rw-r--r--tutorials/module_4/spectroscopy_problem/spectroscopy.py27
2 files changed, 18 insertions, 13 deletions
diff --git a/tutorials/module_4/Spectroscopy problem.md b/tutorials/module_4/Spectroscopy problem.md
index 5252d46..29d26f5 100644
--- a/tutorials/module_4/Spectroscopy problem.md
+++ b/tutorials/module_4/Spectroscopy problem.md
@@ -99,7 +99,7 @@ Calibrate wavelength by converting the length dimension from pixels to nm.
$$
\lambda_p=I+C_1p+C_2p^2+C_3p^3
$$
-- Solve for C1 C2 and C3, use $I=195.54$
+- Solve for C1, C2 and C3, use $I=195.54$
Well-known/defined Hg lines:
@@ -154,5 +154,3 @@ $$
$$
n_{1,2}=\frac{\int_{\lambda_0-\Delta\lambda}^{\lambda_0+\Delta\lambda} I(\lambda)d\lambda}{\frac{1}{4\pi}hv_{1,2}A_{1,2}l}\tag{1}
$$
-
-| \ No newline at end of file
diff --git a/tutorials/module_4/spectroscopy_problem/spectroscopy.py b/tutorials/module_4/spectroscopy_problem/spectroscopy.py
index 404e5ca..1ef6579 100644
--- a/tutorials/module_4/spectroscopy_problem/spectroscopy.py
+++ b/tutorials/module_4/spectroscopy_problem/spectroscopy.py
@@ -15,7 +15,7 @@ Problem:
- Interpolate and convert x-axis from pixels to nm (true wavelength) using Hg lamp data (using data in file: **Lampa_Calibrare_Mercur.xlsx**)
- Find response function of the spectrometer using the tungsten lamp data from file: "**Calibrare Intensitate Oxigen.xlsx**)": $R=\frac{I_{measured}}{I_{true}}$ (where True is computed by Planck's law of radiation (see notes in the pptx above)
- Convert y-axis from Intensity [a.u.] into Intensity in [W/(cm^2*sr*nm)] by dividing the measured Oxygen spectrum with the response function: $I_{oxygen, true}=\frac{I_{oxygen, measured}}{R}$
-- Once the spectra is in real units: compute the density of one of the oxygen lines by integrating underneath one of the peaks (see equation from Slide 39 - bottom). We will give all of the constants that are in this equation (see the "I**ntensity_Calibration_Oxygen_Discharge_Solution.xlsx**")
+- Once the spectra is in real units: compute the density of one of the oxygen lines by integrating underneath one of the peaks (see equation from Slide 39 - bottom). We will give all of the constants that are in this equation (see the "Intensity_Calibration_Oxygen_Discharge_Solution.xlsx")
"""
import numpy as np
@@ -118,7 +118,7 @@ I_Ox_measured = df_Ox['I_Plasma Oxygen [a.u.]']-df_Ox['I_Background [a.u.]']
I_Ox_true = R * I_Ox_measured
-# Plot Hg intensity-wavelength plot
+# Plot Hg spectra [a.u.] plot
plt.figure(figsize=(8,5))
plt.plot(wavelength, I_Ox_measured, linestyle='-')
plt.xlabel('Wavelength [$nm$]')
@@ -128,7 +128,7 @@ plt.title('Wavelength-Intensity ($Ox_{measured}$)')
plt.grid(True)
plt.show()
-# Plot Hg intensity-wavelength plot
+# Plot Hg spectra real units plot
plt.figure(figsize=(8,5))
plt.plot(wavelength, I_Ox_true, linestyle='-')
plt.xlabel('Wavelength [$nm$]')
@@ -141,17 +141,24 @@ plt.show()
# %% Calculate Dencity of Ox at upper state
-from scipy.interpolate import interp1d
-from scipy.integrate import quad
+from scipy.integrate import simpson
-# Create an interpolated callable function
-I_Ox_true = interp1d(wavelength, I_Ox_true, kind='linear',
- fill_value=0, bounds_error=False)
+I_Ox_true = I_Ox_true.to_numpy()
-# Now integrate
+# Integrate numerator
delta = 1
peak = 846.5
bound_lower = peak - delta
bound_upper = peak + delta
-numerator, err = quad(I_Ox_true, bound_lower, bound_upper)
+mask = (wavelength >= bound_lower) & (wavelength <= bound_upper)
+wavelength_trimmed = wavelength[mask]
+I_Ox_trimmed = I_Ox_true[mask]
+numerator = simpson(I_Ox_trimmed, wavelength_trimmed)
+
+v = c/(peak*10**(-9))
+A = 3.6e6 # 1/s
+l = 0.015 # m
+
+n = numerator / (1/(4*np.pi)*h*v*A*l)
+