summaryrefslogtreecommitdiff
path: root/gr-msdd6000/src/non_gr_snapshot_tool/plot_psd.py
diff options
context:
space:
mode:
Diffstat (limited to 'gr-msdd6000/src/non_gr_snapshot_tool/plot_psd.py')
-rwxr-xr-xgr-msdd6000/src/non_gr_snapshot_tool/plot_psd.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/gr-msdd6000/src/non_gr_snapshot_tool/plot_psd.py b/gr-msdd6000/src/non_gr_snapshot_tool/plot_psd.py
new file mode 100755
index 000000000..66d5ae6e2
--- /dev/null
+++ b/gr-msdd6000/src/non_gr_snapshot_tool/plot_psd.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+import struct;
+from pylab import *;
+import sys;
+
+#a = fft([1,2,3,4]);
+#print a;
+
+if(len(sys.argv)<2):
+ print "usage ./plot_psd.py <filename>"
+ sys.exit(-1);
+
+filename = sys.argv[1];
+
+#a = open("test.out_002", "r");
+a = open(filename, "r");
+samples = [];
+i_arr = [];
+q_arr = [];
+while(True):
+ d = a.read(1024*1024*4);
+ if(len(d) <= 0):
+ break;
+
+ for i in range(0,(len(d))/8):
+ [s_i, s_q] = struct.unpack_from("<ff", d, i*8);
+ samples.append(complex(s_i, s_q));
+ i_arr.append(s_i);
+ q_arr.append(s_q);
+ break;
+
+fft_data = fftshift(fft(samples));
+for i in range(0,len(fft_data)):
+ if(fft_data[i] == 0):
+ fft_data[i] = 0.01;
+
+plot(20*log10(abs(fft_data)));
+figure();
+subplot(2,1,1);
+plot(i_arr);
+subplot(2,1,2);
+plot(q_arr);
+show();
+
+
+a.close();
+
+