|
|
|
|
@ -24,6 +24,7 @@ import socket
|
|
|
|
|
import struct
|
|
|
|
|
import math
|
|
|
|
|
import time
|
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
from matplotlib import pyplot
|
|
|
|
|
@ -125,49 +126,69 @@ def done():
|
|
|
|
|
instrSend(s, "beeper.beep(0.150, 523)")
|
|
|
|
|
instrSend(s, "beeper.beep(1.000, 440)")
|
|
|
|
|
|
|
|
|
|
def calc_vector(x, y, arr):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
""" ==============================================================================================================
|
|
|
|
|
MAIN CODE STARTS HERE
|
|
|
|
|
============================================================================================================== """
|
|
|
|
|
ip_address = "192.168.0.53" # Place your instrument's IP address here.
|
|
|
|
|
my_port = 5025
|
|
|
|
|
|
|
|
|
|
output_data_path = time.strftime("data_%Y-%m-%d_%H-%M-%S.csv") # This is the output file that is created which
|
|
|
|
|
# will hold your readings provided in ASCII
|
|
|
|
|
# format in a text file.
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
|
parser.add_argument('-fromfile')
|
|
|
|
|
parser.add_argument('-tofile')
|
|
|
|
|
parser.add_argument('-ip', default="192.168.0.53")
|
|
|
|
|
parser.add_argument('-port', default=5025)
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
s = socket.socket() # Establish a TCP/IP socket object
|
|
|
|
|
# Open the socket connection
|
|
|
|
|
instrConnect(s, ip_address, my_port, 20000, 0, 0)
|
|
|
|
|
ip_address = args.ip
|
|
|
|
|
port = args.port
|
|
|
|
|
|
|
|
|
|
t1 = time.time() # Start the timer...
|
|
|
|
|
print(ip_address)
|
|
|
|
|
|
|
|
|
|
Configure_Backplane(s)
|
|
|
|
|
|
|
|
|
|
a = np.zeros(shape=(90, 90))
|
|
|
|
|
b = np.zeros(shape=(9, 10))
|
|
|
|
|
# reserve space for matrixes
|
|
|
|
|
full_matrix = np.zeros(shape=(90, 90))
|
|
|
|
|
point_specific_matrix = np.zeros(shape=(9, 10))
|
|
|
|
|
|
|
|
|
|
pyplot.ion()
|
|
|
|
|
fig, ax = pyplot.subplots()
|
|
|
|
|
axim = ax.imshow(full_matrix, interpolation='nearest', cmap='gray', vmin=0, vmax=30)
|
|
|
|
|
|
|
|
|
|
axim = ax.imshow(a, interpolation='nearest', cmap='gray', vmin=0, vmax=30)
|
|
|
|
|
t1 = time.time() # Start the timer...
|
|
|
|
|
|
|
|
|
|
x = 0
|
|
|
|
|
y = 0
|
|
|
|
|
print()
|
|
|
|
|
for ch1 in [*range(1001, 1031)] + [*range(2001, 2031)] + [*range(3001, 3031)]:
|
|
|
|
|
for ch2 in [*range(1031, 1061)] + [*range(2031, 2061)] + [*range(3031, 3061)]:
|
|
|
|
|
a[x][y]=diff_4W_mess(s, ch1, ch2)
|
|
|
|
|
b=get_mapped(a[x])
|
|
|
|
|
axim.set_data(b)
|
|
|
|
|
if args.fromfile:
|
|
|
|
|
#TODO check bounds of imported matrix
|
|
|
|
|
full_matrix = np.genfromtxt(args.fromfile, delimiter='\t')
|
|
|
|
|
for row in full_matrix:
|
|
|
|
|
point_specific_matrix=get_mapped(row)
|
|
|
|
|
axim.set_data(point_specific_matrix)
|
|
|
|
|
fig.canvas.flush_events()
|
|
|
|
|
y+=1
|
|
|
|
|
y=0
|
|
|
|
|
x+=1
|
|
|
|
|
else:
|
|
|
|
|
s = socket.socket() # Establish a TCP/IP socket object
|
|
|
|
|
instrConnect(s, ip_address, port, 20000, 0, 0)
|
|
|
|
|
|
|
|
|
|
Configure_Backplane(s)
|
|
|
|
|
|
|
|
|
|
x = 0
|
|
|
|
|
y = 0
|
|
|
|
|
print()
|
|
|
|
|
for ch1 in [*range(1001, 1031)] + [*range(2001, 2031)] + [*range(3001, 3031)]:
|
|
|
|
|
for ch2 in [*range(1031, 1061)] + [*range(2031, 2061)] + [*range(3031, 3061)]:
|
|
|
|
|
full_matrix[x][y]=diff_4W_mess(s, ch1, ch2)
|
|
|
|
|
point_specific_matrix=get_mapped(full_matrix[x])
|
|
|
|
|
axim.set_data(point_specific_matrix)
|
|
|
|
|
fig.canvas.flush_events()
|
|
|
|
|
y+=1
|
|
|
|
|
y=0
|
|
|
|
|
x+=1
|
|
|
|
|
|
|
|
|
|
done()
|
|
|
|
|
|
|
|
|
|
# Close the socket connection
|
|
|
|
|
instrDisconnect(s)
|
|
|
|
|
|
|
|
|
|
if args.tofile:
|
|
|
|
|
np.savetxt(args.tofile, full_matrix, delimiter="\t")
|
|
|
|
|
|
|
|
|
|
done();
|
|
|
|
|
# Close the socket connection
|
|
|
|
|
instrDisconnect(s)
|
|
|
|
|
t2 = time.time()
|
|
|
|
|
|
|
|
|
|
# Notify the user of completion and the data streaming rate achieved.
|
|
|
|
|
|