Commit 7a5ba699 authored by Peter Jansweijer's avatar Peter Jansweijer

get rid of docopt

parent 2b34b56c
...@@ -34,23 +34,21 @@ The same reference clock mentioned above should also have been used for the ...@@ -34,23 +34,21 @@ 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> tic_gui.py <tic_file> <wrgui_file>
tic_gui.py <tic_file> <"tic"> tic_gui.py <tic_file> -type 'tic'
tic_gui.py <wr_gui_file> <"t1_4"> tic_gui.py <wrgui_file> -type 't1_4'
tic_gui.py -h | --help tic_gui.py -h | --help
<tic_file> <type 'str'> file name that contains the Time Interval Options:
measurements between pps_o and either tx_ts or rx_ts output <tic_file> <type 'str'> file name that contains the Time Interval Counter
<wr_gui_file> <type 'str'> name of file containing the Time Interval measurements between PPS output and either abscal_txts ouput
measurements between pps_o and either tx_ts or rx_ts output <wrgui_file> <type 'str'> name of file containing the WR GUI t1, t4p measurments
<meas_type> <type 'str'> either <-type> <type 'str'> either
"" -> (measured TIC for PPS->abscal_txts) - (WR_GUI t1) and "" -> (measured TIC for PPS->abscal_txts) - (WR_GUI t1) and
(measured TIC for PPS->abscal_txts) - (WR_GUI t4p) (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:
-h --help Show this screen. -h --help Show this screen.
--version Show version.
""" """
import os import os
...@@ -72,7 +70,6 @@ lib_path = os.path.join(lib_path,"..") ...@@ -72,7 +70,6 @@ lib_path = os.path.join(lib_path,"..")
sys.path.insert(0,lib_path) sys.path.insert(0,lib_path)
# private imports: # private imports:
from lib.docopt import docopt
import lib.Keysight_53230A as tic import lib.Keysight_53230A as tic
############################################################################ ############################################################################
...@@ -171,23 +168,58 @@ def plot_hist(t_hist, hist_tic): ...@@ -171,23 +168,58 @@ def plot_hist(t_hist, hist_tic):
## ##
## If run from commandline, we can test the library ## If run from commandline, we can test the library
## ##
"""
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
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
<-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)
"tic" -> histogram just the time interval measurements
-h --help Show this screen.
"""
if __name__ == "__main__": if __name__ == "__main__":
arguments = docopt(__doc__,version='Keysight DSO-S 254A version 01') import argparse
parser = argparse.ArgumentParser()
if len(sys.argv) !=3: parser.add_argument("-tic_file", help="file containing TIC measurements")
print ("### wrong number of input arguments") parser.add_argument("-wrgui_file", help="file containing WR GUI 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
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!")
sys.exit() sys.exit()
elif sys.argv[2] == "tic": elif tic_file == "" and wr_gui_file == "":
print ("### Specify TIC and WR GUI file!")
sys.exit()
if meas_type == "tic":
print("Time Interval Counter skew") print("Time Interval Counter skew")
tic_file = sys.argv[1] print("Using TIC file: ",tic_file)
tic_data = tic.file_to_scipy_array(tic_file) tic_data = tic.file_to_scipy_array(tic_file)
num = len(tic_data[0]) # x-axis in [0] num = len(tic_data[0]) # x-axis in [0]
t_hist = tic_data[1] # y-axis in [1] t_hist = tic_data[1] # y-axis in [1]
hist_tic = plt.figure("Time Interval Counter skew") hist_tic = plt.figure("Time Interval Counter skew")
plot_hist(t_hist, hist_tic) plot_hist(t_hist, hist_tic)
elif sys.argv[2] == "t1_4": elif meas_type == "t1_4":
wr_gui_file = sys.argv[1] print("Using WR GUI file: ",wr_gui_file)
gui_data = wr_abs_cal_gui_file_to_scipy_array(wr_gui_file) gui_data = wr_abs_cal_gui_file_to_scipy_array(wr_gui_file)
print("Histogram difference WR (t4p-t1)") print("Histogram difference WR (t4p-t1)")
t_hist = gui_data["t4"] - gui_data["t1"] t_hist = gui_data["t4"] - gui_data["t1"]
...@@ -196,9 +228,9 @@ if __name__ == "__main__": ...@@ -196,9 +228,9 @@ if __name__ == "__main__":
hist_tic = plt.figure("Histogram difference WR GUI (t4-t1)") hist_tic = plt.figure("Histogram difference WR GUI (t4-t1)")
plot_hist(t_hist, hist_tic) plot_hist(t_hist, hist_tic)
else: else:
tic_file = sys.argv[1] print("Using TIC file: ",tic_file)
print("Using WR GUI file: ",wr_gui_file)
tic_data = tic.file_to_scipy_array(tic_file) 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) gui_data = wr_abs_cal_gui_file_to_scipy_array(wr_gui_file)
num_tic = len(tic_data[0]) # x-axis in [0] num_tic = len(tic_data[0]) # x-axis in [0]
num_gui = len(gui_data["t1"]) num_gui = len(gui_data["t1"])
......
...@@ -22,21 +22,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/> ...@@ -22,21 +22,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Usage: Usage:
Keysight_53230A.py <IP#> [--meas=<number>] Keysight_53230A.py IP# [-i1=<float>] [-i2=<float>] [-m=<int>]
Keysight_53230A.py -h | --help Keysight_53230A.py -h | --help
IP IP number of the Frequency Counter/Timer IP IP number of the Frequency Counter/Timer
(for example: 192.168.32.251 which is its DevNet IP number) (for example: 192.168.32.251 which is its DevNet IP number)
Options: Options:
-h --help Show this screen. IP IP number of the instrument [default 192.168.32.251]
--version Show version. -in1 <float> trigger level input 1 [default 0.15]
-m --meas=<number> number of measurements to be taken [default: 1] -in2 <float> trigger level input 2 [default 0.3]
-m <int> number of measurements to be taken [default: 1]
-h, --help Show this screen.
""" """
from docopt import docopt
import sys import sys
import time import time
import scipy import scipy
...@@ -154,15 +154,44 @@ def file_to_scipy_array(filename): ...@@ -154,15 +154,44 @@ def file_to_scipy_array(filename):
## ##
## If run from commandline, we can test the library ## If run from commandline, we can test the library
## ##
"""
Usage:
Keysight_53230A.py IP# [-i1=<float>] [-i2=<float>] [-m=<int>]
Keysight_53230A.py -h | --help
IP IP number of the Frequency Counter/Timer
(for example: 192.168.32.251 which is its DevNet IP number)
Options:
IP IP number of the instrument [default 192.168.32.251]
-in1 <float> trigger level input 1 [default 0.15]
-in2 <float> trigger level input 2 [default 0.3]
-m <int> number of measurements to be taken [default: 1]
-h, --help Show this screen.
"""
if __name__ == "__main__": if __name__ == "__main__":
arguments = docopt(__doc__,version='Keysight DSO-S 254A version 01') import argparse
parser = argparse.ArgumentParser()
parser.add_argument("IP", help="IP number of the instrument", default="192.168.32.251")
parser.add_argument("-i1", help="in1 trigger level", default=0.15)
parser.add_argument("-i2", help="in2 trigger level", default=0.30)
parser.add_argument("-m", help="number of measurements", default=1)
args = parser.parse_args()
IP = args.IP
in1 = float(args.i1)
in2 = float(args.i2)
num_meas = int(args.m)
num_meas = 1 print("trigger level in1: ", in1)
print("trigger level in2: ", in2)
print("number of measurements: ", num_meas)
if len(sys.argv) >= 2: # just IP number freq_cnt = vxi11.Instrument(IP)
freq_cnt = vxi11.Instrument(sys.argv[1])
#freq_cnt = vxi11.Instrument("192.168.32.251")
# Put the device in a known state # Put the device in a known state
freq_cnt.write("*RST") freq_cnt.write("*RST")
...@@ -171,10 +200,6 @@ if __name__ == "__main__": ...@@ -171,10 +200,6 @@ if __name__ == "__main__":
print(freq_cnt.ask("*IDN?")) print(freq_cnt.ask("*IDN?"))
# Returns 'Agilent Technologies,53230A,MY50001484,02.05-1519.666-1.19-4.15-127-155-35' # Returns 'Agilent Technologies,53230A,MY50001484,02.05-1519.666-1.19-4.15-127-155-35'
if len(sys.argv) >= 3: # There are more arguments...
num_meas = int(sys.argv[2].split('=')[1])
print ("num_meas", num_meas)
# Setup Time Interval measurment from channel 1 -> 2 # Setup Time Interval measurment from channel 1 -> 2
freq_cnt.write("CONFigure:TINTerval (@1),(@2)") freq_cnt.write("CONFigure:TINTerval (@1),(@2)")
...@@ -183,7 +208,12 @@ if __name__ == "__main__": ...@@ -183,7 +208,12 @@ if __name__ == "__main__":
freq_cnt.write("SENSE:TINTerval:GATE:POLarity POSitive") freq_cnt.write("SENSE:TINTerval:GATE:POLarity POSitive")
# Use external 10MHz reference # Use external 10MHz reference
freq_cnt.write("ROSCillator:SOURce EXTernal") #freq_cnt.write("ROSCillator:SOURce EXTernal")
# Use internal reference
# forward Keysight 53230A 10MHz reference output to Keysight
# Waveform Generator 33600A reference 10MHz input).
# Keysight 33600A generated 10 MHz and PPS for mode abscal.
freq_cnt.write("ROSCillator:SOURce INTernal")
# Disable timeout (otherwise we might loose measurements) # Disable timeout (otherwise we might loose measurements)
freq_cnt.write("SYSTem:TIMeout INFinity") freq_cnt.write("SYSTem:TIMeout INFinity")
...@@ -196,16 +226,17 @@ if __name__ == "__main__": ...@@ -196,16 +226,17 @@ if __name__ == "__main__":
# A fixed trigger level is important for proper timing measurement # A fixed trigger level is important for proper timing measurement
# MiniCircuits Splitters ZFRSC-123+ have ~ 6 + 3,75 dB attenuation (~ factor 3). # MiniCircuits Splitters ZFRSC-123+ have ~ 6 + 3,75 dB attenuation (~ factor 3).
# A 2,4 V signal split once results in 0,8 V, slit twice in 260 mV. # A 2,4 V signal split once results in 0,8 V, split twice in 260 mV.
use_power_splitter_ch1 = False #use_power_splitter_ch1 = False
use_power_splitter_ch2 = True #use_power_splitter_ch2 = True
freq_cnt.write("INP1:IMP 50") freq_cnt.write("INP1:IMP 50")
if use_power_splitter_ch1: freq_cnt.write("INP1:LEV "+str(float(in1)))
freq_cnt.write("INP1:LEV 0.15") #if use_power_splitter_ch1:
else: # freq_cnt.write("INP1:LEV 0.15")
freq_cnt.write("INP1:LEV 0.3") #else:
# freq_cnt.write("INP1:LEV 0.3")
# Channel 2 setup: # Channel 2 setup:
freq_cnt.write("INP2:COUP DC") freq_cnt.write("INP2:COUP DC")
...@@ -215,15 +246,16 @@ if __name__ == "__main__": ...@@ -215,15 +246,16 @@ if __name__ == "__main__":
# A fixed trigger level is important for proper timing measurement # A fixed trigger level is important for proper timing measurement
# MiniCircuits Splitters ZFRSC-123+ have ~ 6 + 3,75 dB attenuation (~ factor 3). # MiniCircuits Splitters ZFRSC-123+ have ~ 6 + 3,75 dB attenuation (~ factor 3).
# A 2,4 V signal split once results in 0,8 V, slit twice in 260 mV. # A 2,4 V signal split once results in 0,8 V, split twice in 260 mV.
freq_cnt.write("INP2:IMP 50") freq_cnt.write("INP2:IMP 50")
if use_power_splitter_ch2: freq_cnt.write("INP2:LEV "+str(float(in2)))
freq_cnt.write("INP2:LEV 0.15") #if use_power_splitter_ch2:
else: # freq_cnt.write("INP2:LEV 0.15")
freq_cnt.write("INP2:LEV 0.3") #else:
# freq_cnt.write("INP2:LEV 0.3")
# initialize and wait for initialisatio to complete # initialize and wait for initialisation to complete
freq_cnt.write("INIT") freq_cnt.write("INIT")
freq_cnt.write("*WAI") freq_cnt.write("*WAI")
...@@ -236,4 +268,4 @@ if __name__ == "__main__": ...@@ -236,4 +268,4 @@ if __name__ == "__main__":
#plt.plot(x,y) #plt.plot(x,y)
#plt.show() #plt.show()
sys.exit() 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