forked from mxcube/HardwareObjects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AbstractMCA.py
189 lines (157 loc) · 4.87 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
import os
import sys
import time
import abc
import logging
from HardwareRepository.TaskUtils import *
"""
set_calibration - set the energy calibration - fname=None, calib_cf=[0,1,0]:
filename with the calibration factors or
list of calibration factors
get_calibration - get the calibration array.
set_presets - preset parametsrs - **kwargs:
ctime - real time [s]
erange - the energy range [keV] - 10:0, 20:1, 40:2, 80:3
clear_spectrum - clear the acquired spectrum
start_acq - start new acquisition - cnt_time=None:
if specifiefied, cnt_time is the count time [s]
stop_acq - stop the running acquisition
set_roi - configure a ROI - emin, emax, **kwargs:
emin - energy [keV] or channel number
emax - energy [keV] or channel number
channel - output conenctor channel number (1-8)
element - element name as in periodic table
atomic_nb - element atomic number
clear_roi - clear ROI settings - **kwargs:
channel - output conenctor channel number (1-8)
get_roi - get ROI settings, return a dictionarry - **kwargs:
channel - output conenctor channel number (1-8)
get_times - return a dictionary with the preset and elapsed real time [s],
elapsed live time (if possible) [s] and the dead time [%]
get_presets - get the preset paramets **kwargs, e.g.:
ctime - real time
erange - energy range
read_data - read the data, return an array
chmin - channel number or energy [keV]
chmax - channel number or energy [keV]
calib - True/False
x - channels or energy (if calib=True)
y - data
read_raw_data - read the data from chmin to chmax, return a list
chmin - channel number
chmax - channel number
read_roi_data - read the data for the configured roi, return a list
"""
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 data from chmin to chmax, return a list
"""
pass
@task
def read_roi_data(self):
"""
Read the data for the configured roi, return a list
"""
pass
@abc.abstractmethod
@task
def read_data(self, chmin, chmax, calib):
"""
read the data, return an array
chmin - channel number or energy [keV]
chmax - channel number or energy [keV]
calib - True/False
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 - filename with the calibration factors or
list of calibration factors
"""
pass
@abc.abstractmethod
@task
def get_calibration(self):
"""
return a list with energy calibration factors
"""
pass
@task
def set_roi(self, emin, emax, **kwargs):
"""
configure a ROI:
emin - energy [keV] or channel number
emax - energy [keV] or channel number
kwargs could be:
channel - output conenctor channel number
element - element name as in periodic table
atomic_nb - element atomic number
"""
pass
@abc.abstractmethod
@task
def get_roi(self, **kwargs):
"""
get ROI settings, return a dictionarry
kwargs could be:
channel - output conenctor channel number
"""
pass
@task
def clear_roi(self, **kwargs):
"""
clear a configured roi. If kwargs it could be:
channel - output conenctor channel number
"""
pass
@task
def get_times(self):
"""
return a dictionary with possibly the preset and elapsed real time [s],
elapsed live time [s], dead time [%]...
"""
pass
@task
def get_presets(self, **kwargs):
"""
get the preset paramets, where kwargs could be:
ctime - real time
erange - energy range ...
"""
pass
@task
def set_presets(self, **kwargs):
"""
set the preset paramets , where kwargs could be:
ctime - real time
erange - energy range ...
"""
pass
@abc.abstractmethod
@task
def start_acq (self, cnt_time=None):
"""
Start new acquisition. If specifiefied, cnt_time is the count time [s]
"""
pass
@abc.abstractmethod
@task
def stop_acq (self):
"""
stop the running acquisition
"""
pass
@task
def clear_spectrum (self):
"""
clear the acquired spectrum
"""
pass