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
b4d26024
Commit
b4d26024
authored
Jul 24, 2018
by
Peter Jansweijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated tic_gui to comply with v1.1 electrical absolute calibration document
parent
fff94100
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
65 deletions
+82
-65
tic_gui.py
sw/ab_cal_scripts/tic_gui.py
+82
-65
No files found.
sw/ab_cal_scripts/tic_gui.py
View file @
b4d26024
...
@@ -22,20 +22,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
...
@@ -22,20 +22,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
This script calculates the differences between:
This script calculates the differences between:
- the time measured on the Time Interval Counter for PPS ->
Tx/Rx-timestamp
- the time measured on the Time Interval Counter for PPS ->
abscal_txts
- the time stamped by the WR device (t1/t4) that was outputted on the WR GUI
- the time stamped by the WR device (t1/t4) that was outputted on the WR GUI
while running the absolute calibration software.
while running the absolute calibration software.
Measuremen
rs should be taken while the WR device is in GrandMaster mode
Measuremen
ts should be taken while the WR device is in mode abscal
('mode gm') and locked to an external 10 MHz reference. Measur
ments are started
and locked to an external 10 MHz reference. Measure
ments are started
after the 'ptp start' command
after the 'ptp start' command
The same reference clock mentioned above should also have been used for the
The same reference clock mentioned above should also have been used for the
Time Interval Counter measurement!
Time Interval Counter measurement!
Usage:
Usage:
tic_gui.py <tic_file> <wr_gui_file>
<meas_type>
tic_gui.py <tic_file> <wr_gui_file>
tic_gui.py <tic_file> <"tic">
tic_gui.py <tic_file> <"tic">
tic_gui.py <wr_gui_file> <"t1_4">
tic_gui.py -h | --help
tic_gui.py -h | --help
<tic_file> <type 'str'> file name that contains the Time Interval
<tic_file> <type 'str'> file name that contains the Time Interval
...
@@ -43,11 +44,10 @@ Usage:
...
@@ -43,11 +44,10 @@ Usage:
<wr_gui_file> <type 'str'> name of file containing the Time Interval
<wr_gui_file> <type 'str'> name of file containing the Time Interval
measurements between pps_o and either tx_ts or rx_ts output
measurements between pps_o and either tx_ts or rx_ts output
<meas_type> <type 'str'> either
<meas_type> <type 'str'> either
"
t1" -> (measured TIC for PPS/Tx-ts) - (WR_GUI t1)
"
" -> (measured TIC for PPS->abscal_txts) - (WR_GUI t1) and
"t4" -> (measured TIC for PPS/Rx-ts) - (WR_GUI t4)
(measured TIC for PPS->abscal_txts) - (WR_GUI t4p)
"t1_4" -> (WR_GUI t4) - (WR_GUI t1)
"t1_4" -> (WR_GUI t4) - (WR_GUI t1)
"tic" -> histogram just the time interval measurements
"tic" -> histogram just the time interval measurements
Options:
Options:
-h --help Show this screen.
-h --help Show this screen.
--version Show version.
--version Show version.
...
@@ -57,6 +57,7 @@ import os
...
@@ -57,6 +57,7 @@ import os
import
sys
import
sys
import
time
import
time
import
struct
import
struct
import
pdb
#TJP: installed from web python-vxi Alex
#TJP: installed from web python-vxi Alex
import
vxi11
import
vxi11
...
@@ -132,76 +133,29 @@ def wr_abs_cal_gui_file_to_scipy_array(filename):
...
@@ -132,76 +133,29 @@ def wr_abs_cal_gui_file_to_scipy_array(filename):
return
gui_data
return
gui_data
############################################################################
############################################################################
##
## If run from commandline, we can test the library
##
if
__name__
==
"__main__"
:
arguments
=
docopt
(
__doc__
,
version
=
'Keysight DSO-S 254A version 01'
)
tic_file
=
sys
.
argv
[
1
]
if
len
(
sys
.
argv
)
==
3
and
sys
.
argv
[
2
]
==
"tic"
:
tic_data
=
tic
.
file_to_scipy_array
(
tic_file
)
num
=
len
(
tic_data
[
0
])
# x-axis in [0]
t_hist
=
tic_data
[
1
]
# y-axis in [1]
hist_tic
=
plt
.
figure
(
"Time Interval Counter skew"
)
elif
len
(
sys
.
argv
)
!=
4
:
print
(
"### wrong number of input arguments"
)
sys
.
exit
()
else
:
wr_gui_file
=
sys
.
argv
[
2
]
src
=
sys
.
argv
[
3
]
if
src
==
"t1"
:
ts_output
=
"tx_ts"
elif
src
==
"t4"
:
ts_output
=
"rx_ts"
elif
src
==
"t1_4"
:
ts_output
=
""
else
:
print
(
"### wrong timestamp source"
)
sys
.
exit
()
gui_data
=
wr_abs_cal_gui_file_to_scipy_array
(
wr_gui_file
)
if
src
==
"t1_4"
:
def
plot_hist
(
t_hist
,
hist_tic
):
t_hist
=
gui_data
[
"t4"
]
-
gui_data
[
"t1"
]
"""
num
=
len
(
gui_data
[
"t1"
])
plot a histrogram
print
(
"Delay between internal timestamp t1 and t4 (i.e. t4-t1):"
)
hist_tic
=
plt
.
figure
(
"Historam difference WR (t4-t1)"
)
t_hist -- <numpy.array> data to be histogrammed
else
:
hist_tic -- <class 'matplotlib.figure.Figure'> pointer to histogram plot object
tic_data
=
tic
.
file_to_scipy_array
(
tic_file
)
returns
num_tic
=
len
(
tic_data
[
0
])
# x-axis in [0]
"""
num_gui
=
len
(
gui_data
[
src
])
num
=
min
(
num_tic
,
num_gui
)
print
(
"Measurements found in 53230A file:"
,
num_tic
,
"in WR_GUI file:"
,
num_gui
)
print
(
"Measurements to take into account:"
,
num
)
print
(
"Delay between internal timestamp "
+
src
+
" to "
+
ts_output
+
":"
)
fig
=
plt
.
figure
(
"Time Interval Counter measurements and WR GUI "
+
src
+
" versus measurment number"
)
ax
=
fig
.
add_subplot
(
111
)
ax
.
set_xlabel
(
'measurement number'
)
ax
.
set_ylabel
(
'TIC value, WR '
+
src
)
x
=
tic_data
[
0
][:
num
]
ax
.
plot
(
x
,
tic_data
[
1
][:
num
])
ax
.
plot
(
x
,
gui_data
[
src
][:
num
])
plt
.
draw
()
t_hist
=
tic_data
[
1
][:
num
]
-
gui_data
[
src
][:
num
]
hist_tic
=
plt
.
figure
(
"Historam difference (pps->ts) - WR "
+
src
)
mean_delay
=
numpy
.
mean
(
t_hist
)
mean_delay
=
numpy
.
mean
(
t_hist
)
max_delay
=
numpy
.
max
(
t_hist
)
max_delay
=
numpy
.
max
(
t_hist
)
min_delay
=
numpy
.
min
(
t_hist
)
min_delay
=
numpy
.
min
(
t_hist
)
stdev_delay
=
numpy
.
std
(
t_hist
,
ddof
=
1
)
stdev_delay
=
numpy
.
std
(
t_hist
,
ddof
=
1
)
print
(
"number of measurements:"
,
num
)
print
(
"number of measurements:"
,
num
)
print
(
"mean:"
,
mean_delay
)
print
(
"mean:"
,
mean_delay
)
print
(
"max:"
,
max_delay
)
print
(
"max:"
,
max_delay
)
print
(
"min:"
,
min_delay
)
print
(
"min:"
,
min_delay
)
print
(
"width:"
,
max_delay
-
min_delay
)
print
(
"width:"
,
max_delay
-
min_delay
)
print
(
"st-dev:"
,
stdev_delay
)
print
(
"st-dev:"
,
stdev_delay
)
ax
=
hist_tic
.
add_subplot
(
111
)
ax
=
hist_tic
.
add_subplot
(
111
)
ax
.
set_xlabel
(
'Time'
)
ax
.
set_xlabel
(
'Time'
)
ax
.
set_ylabel
(
'Count'
)
ax
.
set_ylabel
(
'Count'
)
...
@@ -211,6 +165,69 @@ if __name__ == "__main__":
...
@@ -211,6 +165,69 @@ if __name__ == "__main__":
ax
.
text
(
0.01
,
0.80
,
'min = {0:.6g}'
.
format
(
min_delay
),
transform
=
ax
.
transAxes
)
ax
.
text
(
0.01
,
0.80
,
'min = {0:.6g}'
.
format
(
min_delay
),
transform
=
ax
.
transAxes
)
ax
.
text
(
0.01
,
0.75
,
'n = {0:d}'
.
format
(
num
),
transform
=
ax
.
transAxes
)
ax
.
text
(
0.01
,
0.75
,
'n = {0:d}'
.
format
(
num
),
transform
=
ax
.
transAxes
)
ax
.
hist
(
t_hist
,
bins
=
20
)
ax
.
hist
(
t_hist
,
bins
=
20
)
return
############################################################################
##
## If run from commandline, we can test the library
##
if
__name__
==
"__main__"
:
arguments
=
docopt
(
__doc__
,
version
=
'Keysight DSO-S 254A version 01'
)
if
len
(
sys
.
argv
)
!=
3
:
print
(
"### wrong number of input arguments"
)
sys
.
exit
()
elif
sys
.
argv
[
2
]
==
"tic"
:
print
(
"Time Interval Counter skew"
)
tic_file
=
sys
.
argv
[
1
]
tic_data
=
tic
.
file_to_scipy_array
(
tic_file
)
num
=
len
(
tic_data
[
0
])
# x-axis in [0]
t_hist
=
tic_data
[
1
]
# y-axis in [1]
hist_tic
=
plt
.
figure
(
"Time Interval Counter skew"
)
plot_hist
(
t_hist
,
hist_tic
)
elif
sys
.
argv
[
2
]
==
"t1_4"
:
wr_gui_file
=
sys
.
argv
[
1
]
gui_data
=
wr_abs_cal_gui_file_to_scipy_array
(
wr_gui_file
)
print
(
"Histogram difference WR (t4p-t1)"
)
t_hist
=
gui_data
[
"t4"
]
-
gui_data
[
"t1"
]
num
=
len
(
gui_data
[
"t1"
])
print
(
"Delay between internal timestamp t1 and t4 (i.e. t4-t1):"
)
hist_tic
=
plt
.
figure
(
"Histogram difference WR (t4-t1)"
)
plot_hist
(
t_hist
,
hist_tic
)
else
:
tic_file
=
sys
.
argv
[
1
]
tic_data
=
tic
.
file_to_scipy_array
(
tic_file
)
wr_gui_file
=
sys
.
argv
[
2
]
gui_data
=
wr_abs_cal_gui_file_to_scipy_array
(
wr_gui_file
)
num_tic
=
len
(
tic_data
[
0
])
# x-axis in [0]
num_gui
=
len
(
gui_data
[
"t1"
])
num
=
min
(
num_tic
,
num_gui
)
print
(
"Measurements found in 53230A file:"
,
num_tic
,
"in WR_GUI file:"
,
num_gui
)
print
(
"Measurements to take into account:"
,
num
)
print
(
"Delay between abscal_txts and internal timestamp t1 and t4p:"
)
fig
=
plt
.
figure
(
"Time Interval Counter measurements and WR GUI t1, t4p versus measurment number"
)
ax
=
fig
.
add_subplot
(
111
)
ax
.
set_xlabel
(
'measurement number'
)
ax
.
set_ylabel
(
'TIC value, WR t1'
)
x
=
tic_data
[
0
][:
num
]
lns1
=
ax
.
plot
(
x
,
gui_data
[
"t1"
][:
num
],
color
=
'red'
,
label
=
'WR GUI t1'
)
lns2
=
ax
.
plot
(
x
,
gui_data
[
"t4"
][:
num
],
color
=
'purple'
,
label
=
'WR GUI t4p'
)
lns3
=
ax
.
plot
(
x
,
tic_data
[
1
][:
num
],
color
=
'blue'
,
label
=
'TIC'
)
lns
=
lns1
+
lns2
+
lns3
labels
=
[
l
.
get_label
()
for
l
in
lns
]
ax
.
legend
(
lns
,
labels
,
loc
=
'lower right'
,
fontsize
=
'medium'
)
plt
.
draw
()
t_hist_t1
=
tic_data
[
1
][:
num
]
-
gui_data
[
"t1"
][:
num
]
hist_tic_t1
=
plt
.
figure
(
"Historam TIC(pps->abscal_txts) - t1"
)
t_hist_t4p
=
tic_data
[
1
][:
num
]
-
gui_data
[
"t4"
][:
num
]
hist_tic_t4p
=
plt
.
figure
(
"Historam TIC(pps->abscal_txts) - t4p"
)
plot_hist
(
t_hist_t1
,
hist_tic_t1
)
plot_hist
(
t_hist_t4p
,
hist_tic_t4p
)
plt
.
show
()
plt
.
show
()
sys
.
exit
()
sys
.
exit
()
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