-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathImporters.py
93 lines (76 loc) · 2.23 KB
/
Importers.py
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import os
import numpy as np
class RichertImport():
def __init__(self, path):
"""
Initiates the controller and loads the data from the given path.
Parameters
----------
path : string
Path where the folder containing the data is located.
Returns
-------
None.
"""
self.path = path
def get_Data(self):
"""
Method that loads the needed data from the given folder path for the
Controller object.
Returns
-------
lambdas_filename : string
DESCRIPTION.
delays_filename : string
DESCRIPTION.
spectra_filename : string
DESCRIPTION.
"""
file_paths = []
content = os.listdir(self.path)
for file in content:
file_paths.append(f'{self.path}/{file}')
for i in file_paths:
if "lambda" in i or "field" in i:
new = i[:-3] + "txt"
os.rename(i, new)
lambdas_filename = new
elif "delays" in i or "time" in i:
new = i[:-3] + "txt"
os.rename(i, new)
delays_filename = new
elif "taspectra" in i or "eprspectra" in i:
new = i[:-3] + "txt"
os.rename(i, new)
spectra_filename = new
return lambdas_filename, delays_filename, spectra_filename
class RichertOKEImport():
def __init__(self, path):
"""
Initiates the controller and loads the data from the given path.
Parameters
----------
path : string
The path of the file containing the data.
Returns
-------
None.
"""
self.path = path
def readData(self):
"""
Reads the data
Returns
-------
data : np.ndarray
The measurment data.
"""
data = np.genfromtxt(self.path, delimiter=' ', skip_header=self.header)
return data
def splitData(self, data):
wave = data[0][1:]
time = data.T[0][1:] * 100
time = time.round() / 100
spec = data[1:]
spec = spec.T[1:]
return wave, time, spec