aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-07-24 18:16:52 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-07-24 18:16:52 +0200
commit2e4ae7c3fa5627fd45ed5153bf95c33e1a01431a (patch)
tree90f9d9607484e320cb123fc5ec71586ece77a2af
parent398668b52a776219af6d056f74b24ec43b13852f (diff)
downloadodr-dab-cir-2e4ae7c3fa5627fd45ed5153bf95c33e1a01431a.tar.gz
odr-dab-cir-2e4ae7c3fa5627fd45ed5153bf95c33e1a01431a.tar.bz2
odr-dab-cir-2e4ae7c3fa5627fd45ed5153bf95c33e1a01431a.zip
Add option to save graph to file
-rwxr-xr-xcorrelate_with_ref.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/correlate_with_ref.py b/correlate_with_ref.py
index 3bf8640..cb3f7aa 100755
--- a/correlate_with_ref.py
+++ b/correlate_with_ref.py
@@ -8,11 +8,12 @@ import numpy as np
import matplotlib.pyplot as pp
import sys
-if len(sys.argv) != 3:
+if len(sys.argv) < 2:
print("Usage")
- print(" script [fc64|u8] <filename>")
+ print(" script [fc64|u8] <filename> [<figure filename>]")
print(" fc64: file is 32-bit float I + 32-bit float Q")
print(" u8: file is 8-bit unsigned I + 8-bit unsigned Q")
+ print(" if <figure filename> is given, save the figure instead of showing it")
sys.exit(1)
print("Reading file")
@@ -28,6 +29,10 @@ if sys.argv[1] == "u8":
elif sys.argv[1] == "fc64":
channel_out = np.fromfile(file_in, np.complex64)
+file_figure = None
+if len(sys.argv) == 4:
+ file_figure = sys.argv[3]
+
print(" File contains {} samples ({}ms)".format(
len(channel_out), len(channel_out) / 2048000.0))
@@ -106,7 +111,10 @@ pp.imshow(cirs)
print("Done")
-pp.show()
+if file_figure:
+ pp.savefig(file_figure)
+else:
+ pp.show()