def main():
    code_1 = ca_code.generate(prn=1) | np.roll(ca_code.generate(prn=2), 100)
    code_2 = ca_code.generate(prn=1)

    # code_2 = np.roll(code_2, 100)

    # fftshift(ifft(fft(a,corrLength).*conj(fft(b,corrLength))))

    q = 2
    code_1 = sfft_aliasing.execute(code_1, q)
    code_2 = sfft_aliasing.execute(code_2, q)

    code_1_fft = fourier_transforms.fft(code_1)
    code_2_fft = fourier_transforms.fft(code_2)

    multiplied = code_1_fft * np.conj(code_2_fft)

    print multiplied.size

    params = Parameters(
        n=multiplied.size/2,
        k=1,
        B_k_location=2,
        B_k_estimation=2,
        estimation_loops=8,
        location_loops=5,
        loop_threshold=4,
        tolerance_location=1e-8,
        tolerance_estimation=1e-8
    )
    result = sfft_inverse.execute(params=params, x=multiplied)
    result = fourier_transforms.fftshift(result)

    result_actual = fourier_transforms.ifft(multiplied)
    result_actual = fourier_transforms.fftshift(result_actual)

    print 'sfft size', result.size
    print 'original size', result_actual.size

    fig = plt.figure()
    ax = fig.gca()
    ax.plot(np.linspace(-1, 1, result.size), np.abs(result))
    ax.plot(np.linspace(-1, 1, result_actual.size), np.abs(result_actual))
    plt.show()
Example #2
0
def make_multiple(x, w, n, b):
    print("w = {0}, n = {1}, b = {2}".format(w, n, b))

    assert b <= n
    assert w <= n

    g = np.zeros(n, dtype=np.complex128)
    h = np.zeros(n, dtype=np.complex128)

    g[0 : w - (w / 2)] = x[(w / 2) :]
    g[n - (w / 2) :] = x[: (w / 2)]

    g = fft(g, n=n)

    s = 0
    for i in xrange(b):
        s += g[i]

    max = 0
    offset = int(b / 2)

    for i in xrange(n):
        h[(i + n + offset) % n] = s
        max = np.maximum(max, np.abs(s))
        s += g[(i + b) % n] - g[i]

    h /= max

    offsetc = 1
    step = np.exp(-2 * np.pi * 1j * (w / 2) / n)

    for i in xrange(n):
        h[i] *= offsetc
        offsetc *= step

    x = ifft(h, n=n)

    return {"time": x, "size": w, "freq": h}
Example #3
0
def make_multiple(x, w, n, b):
    print('w = {0}, n = {1}, b = {2}'.format(w, n, b))

    assert b <= n
    assert w <= n

    g = np.zeros(n, dtype=np.complex128)
    h = np.zeros(n, dtype=np.complex128)

    g[0:w - (w / 2)] = x[(w / 2):]
    g[n - (w / 2):] = x[:(w / 2)]

    g = fft(g, n=n)

    s = 0
    for i in xrange(b):
        s += g[i]

    max = 0
    offset = int(b / 2)

    for i in xrange(n):
        h[(i + n + offset) % n] = s
        max = np.maximum(max, np.abs(s))
        s += (g[(i + b) % n] - g[i])

    h /= max

    offsetc = 1
    step = np.exp(-2 * np.pi * 1j * (w / 2) / n)

    for i in xrange(n):
        h[i] *= offsetc
        offsetc *= step

    x = ifft(h, n=n)

    return {'time': x, 'size': w, 'freq': h}
Example #4
0
 def generate_input(self):
     """Generate time domain signal"""
     self.x = fourier_transforms.ifft(self.x_f)
Example #5
0
 def generate_input(self):
     """Generate time domain signal"""
     self.x = fourier_transforms.ifft(self.x_f)