summaryrefslogtreecommitdiff
path: root/tutorials/module_4/spectroscopy_problem/spectroscopy.py
blob: f32ca529b7e2cf9aadc95f05a54adec3316b1af1 (plain)
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Nov  5 12:58:59 2025

@author: christian
"""


"""
Problem:

- Import xls data into Python
- Plot the Intensity [a.u.]  vs pixels
- 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**")
"""

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt


Hg_data = 'Lampa_Calibrare_Mercur.xlsx'
#Ar_data = 'Spectru Descarcare Argon.xlsx'
Ox_data = 'Calibrare Intensitate Oxigen.xlsx'

df_Hg = pd.read_excel(Hg_data, header=11, engine='openpyxl')
df_Ox = pd.read_excel(Ox_data, header=3, engine='openpyxl')
#df_Ar = pd.read_excel(Ar_data, header=14, engine='openpyxl')


# Trims mercury data to the first 2000 pixels
df_Hg = df_Hg[df_Hg['Pixels']<2000]


"Plot Intensity vs Pixels for mercury"

# Plot Hg intensity-pixel plot
plt.figure(figsize=(8,5))
plt.plot(df_Hg['Pixels'], df_Hg['Intensity'], linestyle='-')
plt.xlabel('Pixels')
plt.ylabel('Intensity [a.u.]')
plt.title('Pixel-Intensity (Hg)')
plt.grid(True)
plt.show()


"Calibrate length dimension"
np.polyfit(df_Hg['Pixels'],df_Hg['Intensity'],3)

"Calibrate intensity dimension"
epsilon = # Surface emissivity
lambd =

I_W_true = epsilon*((2hc**2)/(lambd**5)*1/(e**(hc/kT)-1))
I_W_meas= df_Ox['I_Tungsten [a.u.]']
R=I_W_meas/I_W_true
I_plasma_meas=R*I_plasma_true