-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbaseline_correction_tutorial.py
More file actions
39 lines (26 loc) · 1.2 KB
/
Copy pathbaseline_correction_tutorial.py
File metadata and controls
39 lines (26 loc) · 1.2 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
from argparse import ArgumentParser
from matplotlib import pyplot as plt
from data import Data
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('spectrum_dir', help='Path of directory containing all spectra files')
parser.add_argument('-wf', '--weight_file', required=False, help='Path to weight file')
parser.add_argument('-nt', '--num_time', type=int,required=True, help='Number of time runs per run')
args = parser.parse_args()
spectral_data = Data(in_dir=args.spectrum_dir, num_time_points=args.num_time)
for spectrum_id in [0, 1, 2]:
plt.plot(list(range(len(spectral_data.y[:, spectrum_id]))),
spectral_data.y[:, spectrum_id])
plt.title(f'sample id {spectrum_id}')
plt.show()
baseline_configs = {
'lambda_': 1e5,
'stop_ratio': 1e-6,
'max_iters': 10000
}
spectral_data.baseline_correct(method='arpls', configs=baseline_configs)
for spectrum_id in [0, 1, 2]:
plt.plot(list(range(len(spectral_data.y[:, spectrum_id]))),
spectral_data.y[:, spectrum_id], c='red')
plt.title(f'sample id {spectrum_id} corrected')
plt.show()