Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Calibration
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Calibration
Commits
5acdc522
Commit
5acdc522
authored
Feb 27, 2017
by
Peter Jansweijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added output directory choice to Keysight_DSO_S_254A.py
parent
d80c7ce7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
9 deletions
+20
-9
Keysight_DSO_S_254A.py
sw/lib/Keysight_DSO_S_254A.py
+20
-9
No files found.
sw/lib/Keysight_DSO_S_254A.py
View file @
5acdc522
...
...
@@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
-------------------------------------------------------------------------------
Usage:
Keysight_DSO_S_254A.py <IP#> [-c<1,2,3,4>] [-a<averages>]
Keysight_DSO_S_254A.py <IP#> [-c<1,2,3,4>] [-a<averages>]
[-o=<dir>]
Keysight_DSO_S_254A.py -h | --help
IP IP number of the Oscilloscope
...
...
@@ -33,10 +33,12 @@ Options:
--version Show version.
-c<1,2,3,4> channel number
-a number of averages [default: 1]
-o=<dir> optional directory for output file storage [default: "data/"]
"""
from
docopt
import
docopt
import
os
import
sys
import
time
import
scipy
...
...
@@ -58,7 +60,7 @@ def get_sweeps(scope, chan_str):
############################################################################
def
get_waveforms
(
scope
,
channels
=
[
1
,
2
,
3
,
4
],
num_avg
=
1
):
def
get_waveforms
(
scope
,
channels
=
[
1
,
2
,
3
,
4
],
num_avg
=
1
,
output_dir
=
"data"
):
"""
Measure and save Keysight DSO-S 254A waveforms
...
...
@@ -66,6 +68,7 @@ def get_waveforms(scope, channels=[1,2,3,4], num_avg=1):
scope -- instance of python-vxi connected to the oscilloscope
channels -- channels that are going to be measured for example '1,2'
num_avg -- the number of averiges taken by the oscilloscope
output_dir -- name of the directory where measured waveform files wil be stored
the file output format is as described below:
...
...
@@ -141,7 +144,13 @@ def get_waveforms(scope, channels=[1,2,3,4], num_avg=1):
for
i
in
range
(
len
(
channel_data
)):
data
.
append
(
channel_data
[
i
])
filename
=
"data/"
+
time
.
strftime
(
format
(
"
%
y
%
m
%
d_
%
H_
%
M_
%
S"
),
timestamp
)
+
"_scope_keysight_dso_s_254A_bin"
# add trailing slash if not present
output_dir
=
os
.
path
.
join
(
output_dir
,
''
)
if
os
.
path
.
exists
(
output_dir
)
!=
True
:
os
.
mkdir
(
output_dir
)
print
(
"Output directory does not exist => created: "
+
output_dir
)
filename
=
output_dir
+
time
.
strftime
(
format
(
"
%
y
%
m
%
d_
%
H_
%
M_
%
S"
),
timestamp
)
+
"_scope_keysight_dso_s_254A_bin"
print
(
"save waveform into file:"
,
filename
)
file
=
open
(
filename
,
"w"
)
...
...
@@ -517,7 +526,8 @@ if __name__ == "__main__":
channels
=
'1'
#record_len = 1000
num_avg
=
1
output_dir
=
"data"
if
len
(
sys
.
argv
)
>=
3
:
# There are more arguments...
for
arg_value
in
sys
.
argv
[
2
:]:
if
arg_value
[:
2
]
==
'-c'
:
# set channels
...
...
@@ -528,7 +538,8 @@ if __name__ == "__main__":
# print(record_len)
if
arg_value
[:
2
]
==
'-a'
:
# set number of averages
num_avg
=
int
(
arg_value
[
2
:])
#print(num_avg)
if
option
[
0
]
==
'-o'
:
# set output directory
output_dir
=
option
[
1
]
#print ("channels:",channels, "record length:", record_len, "num_avg", num_avg)
...
...
@@ -537,15 +548,15 @@ if __name__ == "__main__":
# use Channel 3 Ethernet Frame input
# A fixed trigger level (1,4 Volt) is important for proper timing measurement
scope
.
write
(
":TRIGger:LEVel CHANnel1,1.4"
)
scope
.
write
(
":CHANnel1:INPut DCFifty"
)
#
scope.write(":TRIGger:LEVel CHANnel1,1.4")
#
scope.write(":CHANnel1:INPut DCFifty")
# Trigger in the centre of the screen; important for maximum estimations
# forwarded to function average_edge_to_sfd
scope
.
write
(
":TIMebase:DELay 0"
)
#d,filename = get_waveforms(scope, channels, record_len, num_avg)
d
,
filename
=
get_waveforms
(
scope
,
channels
,
num_avg
)
d
,
filename
=
get_waveforms
(
scope
,
channels
,
num_avg
,
output_dir
)
wf_data
=
file_to_waveform
(
filename
)
check_waveforms
(
wf_data
)
...
...
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