|
@@ -954,7 +954,7 @@ def bk_get_temperature(board_id):
|
|
|
backup_get_temp = bk_get_temperature
|
|
|
|
|
|
|
|
|
-def bk_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_observe=None, orbits_skip=None, bucket_to_use=None):
|
|
|
+def bk_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_observe=None, orbits_skip=None, bucket_to_use=None, threshold_counts=None):
|
|
|
"""
|
|
|
Toggle Timescan.
|
|
|
:param board_id: id of the board do manipulate
|
|
@@ -971,7 +971,7 @@ def bk_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_
|
|
|
if board.get_board_status(board_id).time_scan:
|
|
|
_bif_stop_time_scan(board_id, ts_pbar)
|
|
|
else:
|
|
|
- _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_observe, orbits_skip, bucket_to_use)
|
|
|
+ _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, ts_pbar, plot_func, orbits_observe, orbits_skip, bucket_to_use, threshold_counts)
|
|
|
|
|
|
|
|
|
def _bif_stop_time_scan(board_id, ts_pbar):
|
|
@@ -1000,7 +1000,7 @@ def _bif_stop_time_scan(board_id, ts_pbar):
|
|
|
# thread_ts = None
|
|
|
|
|
|
|
|
|
-def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressbar, plot_func, orbits_observe, orbits_skip, bucket_to_use=None):
|
|
|
+def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressbar, plot_func, orbits_observe, orbits_skip, bucket_to_use=None, threshold_counts=None):
|
|
|
"""
|
|
|
Start the timscan. This starts the timer
|
|
|
:param board_id: id of the board do manipulate
|
|
@@ -1013,6 +1013,7 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
|
|
|
:param orbits_observe: Number of orbits to observe for the timescan (original values will be restored after timescan)
|
|
|
:param orbits_skip: Number of orbits to skip for the timescan (original values will be restored after timescan)
|
|
|
:param bucket_to_use: Number of the bucket whos data will be used to calculate the average signal at each timescan step (if None all bunches will be used)
|
|
|
+ :param threshold_counts: Skip buckets with adc counts between 2048 +- threshold_counts
|
|
|
:return: -
|
|
|
"""
|
|
|
thread = storage.get_board_specific_storage(board_id).setdefault("TimeScanThread", storage.ThreadStorage())
|
|
@@ -1057,7 +1058,7 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
|
|
|
stopSignal = QtCore.pyqtSignal()
|
|
|
finished = QtCore.pyqtSignal()
|
|
|
|
|
|
- def __init__(self, c_frm, c_to, f_frm, f_to, timescan_progressbar, bucket_to_use):
|
|
|
+ def __init__(self, c_frm, c_to, f_frm, f_to, timescan_progressbar, bucket_to_use, threshold_counts):
|
|
|
super(thread_time_scan, self).__init__()
|
|
|
self.c_frm = c_frm
|
|
|
self.c_to = c_to
|
|
@@ -1065,6 +1066,7 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
|
|
|
self.f_to = f_to
|
|
|
self.timescan_progressbar = timescan_progressbar
|
|
|
self.bucket_to_use = bucket_to_use
|
|
|
+ self.threshold_counts = threshold_counts
|
|
|
|
|
|
def time_scan(self):
|
|
|
'''Method to run in the thread that does the timescan'''
|
|
@@ -1132,7 +1134,14 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
|
|
|
|
|
|
for adc in range(4):
|
|
|
if self.bucket_to_use is None:
|
|
|
- buckets = data.array[:, adc]
|
|
|
+ if self.threshold_counts is not None:
|
|
|
+ indexes = np.where(np.logical_or(data.array[:, adc] > 2048+self.threshold_counts, data.array[:, adc] < 2048-self.threshold_counts))[0]
|
|
|
+ if indexes.shape[0] == 0:
|
|
|
+ buckets = data.array[:, adc]
|
|
|
+ else:
|
|
|
+ buckets = data.array[indexes, adc]
|
|
|
+ else:
|
|
|
+ buckets = data.array[:, adc]
|
|
|
else:
|
|
|
buckets = data.array[self.bucket_to_use::config.bunches_per_turn, adc]
|
|
|
heatmap[adc, f_step, c_step] = float(buckets.sum()) / buckets.shape[0]
|
|
@@ -1215,7 +1224,7 @@ def _bif_start_time_scan(board_id, c_frm, c_to, f_frm, f_to, timescan_progressba
|
|
|
|
|
|
return
|
|
|
|
|
|
- tst = thread_time_scan(c_frm, c_to, f_frm, f_to, timescan_progressbar, bucket_to_use)
|
|
|
+ tst = thread_time_scan(c_frm, c_to, f_frm, f_to, timescan_progressbar, bucket_to_use, threshold_counts)
|
|
|
thread.register(tst)
|
|
|
thread.connect('pbarSignal', timescan_progressbar.setValue)
|
|
|
thread.connect('finished', lambda: finished(timescan_progressbar))
|