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
Show 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/>
-------------------------------------------------------------------------------
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
while running the absolute calibration software.
Measuremen
rs should be taken while the WR device is in GrandMaster mode
('mode gm') and locked to an external 10 MHz reference. Measur
ments are started
Measuremen
ts should be taken while the WR device is in mode abscal
and locked to an external 10 MHz reference. Measure
ments are started
after the 'ptp start' command
The same reference clock mentioned above should also have been used for the
Time Interval Counter measurement!
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 <wr_gui_file> <"t1_4">
tic_gui.py -h | --help
<tic_file> <type 'str'> file name that contains the Time Interval
...
...
@@ -43,11 +44,10 @@ Usage:
<wr_gui_file> <type 'str'> name of file containing the Time Interval
measurements between pps_o and either tx_ts or rx_ts output
<meas_type> <type 'str'> either
"
t1" -> (measured TIC for PPS/Tx-ts) - (WR_GUI t1)
"t4" -> (measured TIC for PPS/Rx-ts) - (WR_GUI t4)
"
" -> (measured TIC for PPS->abscal_txts) - (WR_GUI t1) and
(measured TIC for PPS->abscal_txts) - (WR_GUI t4p)
"t1_4" -> (WR_GUI t4) - (WR_GUI t1)
"tic" -> histogram just the time interval measurements
Options:
-h --help Show this screen.
--version Show version.
...
...
@@ -57,6 +57,7 @@ import os
import
sys
import
time
import
struct
import
pdb
#TJP: installed from web python-vxi Alex
import
vxi11
...
...
@@ -131,6 +132,41 @@ def wr_abs_cal_gui_file_to_scipy_array(filename):
return
gui_data
############################################################################
def
plot_hist
(
t_hist
,
hist_tic
):
"""
plot a histrogram
t_hist -- <numpy.array> data to be histogrammed
hist_tic -- <class 'matplotlib.figure.Figure'> pointer to histogram plot object
returns
"""
mean_delay
=
numpy
.
mean
(
t_hist
)
max_delay
=
numpy
.
max
(
t_hist
)
min_delay
=
numpy
.
min
(
t_hist
)
stdev_delay
=
numpy
.
std
(
t_hist
,
ddof
=
1
)
print
(
"number of measurements:"
,
num
)
print
(
"mean:"
,
mean_delay
)
print
(
"max:"
,
max_delay
)
print
(
"min:"
,
min_delay
)
print
(
"width:"
,
max_delay
-
min_delay
)
print
(
"st-dev:"
,
stdev_delay
)
ax
=
hist_tic
.
add_subplot
(
111
)
ax
.
set_xlabel
(
'Time'
)
ax
.
set_ylabel
(
'Count'
)
ax
.
text
(
0.01
,
0.95
,
'mean = {0:.6g}'
.
format
(
mean_delay
),
transform
=
ax
.
transAxes
)
ax
.
text
(
0.01
,
0.90
,
'std = {0:.6g}'
.
format
(
stdev_delay
),
transform
=
ax
.
transAxes
)
ax
.
text
(
0.01
,
0.85
,
'max = {0:.6g}'
.
format
(
max_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
.
hist
(
t_hist
,
bins
=
20
)
return
############################################################################
##
## If run from commandline, we can test the library
...
...
@@ -139,78 +175,59 @@ 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
]
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
()
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
)
if
src
==
"t1_4"
:
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
(
"Historam difference WR (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
[
src
])
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 internal timestamp "
+
src
+
" to "
+
ts_output
+
"
:"
)
print
(
"Delay between abscal_txts and internal timestamp t1 and t4p
:"
)
fig
=
plt
.
figure
(
"Time Interval Counter measurements and WR GUI "
+
src
+
"
versus measurment number"
)
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 '
+
src
)
ax
.
set_ylabel
(
'TIC value, WR t1'
)
x
=
tic_data
[
0
][:
num
]
ax
.
plot
(
x
,
tic_data
[
1
][:
num
])
ax
.
plot
(
x
,
gui_data
[
src
][:
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
=
tic_data
[
1
][:
num
]
-
gui_data
[
src
][:
num
]
hist_tic
=
plt
.
figure
(
"Historam difference (pps->ts) - WR "
+
src
)
mean_delay
=
numpy
.
mean
(
t_hist
)
max_delay
=
numpy
.
max
(
t_hist
)
min_delay
=
numpy
.
min
(
t_hist
)
stdev_delay
=
numpy
.
std
(
t_hist
,
ddof
=
1
)
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"
)
print
(
"number of measurements:"
,
num
)
print
(
"mean:"
,
mean_delay
)
print
(
"max:"
,
max_delay
)
print
(
"min:"
,
min_delay
)
print
(
"width:"
,
max_delay
-
min_delay
)
print
(
"st-dev:"
,
stdev_delay
)
plot_hist
(
t_hist_t1
,
hist_tic_t1
)
plot_hist
(
t_hist_t4p
,
hist_tic_t4p
)
ax
=
hist_tic
.
add_subplot
(
111
)
ax
.
set_xlabel
(
'Time'
)
ax
.
set_ylabel
(
'Count'
)
ax
.
text
(
0.01
,
0.95
,
'mean = {0:.6g}'
.
format
(
mean_delay
),
transform
=
ax
.
transAxes
)
ax
.
text
(
0.01
,
0.90
,
'std = {0:.6g}'
.
format
(
stdev_delay
),
transform
=
ax
.
transAxes
)
ax
.
text
(
0.01
,
0.85
,
'max = {0:.6g}'
.
format
(
max_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
.
hist
(
t_hist
,
bins
=
20
)
plt
.
show
()
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