Commit 633a7db6 authored by Peter Jansweijer's avatar Peter Jansweijer

renamed and get rid of GUI

parent cb941b31
#!/usr/bin/python
"""
tic_gui: Analyzes Time Interval Count Measurements and White Rabbit Abslolute
Calibration GUI output
tic_wr: Analyzes Time Interval Count Measurements and White Rabbit Absolute
Calibration GUI/console output
-------------------------------------------------------------------------------
Copyright (C) 2016 Peter Jansweijer
......@@ -23,8 +23,8 @@ 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 -> abscal_txts
- the time stamped by the WR device (t1/t4) that was outputted on the WR GUI
while running the absolute calibration software.
- the time stamped by the WR device (t1/t4p) that was outputted on the WR
GUI/console while running the absolute calibration software.
Measurements should be taken while the WR device is in mode abscal
and locked to an external 10 MHz reference. Measurements are started
......@@ -34,19 +34,19 @@ The same reference clock mentioned above should also have been used for the
Time Interval Counter measurement!
Usage:
tic_gui.py <tic_file> <wrgui_file>
tic_gui.py <tic_file> -type 'tic'
tic_gui.py <wrgui_file> -type 't1_4'
tic_gui.py -h | --help
tic_wr.py <tic_file> <wr_file>
tic_wr.py <tic_file> -type 'tic'
tic_wr.py <wr_file> -type 't1_4'
tic_wr.py -h | --help
Options:
<tic_file> <type 'str'> file name that contains the Time Interval Counter
measurements between PPS output and either abscal_txts ouput
<wrgui_file> <type 'str'> name of file containing the WR GUI t1, t4p measurments
measurements between PPS output and either abscal_txts output
<wr_file> <type 'str'> name of file containing the WR GUI/console t1, t4p measurements
<-type> <type 'str'> either
"" -> (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)
"" -> (measured TIC for PPS->abscal_txts) - (WR t1) and
(measured TIC for PPS->abscal_txts) - (WR t4p)
"t1_4" -> (WR t4p) - (WR t1)
"tic" -> histogram just the time interval measurements
-h --help Show this screen.
"""
......@@ -75,9 +75,9 @@ import lib.Keysight_53230A as tic
############################################################################
def wr_abs_cal_gui_file_to_scipy_array(filename):
def wr_abs_cal_file_to_scipy_array(filename):
"""
Retrieve the White Rabbit GUI info which is written during Absolute Calibration
Retrieve the White Rabbit GUI/console info which is written during Absolute Calibration
filename -- source file from which to retrieve data.
......@@ -87,13 +87,13 @@ def wr_abs_cal_gui_file_to_scipy_array(filename):
data_file = open(filename,"r")
# header = data_file.read(5) # read the waveform_header "wrc# "
#if header != "wrc# ":
#print("Exception: wr_abs_cal_gui_file_to_scipy_array: Not a WR Absolute Calibration GUI file.")
#Exception("wr_abs_cal_gui_file_to_scipy_array: Not a WR Absolute Calibration GUI file.")
#print("Exception: wr_abs_cal_file_to_scipy_array: Not a WR Absolute Calibration file.")
#Exception("wr_abs_cal_file_to_scipy_array: Not a WR Absolute Calibration file.")
#data_file.close()
#return
# create an empty gui_data dictionairy
gui_data = {}
# create an empty wr_data dictionary
wr_data = {}
# create an empty lists for t1 and t4 components
lst_t1_sec = []
......@@ -123,12 +123,12 @@ def wr_abs_cal_gui_file_to_scipy_array(filename):
t4_sec = scipy.array(lst_t4_sec)
t4 = scipy.array(lst_t4)
gui_data["t1 seconds"]=(t1_sec)
gui_data["t1"]=(t1)
gui_data["t4 seconds"]=(t4_sec)
gui_data["t4"]=(t4)
wr_data["t1 seconds"]=(t1_sec)
wr_data["t1"]=(t1)
wr_data["t4 seconds"]=(t4_sec)
wr_data["t4"]=(t4)
return gui_data
return wr_data
############################################################################
......@@ -171,19 +171,19 @@ def plot_hist(t_hist, hist_tic):
##
"""
Usage:
tic_gui.py <tic_file> <wrgui_file>
tic_gui.py <tic_file> -type 'tic'
tic_gui.py <wrgui_file> -type 't1_4'
tic_gui.py -h | --help
tic_wr.py <tic_file> <wr_file>
tic_wr.py <tic_file> -type 'tic'
tic_wr.py <wr_file> -type 't1_4'
tic_wr.py -h | --help
Options:
<tic_file> <type 'str'> file name that contains the Time Interval Counter
measurements between PPS output and either abscal_txts ouput
<wrgui_file> <type 'str'> name of file containing the WR GUI t1, t4p measurments
measurements between PPS output and either abscal_txts output
<wr_file> <type 'str'> name of file containing the WR t1, t4p measurements
<-type> <type 'str'> either
"" -> (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)
"" -> (measured TIC for PPS->abscal_txts) - (WR t1) and
(measured TIC for PPS->abscal_txts) - (WR t4p)
"t1_4" -> (WR t4p) - (WR t1)
"tic" -> histogram just the time interval measurements
-h --help Show this screen.
"""
......@@ -193,22 +193,22 @@ if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-tic_file", help="file containing TIC measurements")
parser.add_argument("-wrgui_file", help="file containing WR GUI measurements")
parser.add_argument("-wr_file", help="file containing WR GUI/console measurements")
parser.add_argument("-type", help="measurement type, either: 'tic' or 't1_4,", default='')
args = parser.parse_args()
tic_file = args.tic_file
wr_gui_file = args.wrgui_file
wr_file = args.wr_file
meas_type = args.type
if tic_file == "" and meas_type == "tic":
print ("### no TIC file specified!")
sys.exit()
elif wr_gui_file == "" and meas_type == "t1_4":
print ("### no WR GUI file specified!")
elif wr_file == "" and meas_type == "t1_4":
print ("### no WR GUI/console file specified!")
sys.exit()
elif tic_file == "" and wr_gui_file == "":
print ("### Specify TIC and WR GUI file!")
elif tic_file == "" and wr_file == "":
print ("### Specify TIC and WR GUI/console file!")
sys.exit()
if meas_type == "tic":
......@@ -220,43 +220,43 @@ if __name__ == "__main__":
hist_tic = plt.figure("Time Interval Counter skew")
plot_hist(t_hist, hist_tic)
elif meas_type == "t1_4":
print("Using WR GUI file: ",wr_gui_file)
gui_data = wr_abs_cal_gui_file_to_scipy_array(wr_gui_file)
print("Using WR file: ",wr_file)
wr_data = wr_abs_cal_file_to_scipy_array(wr_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 GUI (t4-t1)")
t_hist = wr_data["t4"] - wr_data["t1"]
num = len(wr_data["t1"])
print("Delay between internal timestamp t1 and t4p (i.e. t4p-t1):")
hist_tic = plt.figure("Histogram difference WR (t4p-t1)")
plot_hist(t_hist, hist_tic)
else:
print("Using TIC file: ",tic_file)
print("Using WR GUI file: ",wr_gui_file)
print("Using WR file: ",wr_file)
tic_data = tic.file_to_scipy_array(tic_file)
gui_data = wr_abs_cal_gui_file_to_scipy_array(wr_gui_file)
wr_data = wr_abs_cal_file_to_scipy_array(wr_file)
num_tic = len(tic_data[0]) # x-axis in [0]
num_gui = len(gui_data["t1"])
num = min(num_tic,num_gui)
num_wr = len(wr_data["t1"])
num = min(num_tic,num_wr)
print ("Measurements found in 53230A file:",num_tic,"in WR_GUI file:", num_gui)
print ("Measurements found in 53230A file:",num_tic,"in WR file:", num_wr)
print ("Measurements to take into account:",num)
print("Delay between abscal_txts and internal timestamp t1 and t4p:")
fig = plt.figure("Time Interval Counter and WR GUI t1, t4p versus measurment number")
fig = plt.figure("Time Interval Counter and WR t1, t4p versus measurement number")
ax = fig.add_subplot(111)
ax.set_xlabel('measurement number')
ax.set_ylabel('TIC, WR GUI t1, WR GUI t4p')
ax.set_ylabel('TIC, WR t1, WR t4p')
x = tic_data[0][:num]
lns1 = ax.plot(x,gui_data["t1"][:num], color='red', dashes=[2,2,10,2], label = 'WR GUI t1')
lns2 = ax.plot(x,gui_data["t4"][:num], color='red', dashes=[6,2], label = 'WR GUI t4p')
lns1 = ax.plot(x,wr_data["t1"][:num], color='red', dashes=[2,2,10,2], label = 'WR t1')
lns2 = ax.plot(x,wr_data["t4"][:num], color='red', dashes=[6,2], label = 'WR 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.subplots_adjust(left=0.17)
plt.draw()
t_hist_t1 = tic_data[1][:num] - gui_data["t1"][:num]
t_hist_t1 = tic_data[1][:num] - wr_data["t1"][:num]
hist_tic_t1 = plt.figure("Historam TICt1")
t_hist_t4p = tic_data[1][:num] - gui_data["t4"][:num]
t_hist_t4p = tic_data[1][:num] - wr_data["t4"][:num]
hist_tic_t4p = plt.figure("Historam TICt4p")
plot_hist(t_hist_t1, hist_tic_t1)
......
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