Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
total_control_app
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Drechsler
total_control_app
Commits
c2192172
Commit
c2192172
authored
Oct 27, 2018
by
Martin Drechsler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scan functions improved
parent
a77cf865
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
13 deletions
+23
-13
myWidgets.py
myWidgets.py
+4
-6
scanFunctions.py
scanFunctions.py
+19
-7
No files found.
myWidgets.py
View file @
c2192172
...
...
@@ -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
(
"
%.2
f"
%
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
)
...
...
scanFunctions.py
View file @
c2192172
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment