-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyser.py
executable file
·74 lines (55 loc) · 1.84 KB
/
analyser.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
65
66
67
68
69
70
71
72
73
74
# -*- coding: utf-8 -*-
""" IQ samples analyser
"""
import argparse
import numpy as np
import matplotlib.pyplot as plt
import utils
import dsp_utils
DEFAULT_OFFSET = 0
DEFAULT_N_SAMPLES = 0
DEFAULT_SIGNAL_PATH = "signals/ones.seq.json"
DEFAULT_FFT_SIZE = 1024
def main(args: argparse.Namespace):
samples = utils.import_json(args.input)
if args.n_samples > 0:
samples = samples[args.offset:args.offset+args.n_samples]
############# Visualizer ###############
fig = plt.figure(figsize=(10, 10))
# Real
ax = plt.subplot(2, 2, 1)
plt.plot(samples.real,".")
plt.ylabel("Real")
#plt.xlabel("N-Samples")
plt.grid(True)
# Imaginary
ax = plt.subplot(2, 2, 3)
plt.plot(samples.imag,".")
plt.ylabel("Imaginary")
plt.xlabel("N-Samples")
plt.grid(True)
# Z-Plane
ax = plt.subplot(2, 2, 2)
plt.plot(samples.real, samples.imag, "r.")
plt.xlabel("In-Phase")
plt.ylabel("Quadrature")
plt.grid(True)
# FFT
ax = plt.subplot(2, 2, 4)
fft_result_pss = dsp_utils.calc_fft_psd(samples.real, samples.imag, args.fft_size)
plt.plot(fft_result_pss.real)#, ".")
plt.xlabel("FFT size")
plt.grid(True)
plt.show()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Analyser Protocol Script')
parser.add_argument('--input', type=str, default=DEFAULT_SIGNAL_PATH,
help=f'path to input signal file')
parser.add_argument('--fft-size', type=int, default=DEFAULT_FFT_SIZE,
help=f'FFT Size')
parser.add_argument('--offset', type=int, default=DEFAULT_OFFSET,
help=f'samples offset')
parser.add_argument('--n-samples', type=int, default=DEFAULT_N_SAMPLES,
help=f'number of samples to analyse')
args = parser.parse_args()
main(args)