def generate_dolph_chebyshev(lobe_fraction, tolerance):
    def cheb(m, x):
        if np.abs(x) <= 1:
            return np.cos(m * np.arccos(x))
        else:
            return np.cosh(m * np.arccosh(np.abs(x))).real

    w = int((1 / np.pi) * (1 / lobe_fraction) * np.arccosh(1 / tolerance))

    if w % 2 == 0:
        w -= 1

    beta = np.cosh(np.arccosh(1 / tolerance) / float(w - 1))

    print('lobe_fraction = {0}, tolerance = {1}, w = {2}, beta = {3}'.format(
        lobe_fraction, tolerance, w, beta))

    x = np.empty(w, dtype=np.complex128)

    for i in xrange(w):
        x[i] = cheb(w - 1, beta * np.cos(np.pi * i / w)) * tolerance

    x = fft(x, n=w)
    x = fftshift(x)
    x = np.real(x)

    return {'x': x, 'w': w}
Exemple #2
0
def generate_dolph_chebyshev(lobe_fraction, tolerance):
    def cheb(m, x):
        if np.abs(x) <= 1:
            return np.cos(m * np.arccos(x))
        else:
            return np.cosh(m * np.arccosh(np.abs(x))).real

    w = int((1 / np.pi) * (1 / lobe_fraction) * np.arccosh(1 / tolerance))

    if w % 2 == 0:
        w -= 1

    beta = np.cosh(np.arccosh(1 / tolerance) / float(w - 1))

    print("lobe_fraction = {0}, tolerance = {1}, w = {2}, beta = {3}".format(lobe_fraction, tolerance, w, beta))

    x = np.empty(w, dtype=np.complex128)

    for i in xrange(w):
        x[i] = cheb(w - 1, beta * np.cos(np.pi * i / w)) * tolerance

    x = fft(x, n=w)
    x = fftshift(x)
    x = np.real(x)

    return {"x": x, "w": w}
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()