forked from Pocar-Lab/SPE-Analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMeasurementInfo.py
207 lines (171 loc) · 5.64 KB
/
MeasurementInfo.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 19 22:11:30 2022
@author: lab-341
"""
from os.path import exists
# holds the meta data for any given measurement
class MeasurementInfo:
def __init__(self):
self._selftrig_path = None
self._solicit_path = None
self._selftrig_savedir = None
self._solicit_savedir = None
self._condition = None
self._date = None
self._temperature = None
self._spe_a = None
self._spe_b = None
self._bias = None
self._spe_guess = None
self._which_spes = None
self._baseline_numbins = None
self._peaks_numbins = None
self._saved_to_csv = None
self._peak_search_params = None
self._min_alpha_value = None
self._data_type = None
@property
def selftrig_path(self):
return self._selftrig_path
@selftrig_path.setter
def selftrig_path(self, p):
if not isinstance(p, str):
raise TypeError('Path must be a string')
self._selftrig_path = p
@property
def solicit_path(self):
return self._solicit_path
@solicit_path.setter
def solicit_path(self, p):
if not isinstance(p, str):
raise TypeError('Path must be a string')
self._solicit_path = p
@property
def selftrig_savedir(self):
return self._selftrig_savedir
@selftrig_savedir.setter
def selftrig_savedir(self, d):
if not isinstance(d, str):
raise TypeError('Save dir must be a string')
self._selftrig_savedir = d
@property
def solicit_savedir(self):
return self._solicit_savedir
@solicit_savedir.setter
def solicit_savedir(self, d):
if not isinstance(d, str):
raise TypeError('Save dir must be a string')
self._solicit_savedir = d
@property
def condition(self):
return self._condition
@condition.setter
def condition(self, c):
if not isinstance(c, str):
raise TypeError('Condition must be a string')
self._condition = c
@property
def date(self):
return self._date
@date.setter
def date(self, d):
if not isinstance(d, str):
raise TypeError('Date must be a string')
self._date = d
@property
def temperature(self):
return self._temperature
@temperature.setter
def temperature(self, t):
self._temperature = t
@property
def spe_a(self):
return self._spe_a
@spe_a.setter
def spe_a(self, a):
self._spe_a = a
@property
def spe_b(self):
return self._spe_b
@spe_b.setter
def spe_b(self, b):
self._spe_b = b
@property
def bias(self):
return self._bias
@bias.setter
def bias(self, b):
self._bias = b
@property
def min_alpha_value(self):
return self._min_alpha_value
@min_alpha_value.setter
def min_alpha_value(self, m):
self._min_alpha_value = m
@property
def spe_guess(self):
if not self._spe_a:
raise ValueError('Must set spe_a to estimate spe')
if not self._spe_b:
raise ValueError('Must set spe_b to estimate spe')
if not self._bias:
raise ValueError('Must set bias to estimate spe')
self._spe_guess = self._spe_estimate(self._bias, self._spe_a, self._spe_b)
return self._spe_guess
def _spe_estimate(self, bias, a, b):
return a * bias + b
@property
def which_spes(self):
return self._which_spes
@which_spes.setter
def which_spes(self, w):
if not isinstance(w, list):
raise TypeError('which_spes must be a list')
else:
for item in w:
if not isinstance(item, bool):
raise TypeError('which_spes values must be a bool')
self._which_spes = w
@property
def baseline_numbins(self):
return self._baseline_numbins
@baseline_numbins.setter
def baseline_numbins(self, n):
if not isinstance(n, int):
raise TypeError('baseline_numbins must be a int')
self._baseline_numbins = n
@property
def peaks_numbins(self):
return self._peaks_numbins
@peaks_numbins.setter
def peaks_numbins(self, n):
if not isinstance(n, int):
raise TypeError('peaks_numbins must be a int')
self._peaks_numbins = n
@property
def saved_to_csv(self):
if not self._selftrig_savedir:
raise ValueError('Must supply selftrig_savedir')
if not self._solicit_savedir:
raise ValueError('Must supply selftrig_savedir')
selftrig_exists = exists(self._selftrig_savedir)
solicit_exists = exists(self._solicit_savedir)
self._saved_to_csv = selftrig_exists and solicit_exists
return self._saved_to_csv
@property
def peak_search_params(self):
return self._peak_search_params
@peak_search_params.setter
def peak_search_params(self, p):
if not isinstance(p, dict):
raise TypeError('peak_search_params must be a dict')
self._peak_search_params = p
@property
def data_type(self):
return self._data_type
@data_type.setter
def data_type(self, d):
if not isinstance(d, str):
raise TypeError('Data type must be a string')
self._data_type = d