-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot_spec.py
More file actions
44 lines (39 loc) · 1.45 KB
/
plot_spec.py
File metadata and controls
44 lines (39 loc) · 1.45 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
#!usr/bin/python
from brukeropusreader import read_file
import matplotlib.pyplot as plt
def file_prop(file_path): #input - file path | return - Key values (name of stored data parameters)
data = read_file(file_path)
return data.keys()
def plot_spec(file_path,multiplier=1,wn=True):
data = read_file(file_path)
if wn: #if input is True(default) - covert unit to nm | if input - False - unit stays cm^-1
x_ = 'Wavenumber (cm^(-1))'
else:
x_ = 'Wavelength (nm)' #x_ and y_ are just name for labels for the x and y axis
if "AB" not in file_prop(file_path): #Checks if file is a reference or sample spectra and loads the required data parameter 'AB' or 'ScRf'
x = data.get_range('ScRf',wavenums=wn)
r = data['ScRf'][0:len(x)]
y = []
for i in r:
a = i*multiplier
y.append(a)
y_ = 'Intensity'
else:
x = data.get_range('AB',wavenums=wn)
r = data['AB'][0:len(x)]
y = []
for i in r:
a = i*multiplier
y.append(a)
y_ = 'Transmittance'
a = file_path.split('/')
name = a[len(a)-2]
plt.plot(x,y,label=name)
plt.xlabel(x_)
plt.ylabel(y_)
plt.legend()
plt.show()
'''
spec = r'NIR-comp-DIFF_REFLECT/PUG-18-5-b_Diff_ref_VTX_NIR_202406041202.0'
plot_spec(spec,'test')
'''