-
Notifications
You must be signed in to change notification settings - Fork 11
/
AbstractMCA.py
188 lines (145 loc) · 4.24 KB
/
AbstractMCA.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import abc
from HardwareRepository.TaskUtils import *
class AbstractMCA(object):
__metaclass__ = abc.ABCMeta
def __init__(self):
self.mca = None
self.calib_cf = []
@task
def read_raw_data(self, chmin, chmax):
"""Read the raw data from chmin to chmax
Keyword Args:
chmin (int): channel number, defaults to 0
chmax (int): channel number, defaults to 4095
Returns:
list. Raw data.
"""
pass
@task
def read_roi_data(self):
"""Read the data for the predefined ROI
Returns:
list. Raw data for the predefined ROI channels.
"""
pass
@abc.abstractmethod
@task
def read_data(self, chmin, chmax, calib):
"""Read the data
Keyword Args:
chmin (float): channel number or energy [keV]
chmax (float): channel number or energy [keV]
calib (bool): use calibration, defaults to False
Returns:
numpy.array. x - channels or energy (if calib=True), y - data.
"""
pass
@task
def set_calibration(self, fname=None, calib_cf=[0,1,0]):
"""Set the energy calibration. Give a filename or a list of calibration factors.
Kwargs:
fname (str): optional filename with the calibration factors
calib_cf (list): optional list of calibration factors
Returns:
list. Calibration factors.
Raises:
IOError, ValueError
"""
pass
@abc.abstractmethod
@task
def get_calibration(self):
"""Get the calibration factors list
Returns:
list. Calibration factors.
"""
pass
@task
def set_roi(self, emin, emax, **kwargs):
"""Configure a ROI
Args:
emin (float): energy [keV] or channel number
emax (float): energy [keV] or channel number
Keyword Args:
element (str): element name as in periodic table
atomic_nb (int): element atomic number
channel (int): output connector channel number (1-8)
Returns:
None
Raises:
KeyError
"""
pass
@abc.abstractmethod
@task
def get_roi(self, **kwargs):
"""Get ROI settings
Keyword Args:
channel (int): output connector channel number (1-8)
Returns:
dict. ROI dictionary.
"""
pass
@task
def clear_roi(self, **kwargs):
"""Clear ROI settings
Keyword Args:
channel (int): optional output connector channel number (1-8)
Returns:
None
"""
pass
@task
def get_times(self):
"""Return a dictionary with the preset and elapsed real time [s],
elapsed live time (if possible) [s] and the dead time [%].
Returns:
dict. Times dictionary.
Raises:
RuntimeError
"""
pass
@task
def get_presets(self, **kwargs):
"""Get the preset parameters
Keyword Args:
ctime (float): Real time
erange (int): energy range
fname (str): filename where the data are stored
...
Returns:
dict.
Raises:
RuntimeError
"""
pass
@task
def set_presets(self, **kwargs):
"""Set presets parameters
Keyword Args:
ctime (float): real time [s]
erange (int): the energy range
fname (str): file name (full path) to save the raw data
Returns:
None
"""
pass
@abc.abstractmethod
@task
def start_acq (self, cnt_time=None):
"""Start new acquisition. If cnt_time is not specified, counts for preset real time.
Keyword Args:
cnt_time (float, optional): count time [s]; 0 means to count indefinitely.
Returns:
None
"""
pass
@abc.abstractmethod
@task
def stop_acq (self):
"""Stop the running acquisition"""
pass
@task
def clear_spectrum (self):
"""Clear the acquired spectrum"""
pass