forked from DrSutherland/fyp-faster-gps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sfft_inverse.py
57 lines (42 loc) · 1.06 KB
/
sfft_inverse.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
import matplotlib.pyplot as plt
import numpy as np
from parameters import Parameters
import sfft
__author__ = 'jyl111'
def execute(params, x):
x = np.imag(x) + 1j * np.real(x)
A = sfft.execute(params=params, x=x)
B = np.imag(A) + 1j * np.real(A)
return B
def main():
params = Parameters(
n=1024,
k=1,
B_k_location=4,
B_k_estimation=2,
estimation_loops=8,
location_loops=5,
loop_threshold=4,
tolerance_location=1e-8,
tolerance_estimation=1e-8
)
from simulation import Simulation
sim = Simulation(params=params)
x_f = execute(params=params, x=sim.x)
x_f_actual = np.fft.ifft(sim.x)
fig = plt.figure()
ax = fig.gca()
ax.plot(
sim.t, x_f_actual.real, '-',
sim.t, x_f_actual.imag, '-',
sim.t, x_f.real, '--',
sim.t, x_f.imag, '--',
)
ax.legend((
'Real', 'Imaginary',
'sFFT Real', 'sFFT Imaginary'
))
ax.set_xlim(right=sim.t.shape[-1]-1)
plt.show()
if __name__ == '__main__':
main()