-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_iq.py
64 lines (51 loc) · 1.89 KB
/
plot_iq.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from __future__ import print_function
import argparse
import sys
import numpy as np
from matplotlib import pyplot as plt
import sdrcalibrator.lib.utils.common as utils
def main(args):
print("in main")
print(args)
test_foldername = args.foldername
print(test_foldername)
iq_filename = test_foldername + "iq_dump.csv"
profile_name = test_foldername + "iq_dump_profile.profile"
# change to get profile name from the folder
#profile_name = test_foldername + "single_fft_profile.profile"
profile = utils.load_profile(profile_name)
print(profile_name)
print(iq_filename)
data = np.loadtxt(iq_filename, delimiter=",", dtype="str")
n_samples = np.shape(data)[0]-1
fs = profile.sdr_sampling_frequency
ts = 1/fs
print("ts is:",ts)
if(args.n_plot_samples == "all"):
n_plot_samples = n_samples
else:
n_plot_samples = int(args.n_plot_samples)
tstart = 0; tend = tstart +(n_plot_samples-1)*ts
print("tend:",tend)
t = np.linspace(tstart,tend,n_plot_samples) # t is in miliseconds
data = np.loadtxt(iq_filename, delimiter=",", dtype="str")
IQ = data[1:np.shape(data)[0],:].astype(np.float64)
I = IQ[:,0]; Q = IQ[:,1]
plt.figure()
fs = 1e6; # change to read from profile
plt.plot(t,I[0:n_plot_samples],label="I"); plt.plot(t,Q[0:n_plot_samples],label="Q")
plt.legend(); plt.xlabel("Time, t (s)"); plt.ylabel("Voltage")
plt.title("IQ Dump")
plt.show()
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('foldername',
help="Name of folder for data",)
parser.add_argument('n_plot_samples',
help="number of samples to plot",default="all")
args = parser.parse_args()
try:
main(args)
except KeyboardInterrupt:
print("Caught Ctrl-C, exiting...", file=sys.stderr)
sys.exit(130)