コード例 #1
0
def alg_2(csi):
    """alg_2

    Note: N_p = 1
    """

    p = np.power(np.abs(phy_ifft(csi, scidx(20, 2), axis=1)), 2.0)
    # find_peak() is better
    s = p[:, :20].argmax(axis=1).reshape(csi.shape[0], -1)
    N_sto = scidx(20, 2)[mode(s, axis=1)[0][:, 0]]
    N_sc = 64
    csi = derotate_formual16(csi, -2 * np.pi * N_sto / N_sc)
    return csi
コード例 #2
0
ファイル: csishow.py プロジェクト: citysu/csiread
def func_3(csidata):
    """CSI: time-phase"""
    s_index = 15  # subcarrier index
    csi = csidata.get_scaled_csi_sm()
    t = csidata.timestamp_low / 1000000 - csidata.timestamp_low[0] / 1000000
    phase = np.unwrap(np.angle(csi), axis=1)
    phase = calib(phase, scidx(20, 2))

    plt.figure()
    plt.plot(t,
             phase[:, s_index, 0, 0],
             linewidth=0.3,
             label='subcarrier_15_0_0')
    plt.plot(t,
             phase[:, s_index, 1, 0],
             linewidth=0.3,
             label='subcarrier_15_1_0')
    plt.plot(t,
             phase[:, s_index, 2, 0],
             linewidth=0.3,
             label='subcarrier_15_2_0')
    plt.legend()
    plt.title('csi-phase')
    plt.xlabel('time(s)')
    plt.ylabel('phase')
    plt.show()
コード例 #3
0
def fig_4(athdata, index=26):
    """fig_4

    Ref:
        [FFT Length (802.11n/ac/ax)](http://rfmw.em.keysight.com/wireless/helpfiles/89600B/WebHelp/Subsystems/wlan-mimo/Content/mimo_adv_fftsze.htm)
    """
    csi = athdata.csi

    # Fig.4(a)
    phase = np.unwrap(np.angle(csi), axis=1)
    phase = calib(phase, scidx(20, 1))
    plt.subplot(3, 1, 1)
    plt.plot(phase[index].reshape(csi.shape[1], -1))

    # Fig.4(b)
    amplidute = 10 * np.log10(np.abs(csi) + 1 / 10**6)  # db
    plt.subplot(3, 1, 2)
    plt.plot(amplidute[index].reshape(csi.shape[1], -1))

    # Fig.4(c)
    # scipy.fftpack.fft or phy_fft ?
    A = np.log10(np.abs(fft(csi, n=64, axis=1)))
    plt.subplot(3, 1, 3)
    plt.plot(A[index].reshape(64, -1), '*--')

    plt.tight_layout()
    plt.show()
コード例 #4
0
def algshow(csidata):
    s_index = scidx(20, 2)
    csi = csidata.csi[:500]

    plt.figure()

    # alg_1
    csi = alg_1(csi)
    phase = np.unwrap(np.angle(csi), axis=1)
    phase = calib(phase, s_index)
    plt.subplot(3, 1, 1)
    plt.plot(s_index, phase[200:300, :, 0, 0].T)

    # alg_2
    csi = alg_2(csi)
    phase = np.unwrap(np.angle(csi), axis=1)
    phase = calib(phase, s_index)
    plt.subplot(3, 1, 2)
    plt.plot(s_index, phase[200:300, :, 0, 0].T)

    # alg_3
    # csicopy = csi.copy()
    # for i in range(100, 200):
    #     csicopy[i] = alg_3(csi, i)
    # phase = np.unwrap(np.angle(csicopy), axis=1)
    # phase = calib(phase, s_index)
    # plt.subplot(3, 1, 3)
    # plt.plot(s_index, phase[100:200, :, 0, 0].T)
    plt.show()
コード例 #5
0
def fig_6(csidata):
    """fig_6"""
    csi = csidata.csi
    s_index = scidx(20, 2)

    phase = np.unwrap(np.angle(csi[:1000, :, 0, 0])).T
    phase_diff = np.diff(phase)
    phase_diff -= phase_diff.mean(axis=0)
    phase_mean_0 = phase_diff.mean(axis=-1)

    plt.figure()
    plt.subplot(2, 1, 1)
    plt.plot(s_index, phase_diff, 'y+', linewidth=0.3)
    plt.plot(s_index, phase_mean_0, 'r-', linewidth=2.0)
    patch_1 = mpatches.Patch(color='yellow', label=':1000_r0t0')
    patch_2 = mpatches.Patch(color='red', label=':1000_r0t0_phase_mean_0')
    plt.legend(handles=[patch_1, patch_2])
    plt.title('fig6b: csi-phase_diff')
    plt.xlabel('subcarriers')
    plt.ylabel('phase_diff')

    plt.subplot(2, 1, 2)
    plt.hist(phase_diff[12],
             bins=250,
             histtype='stepfilled',
             density=False,
             color='red',
             alpha=0.5)
    plt.hist(phase_diff[13],
             bins=250,
             histtype='stepfilled',
             density=False,
             color='green',
             alpha=0.5)
    patch_1 = mpatches.Patch(color='red', label=':1000_s12r0t0')
    patch_2 = mpatches.Patch(color='green', label=':1000_s13r0t0')
    plt.legend(handles=[patch_1, patch_2])
    plt.title('fig6c: csi-phase_diff')
    plt.xlabel('phase_diff')
    plt.ylabel('packets count')
    plt.tight_layout()
    plt.show()
コード例 #6
0
ファイル: csishow.py プロジェクト: citysu/csiread
def func_2(csidata):
    """CSI: subcarrier-amplitude(CFR)"""
    csi = csidata.get_scaled_csi_sm()
    amplitude = np.abs(csi)
    s_index = scidx(20, 2)

    plt.figure()
    plt.plot(s_index, amplitude[:100, :, 0, 0].T, 'r-', linewidth=0.3)
    plt.plot(s_index, amplitude[:100, :, 1, 0].T, 'g-', linewidth=0.3)
    plt.plot(s_index, amplitude[:100, :, 2, 0].T, 'y-', linewidth=0.3)

    patch_1 = mpatches.Patch(color='red', label=':100_r0t0')
    patch_2 = mpatches.Patch(color='green', label=':100_r1t0')
    patch_3 = mpatches.Patch(color='yellow', label=':100_r2t0')
    plt.legend(handles=[patch_1, patch_2, patch_3])

    plt.title('csi-amplitude')
    plt.xlabel('subcarriers')
    plt.ylabel('amplitude')
    plt.show()
コード例 #7
0
ファイル: csishow.py プロジェクト: citysu/csiread
def func_4(csidata):
    """CSI: subcarrier-phase"""
    csi = csidata.get_scaled_csi_sm()
    s_index = scidx(20, 2)
    phase = np.unwrap(np.angle(csi), axis=1)
    phase = calib(phase, s_index)

    plt.figure(4)
    plt.plot(s_index, phase[:100, :, 0, 0].T, 'r-', linewidth=0.3)
    plt.plot(s_index, phase[:100, :, 1, 0].T, 'g-', linewidth=0.3)
    plt.plot(s_index, phase[:100, :, 2, 0].T, 'y-', linewidth=0.3)

    patch_1 = mpatches.Patch(color='red', label=':100_r0t0')
    patch_2 = mpatches.Patch(color='green', label=':100_r1t0')
    patch_3 = mpatches.Patch(color='yellow', label=':100_r2t0')
    plt.legend(handles=[patch_1, patch_2, patch_3])

    plt.title('csi-phase')
    plt.xlabel('subcarriers')
    plt.ylabel('phase')
    plt.show()
コード例 #8
0
ファイル: csishow.py プロジェクト: citysu/csiread
def func_6(csidata):
    """CSI: time-amplitude(CIR: OFDM symbol view)"""
    csi = csidata.get_scaled_csi_sm()

    s_index = scidx(20, 2)
    amplitude1 = np.abs(phy_ifft(csi[:100, :, 0, 0], s_index, axis=1)).T
    amplitude2 = np.abs(phy_ifft(csi[:100, :, 1, 0], s_index, axis=1)).T
    amplitude3 = np.abs(phy_ifft(csi[:100, :, 2, 0], s_index, axis=1)).T
    t = np.linspace(0, 64, 64)

    plt.figure(6)
    plt.plot(t, amplitude1, 'r-', linewidth=0.3)
    plt.plot(t, amplitude2, 'g-', linewidth=0.3)
    plt.plot(t, amplitude3, 'y-', linewidth=0.3)

    patch_1 = mpatches.Patch(color='red', label=':100_r0t0')
    patch_2 = mpatches.Patch(color='green', label=':100_r1t0')
    patch_3 = mpatches.Patch(color='yellow', label=':100_r2t0')
    plt.legend(handles=[patch_1, patch_2, patch_3])

    plt.title('csi-CIR')
    plt.xlabel('time(50ns)')
    plt.ylabel('amplitude')
    plt.show()
コード例 #9
0
def fig_2(csidata, index=34):
    """fig_2

    Note:
        Fig. 2a uses data collected from a setup where transmitter and receiver arrays
        directly face each other whereas, in Fig. 2b, the receiver is rotated by 90 degrees

    Ref:
        [Power Delay Profile](https://www.gaussianwaves.com/2014/07/power-delay-profile/)
        [From Channel Impulse Response (CIR) to Power Delay Profile (PDP)](https://www.mathworks.com/matlabcentral/answers/44530-from-channel-impulse-response-cir-to-power-delay-profile-pdp)
    """
    csi = csidata.csi

    pdp = np.power(np.abs(phy_ifft(csi, scidx(20, 2), axis=1)),
                   2.0) / csi.shape[1]
    norm = lambda x: x / np.max(x)

    plt.figure()
    plt.plot(norm(pdp[index, :12].reshape(12, -1)))
    plt.title('Anechoic Chamber: $N_{SS}=%d$' % (sum(csi[index, 0, 0] != 0)))
    plt.xlabel('sample index')
    plt.ylabel('PDP')
    plt.tight_layout()
    plt.show()
コード例 #10
0
def derotate_formual16(csi, phi, bw=20, ng=2):
    """De-rotate CSI phase using (16)"""
    k = scidx(bw, ng)[:, np.newaxis, np.newaxis]
    phi = phi[:, np.newaxis, np.newaxis, np.newaxis]
    return np.exp(1j * phi * k) * csi
コード例 #11
0
def derotate_linear(csi, bw=20, ng=2):
    """Windowing/CP removal effect compensation"""
    k = scidx(bw, ng)[:, np.newaxis, np.newaxis]
    phi = -7e-5 * k**3 + 3e-5 * k**2 + 0.05 * k
    return np.exp(-1j * phi) * csi
コード例 #12
0
def formula_16(csi):
    """formula_16"""
    k = scidx(20, 2)[:, np.newaxis, np.newaxis]
    phi = formula_15(csi)[:, np.newaxis, np.newaxis, np.newaxis]
    return np.exp(1j * phi * k) * csi