Commit b4d26024 authored by Peter Jansweijer's avatar Peter Jansweijer

updated tic_gui to comply with v1.1 electrical absolute calibration document

parent fff94100
......@@ -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.
Measuremenrs should be taken while the WR device is in GrandMaster mode
('mode gm') and locked to an external 10 MHz reference. Measurments are started
Measurements should be taken while the WR device is in mode abscal
and locked to an external 10 MHz reference. Measurements 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
......@@ -132,76 +133,29 @@ def wr_abs_cal_gui_file_to_scipy_array(filename):
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":
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)")
else:
tic_data = tic.file_to_scipy_array(tic_file)
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)
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')
......@@ -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.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
##
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()
sys.exit()
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