From 203129284a3dd75f472f8c9d6c49cce024f98b28 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Wed, 6 Oct 2021 14:49:52 +0800 Subject: [PATCH] plot_sayma_data: Add option to log phase measurements --- plot_sayma_data.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plot_sayma_data.py b/plot_sayma_data.py index d40619d..3f4c38c 100644 --- a/plot_sayma_data.py +++ b/plot_sayma_data.py @@ -28,6 +28,9 @@ def main(): "CHANNEL must be 1 or 2; " "NAME must be any of: " + " ".join(list(RP_IP_ADDRS.keys())), 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() # 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. 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) # Normalize y1 and y2 for plotting