plot_sayma_data: Add option to log phase measurements

This commit is contained in:
Harry Ho 2021-10-06 14:49:52 +08:00
parent 3b9cae0d0e
commit 203129284a

View File

@ -28,6 +28,9 @@ def main():
"CHANNEL must be 1 or 2; " "CHANNEL must be 1 or 2; "
"NAME must be any of: " + " ".join(list(RP_IP_ADDRS.keys())), "NAME must be any of: " + " ".join(list(RP_IP_ADDRS.keys())),
type=str, nargs=2) type=str, nargs=2)
parser.add_argument("--log",
help="path of the log file where the measurement record will be appended",
type=str)
args = parser.parse_args() args = parser.parse_args()
# Must only compare 2 data # Must only compare 2 data
@ -65,6 +68,13 @@ def main():
# Element-wise multiply Z[0] with the conjugate of Z[1] to get the phase difference (i.e. angle(z0) - angle(z1)), and use the mean value. # Element-wise multiply Z[0] with the conjugate of Z[1] to get the phase difference (i.e. angle(z0) - angle(z1)), and use the mean value.
angle = np.angle(np.mean(z[0]*z[1].conj())) angle = np.angle(np.mean(z[0]*z[1].conj()))
# Append the phase difference to the log file
log = args.log
if log is not None:
with open(log, 'a') as f:
f.write("{}\t{}\n".format(now_iso, angle))
print("Phase measurement record appended to log: {}".format(log))
# Print the phase difference
print(angle) print(angle)
# Normalize y1 and y2 for plotting # Normalize y1 and y2 for plotting