Commit c2192172 authored by Martin Drechsler's avatar Martin Drechsler

Scan functions improved

parent a77cf865
......@@ -61,7 +61,6 @@ class anal_control_signal(QWidget):
self.scan_sb_stop = pg.SpinBox(value = 0, bounds=[self.min, self.max], step = self.step, siPrefix = self.siPrefix, suffix = self.suffix)
self.scan_sb_period = pg.SpinBox(value = 1, bounds=[0, 100], step = 0.1, siPrefix = True, suffix = 's')
self.scan_direction = 0
self.scan_button.clicked.connect(self.doScanAction)
......@@ -107,7 +106,6 @@ class anal_control_signal(QWidget):
self.scanLabelValue.setText("%.2f" % self.scan_step + ' V')
except ZeroDivisionError:
self.doScanAction()
#print('Oh dear, you might be trying to scan from 0 to 0. Plase never do that again. ')
show_warning('Oh dear, you might be trying to scan from 0 to 0. Plase never do that again.')
def doScanAction(self):
......@@ -118,16 +116,16 @@ class anal_control_signal(QWidget):
self.scan_button.setText('Start scan')
self.scan_button.setStyleSheet('background-color: None')
self.PbarTimer.stop()
self.sb.setEnabled(True)
self.sb.setValue(self.scan_step)
else:
dt = 5.0e-3
self.scan_array = scanFunctions.create_scan_array(self.scan_sb_start.val, self.scan_sb_stop.val, self.scan_sb_period.val, dt)
first_value = float(self.scan_step)
self.scan_array = scanFunctions.create_scan_array(self.scan_sb_start.val, self.scan_sb_stop.val, self.scan_sb_period.val, first_value,dt)
self.scan_array_gen = scanFunctions.yield_scan_array(self.scan_array)
......
......@@ -10,9 +10,11 @@ Auxiliary functions for performing scans in a cleaner way
import numpy as np
def create_scan_array(scan_start, scan_stop, scan_period, dt):
def create_scan_array(scan_start, scan_stop, scan_period, first_value, dt):
"""
Returns the array that represents one period of the scan, including up and down paths of the triangle.
The first_value param is were the scan actually starts. The scan_start and scan_top give the range.
"""
scan_start = float(scan_start)
scan_stop = float(scan_stop)
......@@ -20,11 +22,13 @@ def create_scan_array(scan_start, scan_stop, scan_period, dt):
number_of_points = 1 + (scan_period+dt)//(2*dt)
scan_array = np.linspace(scan_start, scan_stop, int(number_of_points))
scan_array = np.concatenate((scan_array, np.flip(scan_array, 0)[1:]))
starting_index = np.abs(scan_array-first_value).argmin()+1
scan_array = np.roll(scan_array, starting_index)
return np.concatenate((scan_array, np.flip(scan_array, 0)[1:]))
return scan_array
def yield_array(arr):
def _yield_array(arr):
larr = len(arr)
cursor = 0
while cursor < larr:
......@@ -34,8 +38,16 @@ def yield_array(arr):
def yield_scan_array(arr):
while True:
yield from yield_array(arr)
yield from _yield_array(arr)
#%%
#scan_start = 0
#scan_stop = 1
#scan_period = 1
#first_value = .6
#dt = 0.1
#
#a = create_scan_array(scan_start, scan_stop, scan_period, first_value, dt)
#print(a)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment