From 62ff2938acd8dff4fd696f6b3e2b69810c6cf283 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Sun, 17 Oct 2021 19:46:30 +0200 Subject: [PATCH] Some python debug plot scripts --- impl/utils/plot_constellation.py | 18 ++++++++++++++++++ impl/utils/plot_timedomain.py | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100755 impl/utils/plot_constellation.py create mode 100755 impl/utils/plot_timedomain.py diff --git a/impl/utils/plot_constellation.py b/impl/utils/plot_constellation.py new file mode 100755 index 0000000..d79de51 --- /dev/null +++ b/impl/utils/plot_constellation.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +import sys + +import numpy as np +import matplotlib.pyplot as pp + +with open(sys.argv[1], 'rb') as infile: + header = infile.read(4) + if header != b'CPX_': + print(f"Error: not a complex signal file. Format {header} not implemented yet.") + exit(1) + + T = np.fromfile(infile, dtype=np.float32, count=1) + data = np.fromfile(infile, dtype=np.complex64) + + pp.plot(np.real(data), np.imag(data), 'x') + pp.show() diff --git a/impl/utils/plot_timedomain.py b/impl/utils/plot_timedomain.py new file mode 100755 index 0000000..84c4bd8 --- /dev/null +++ b/impl/utils/plot_timedomain.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +import sys + +import numpy as np +import matplotlib.pyplot as pp + +with open(sys.argv[1], 'rb') as infile: + header = infile.read(4) + if header != b'CPX_': + print(f"Error: not a complex signal file. Format {header} not implemented yet.") + exit(1) + + T = np.fromfile(infile, dtype=np.float32, count=1) + data = np.fromfile(infile, dtype=np.complex64) + + t = np.arange(0, T*data.size, T) + + pp.plot(t, np.real(data), 'r-') + pp.plot(t, np.imag(data), 'b-') + pp.legend(['In-phase', 'Quadrature']) + pp.xlabel('Time [s]') + pp.show()