Exemple #1
0
n_theta = 200

theta = np.linspace(-np.pi / 2, np.pi / 2, num=n_theta)
lambda_c = c / rx.fc
k = 2 * np.pi / (lambda_c)

#%%
a = np.empty((rx.m, theta.size), dtype=complex)

for ax in range(theta.size):
    for i in range(rx.m):
        a[i, ax] = np.e**(1j * i * k * rx.d * np.sin(theta[ax]))

s = doamusic_samples(txs, rx, simulation)
p_mu = doamusic_estimation(s, a)

#%%
x_start = np.array([-15, 0, 15])  # Start coordinate for the transmitter in m
v = np.array([1, 0, 0])  # Transmitter velocity in m/s
t = 0
fc = 436 * MHz
amp = 10
freq = 1300
s = Sine_Wave(amp, freq, fc)
tx0 = Transmitter(x_start, v, t, s)

x_start = np.array([15, 0, 15])  # Start coordinate for the transmitter in m
v = np.array([1, 0, 0])  # Transmitter velocity in m/s
t = 0
fc = 436 * MHz
Exemple #2
0
def image_array(snr):
    print(snr)
    simulation = Simulation(n, d, fs, fc, sampling_time, snr)

    s1 = doamusic_samples(txs1, rx, simulation)
    p_mu1 = doamusic_estimation(s1, a)
    s2 = doamusic_samples(txs2, rx, simulation)
    p_mu2 = doamusic_estimation(s2, a)

    fig, axs = plt.subplots(1, 2, figsize=(20, 9), frameon=False, dpi=200)
    for ax in axs:
        ax.set_yscale("log")
        ax.set_ylabel(r"$|P_{MU}|$", size=15)
        ax.set_xlabel(r"$\theta$ [°]")
        ax.set_xticks([-75, -45, -25, 0, 25, 45, 75])
        ax.set_yticks([])
        ax.minorticks_off()

        at = AnchoredText("SNR = %i dB" % (snr),
                          prop=dict(size=15),
                          frameon=True,
                          loc="upper right")
        at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
        ax.add_artist(at)

    axs[0].plot((0, 0), (0, p_mu1.max() * 1.05),
                linestyle="--",
                color="r",
                linewidth=2)
    axs[0].plot((45, 45), (0, p_mu1.max() * 1.05),
                linestyle="--",
                color="r",
                linewidth=2)
    axs[0].plot((-45, -45), (0, p_mu1.max() * 1.05),
                linestyle="--",
                color="r",
                linewidth=2)
    axs[0].set_ylim((p_mu1.min(), p_mu1.max() * 1.05))
    axs[0].plot(theta * 180 / np.pi, p_mu1)
    axs[0].set_title("Señales coherentes", size=20)

    axs[1].plot((0, 0), (0, p_mu2.max() * 1.05),
                linestyle="--",
                color="r",
                linewidth=2)
    axs[1].plot((45, 45), (0, p_mu2.max() * 1.05),
                linestyle="--",
                color="r",
                linewidth=2)
    axs[1].plot((-45, -45), (0, p_mu2.max() * 1.05),
                linestyle="--",
                color="r",
                linewidth=2)
    axs[1].set_ylim((p_mu2.min(), p_mu2.max() * 1.05))
    axs[1].plot(theta * 180 / np.pi, p_mu2)
    axs[1].set_title("Señales no coherentes", size=20)

    fig.canvas.draw()  # draw the canvas, cache the renderer
    image = np.frombuffer(fig.canvas.tostring_rgb(), dtype="uint8")
    image = image.reshape(fig.canvas.get_width_height()[::-1] + (3, ))

    return image
Exemple #3
0
track = np.zeros((2, n_time))
theta = np.linspace(-np.pi / 2, np.pi / 2, num=n_theta)
lambda_c = c / rx.fc
k = 2 * np.pi / (lambda_c)
a = np.empty((rx.m, theta.size), dtype=complex)

for ax in range(theta.size):
    for i in range(rx.m):
        a[i, ax] = np.e**(1j * i * k * rx.d * np.sin(theta[ax]))

for j in range(n_time):
    t = t_array[j]
    tx = Transmitter(x_start, v, t, sine)
    track[:, j] = np.array([tx.r[0], tx.r[2]])
    s, x = doa_samplesgen(tx, rx, simulation)
    p_mu[:, j] = doamusic_estimation(s, a)
#%%

# %%
plotanim(p_mu, theta)

# %%
step = 0.02
plt.ion()
fig, ax = plt.subplots(2, 1, figsize=(16, 9), dpi=100)
# arr_satelite = mpimg.imread("satelite.png")
# imagebox = OffsetImage(arr_satelite, zoom=0.08)
# ab = AnnotationBbox(imagebox, (track[0, 0], track[1, 0]))
# ax[0].add_artist(ab)

# img = cv2.imread('satelite.png', cv2.IMREAD_UNCHANGED)