blob: 575aa74122d0a61a72884053f0f9da46a1589bf6 [file] [log] [blame]
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.ticker import MultipleLocator
from pylab import *
######################################################################################
# ----------------------------------- NR PLOTTING (B) -------------------------------#
######################################################################################
class NR_Plot:
def __init__(self, params):
self.rows = 2
self.cols = 3
self.fig = plt.figure(figsize=(20,10),dpi=80)
self.fig.set_facecolor('black')
self.params = params
self.ssb_idx = 0
def timedomain_plot(self, timedomain_IQ):
time_vec = (1/self.params.sample_rate)*np.arange(len(timedomain_IQ))
ax = plt.subplot(self.rows, self.cols, 1)
ax.set_facecolor('black')
ax.set_title("Time domain IQ", fontsize=16, color='white')
ax.plot(time_vec,np.real(timedomain_IQ), 'cyan', ms=0.)
ax.plot(time_vec,np.imag(timedomain_IQ), 'purple', ms=0.)
ax.yaxis.grid(True, linestyle=':', which='major', color='black',alpha=1.0)
ax.xaxis.grid(True, linestyle=':', which='major', color='black',alpha=1.0)
ax.spines['bottom'].set_color('white')
ax.spines['top'].set_color('white')
ax.spines['right'].set_color('white')
ax.spines['left'].set_color('white')
ax.tick_params(axis='x', colors='white')
ax.tick_params(axis='y', colors='white')
ax.set_xlim(time_vec[0], time_vec[-1])
ymin, ymax = ax.get_ylim()
ax.set_xlabel('Time progression (ms)', color='white')
ax.set_ylabel('Amplitude', color='white')
legend = ax.legend(('I-component','Q-component'), loc='upper center', bbox_to_anchor=(0.5, 1.0),ncol='2')
frame = legend.get_frame()
frame.set_facecolor('black')
frame.set_edgecolor('white')
for text in legend.get_texts():
plt.setp(text, color = 'white')
plt.setp(text, fontsize='12')
def freqdomain_plot(self, timedomain_IQ):
Accum_freqSpectrum_IQ_shifted_main = [0]* len(timedomain_IQ)
# Frequency Span vector
Fs = self.params.sample_rate
N = len(timedomain_IQ)
dF = Fs/N
Accum_slidingWinMat_freqSpectrum_IQ_shifted_main = np.zeros((len(timedomain_IQ), self.params.num_avg_frames))
f_vec = np.arange(-Fs/2,Fs/2,dF)
ax = plt.subplot(self.rows, self.cols, 4)
ax.set_facecolor('black')
ax.yaxis.grid(True, linestyle=':', which='major', color='white',alpha=1.0)
ax.xaxis.grid(True, linestyle=':', which='major', color='white',alpha=1.0)
ax.spines['bottom'].set_color('white')
ax.spines['top'].set_color('white')
ax.spines['right'].set_color('white')
ax.spines['left'].set_color('white')
ax.tick_params(axis='x', colors='white')
ax.tick_params(axis='y', colors='white')
ax.set_title('Frequency Spectrum',fontsize=14, color='white')
ax.set_xlabel('Frequency (MHz)',fontsize=11, color='white')
ax.set_ylabel('Power (dB)',fontsize=11, color='white')
# Compute FFT - Freq. Spectrum
freqSpectrum_IQ_main = (1.0 / self.params.analysis_frame_len) * np.fft.fft(timedomain_IQ)
# Center Freq. Spectrum at 0 Hz
freqSpectrum_IQ_shifted_main = np.fft.fftshift(freqSpectrum_IQ_main)
if (self.params.is_averagedFrames): # Reduce variance of a signal
if (self.params.is_avgSlidingWindow):
# MAIN
Accum_slidingWinMat_freqSpectrum_IQ_shifted_main[:,1:] = Accum_slidingWinMat_freqSpectrum_IQ_shifted_main[:,:-1]
Accum_slidingWinMat_freqSpectrum_IQ_shifted_main[:,0] = np.absolute(freqSpectrum_IQ_shifted_main)
Accum_slidingWinVec_freqSpectrum_IQ_shifted_main = (1.0 / self.params.num_avg_frames) * Accum_slidingWinMat_freqSpectrum_IQ_shifted_main.sum(axis=1)
ax.plot(f_vec, 20.0*np.log10(np.absolute(freqSpectrum_IQ_shifted_main)), 'red',
f_vec, 20.0*np.log10(Accum_slidingWinVec_freqSpectrum_IQ_shifted_main), 'orange')
legendNames = ['Shifted at center freq', 'Avg sliding window']
else:
# MAIN/DIV
Accum_freqSpectrum_IQ_shifted_main = self.Accum_freqSpectrum_IQ_shifted_main + np.absolute(freqSpectrum_IQ_shifted_main)
ax.plot(self.f_vec, 20.0*np.log10(np.absolute(freqSpectrum_IQ_shifted_main)), 'red',
self.f_vec, 20.0*np.log10(Accum_freqSpectrum_IQ_shifted_main/frame_counter), 'orange')
legendNames = ['Main', 'Avg']
else:
ax.plot(self.f_vec, 20.0*np.log10(np.absolute(freqSpectrum_IQ_shifted_main)), 'y')
legendNames = ['Main']
legend = ax.legend((legendNames), loc=1, bbox_to_anchor=(0.5, 1.0), borderaxespad=0.)
frame = legend.get_frame()
frame.set_facecolor('black')
frame.set_edgecolor('white')
for text in legend.get_texts():
plt.setp(text, color = 'w')
plt.setp(text, fontsize='small')
ylimit = np.max(np.ceil(np.absolute(20.0*np.log10(np.absolute(freqSpectrum_IQ_shifted_main)))))
ax.set_ylim([-150, ylimit+10])
ax.set_xlim(self.params.interp_freqSpectrum_lowLimit, self.params.interp_freqSpectrum_upperLimit)
ax.yaxis.grid(True, linestyle=':', which='major', color='white',alpha=1.0)
ax.xaxis.grid(True, linestyle=':', which='major', color='white',alpha=1.0)
ax.set_title('Frequency Spectrum',fontsize=14, color='white')
ax.set_xlabel('Frequency (Hz)',fontsize=11, color='white')
ax.set_ylabel('Power (dB)',fontsize=11, color='white')
def ss_plot(self, ss_results):
# ------------------ PSS PLOT PROCESSING INIT (B) ------------------
PSS_corr_magSQR_output_frame_main = ss_results.PSS_corr_magSQR_output_frame_main # Correlation result
pss_time = len(PSS_corr_magSQR_output_frame_main)
PSS_time_vec_tot = (1/self.params.sample_rate)*np.arange(pss_time)
# ------------------ PSS PLOT PROCESSING INIT (E) ------------------
# ------------------ SSS PLOT PROCESSING INIT (B) ------------------
SSS_corr_magSQR_output_frame_main = ss_results.SSS_corr_magSQR_output_frame_main
sss_time = len(SSS_corr_magSQR_output_frame_main)
SSS_time_vec_tot = (1/self.params.sample_rate)*np.arange(sss_time)
# ------------------ SSS PLOT PROCESSING INIT (E) ------------------
ax = plt.subplot(self.rows, self.cols, 2)
ax.set_facecolor('black')
ax.yaxis.grid(True, linestyle=':', which='major', color='black',alpha=1.0)
ax.xaxis.grid(True, linestyle=':', which='major', color='black',alpha=1.0)
ax.spines['bottom'].set_color('white')
ax.spines['top'].set_color('white')
ax.spines['right'].set_color('white')
ax.spines['left'].set_color('white')
ax.tick_params(axis='x', colors='white')
ax.tick_params(axis='y', colors='white')
ax.plot(PSS_time_vec_tot, PSS_corr_magSQR_output_frame_main,'-', ms=3.0)
ax.plot(SSS_time_vec_tot, SSS_corr_magSQR_output_frame_main,'.-', color='orangered', ms=2.0)
ax.set_xlim([PSS_time_vec_tot[0], PSS_time_vec_tot[-1]])
ax.set_ylim([0.0, 1.0])
ax.xaxis.grid(True, linestyle=':', which='major', color='black',alpha=0.5)
legend = ax.legend(('PSS', 'SSS'), loc='upper center', bbox_to_anchor=(0.5, 1.0),ncol='2', fontsize = 'large')
frame = legend.get_frame()
frame.set_facecolor('white')
frame.set_edgecolor('black')
for text in legend.get_texts():
plt.setp(text, color = 'black')
plt.setp(text, fontsize='large')
ax.set_xlim([PSS_time_vec_tot[0], PSS_time_vec_tot[-1]])
ax.set_ylim([0.0, 1.0])
ax.xaxis.grid(True, linestyle=':', which='major', color='black',alpha=0.5)
ax.set_title('PSS/SSS Correlation Outputs',fontsize=14, color='white')
ax.set_xlabel('Time progression (sec.)',fontsize=14, color='white')
ax.set_ylabel('Amplitude',fontsize=14, color='white')
def resourceGrid_plot(self, half_frame2D_FD_occupiedRB):
sizeRB = 12
Y = np.arange(0, sizeRB*self.params.numRB)
X = np.arange(0, self.params.symAmount*5)
X, Y = np.meshgrid(X, Y)
symAmount = self.params.symAmount
symAmount_5ms = 5*symAmount
ax = plt.subplot(self.rows, self.cols, 3)
ax.set_facecolor('black')
ax.spines['bottom'].set_color('white')
ax.spines['top'].set_color('white')
ax.spines['right'].set_color('white')
ax.spines['left'].set_color('white')
ax.tick_params(axis='x', colors='white')
ax.tick_params(axis='y', colors='white')
colorbar_divider = make_axes_locatable(ax)
cb_axes = colorbar_divider.append_axes("right", size="5%", pad=1.0)
ax.set_title('Five Subframes Resource Grid (Amplitude)',fontsize=14, color='white')
ax.set_xlabel('OFDM symbol index',fontsize=12, color='white')
ax.set_ylabel('Subcarrier index',fontsize=12, color='white')
startSym = 0
ax.cla()
Z = np.absolute(half_frame2D_FD_occupiedRB)
im = ax.imshow(Z,
interpolation='nearest',
cmap="nipy_spectral",
aspect='auto',
origin="lower",
vmin=0.0, vmax=20.0)
major_ticks = np.arange(-0.5, symAmount_5ms+1, symAmount)
minor_ticks = np.arange(-0.5, symAmount_5ms+1, 1)
ax.set_xticks(major_ticks)
ax.set_xticks(minor_ticks, minor=True)
ax.set_xticklabels(np.arange(startSym, symAmount_5ms+startSym+1, symAmount), fontsize=12)
ax.xaxis.grid(b=True, linestyle='-', which='major', color='black',alpha=1.0)
ax.xaxis.grid(b=True, linestyle=':', which='minor', color='black',alpha=0.5)
ax.set_xlim([-0.5, symAmount_5ms-0.5])
ax.set_ylim([-0.5, 240-0.5])
ax.set_title('Five Subframes Resource Grid (Amplitude)',fontsize=14, color='white')
ax.set_xlabel('OFDM symbol index', fontsize=12, color='white')
ax.set_ylabel('Subcarrier index', fontsize=12, color='white')
grid_colorbar = plt.colorbar(im, cax=cb_axes, ticks=MultipleLocator(1.0), format="%.1f")
grid_colorbar_obj = plt.getp(grid_colorbar.ax.axes, 'yticklabels')
plt.setp(grid_colorbar_obj, color='white')
def constellation(self, pbchSymbols, detected_PBCH, place):
ax = plt.subplot(self.rows, self.cols, place)
ax.set_facecolor('black')
ax.spines['bottom'].set_color('white')
ax.spines['top'].set_color('white')
ax.spines['right'].set_color('white')
ax.spines['left'].set_color('white')
ax.tick_params(axis='x', colors='white')
ax.tick_params(axis='y', colors='white')
ax.set_xlabel('In-phase',fontsize=10, color='white')
ax.set_ylabel('Quadrature-phase',fontsize=10, color='white')
colors = ['red', 'green', 'blue', 'white', 'magenta','orange','cyan','pink', 'red', 'green', 'blue', 'white', 'magenta','orange','cyan','pink']
idx_first_PBCHsym = 0
idx_last_PBCHsym = 432
for i in xrange(detected_PBCH):
line1 = ax.scatter(np.real(pbchSymbols[idx_first_PBCHsym:idx_last_PBCHsym]),np.imag(pbchSymbols[idx_first_PBCHsym:idx_last_PBCHsym]),
color=colors[i],label='PBCH-QPSK'+str(self.ssb_idx),s=10,facecolors='none')
idx_first_PBCHsym = idx_last_PBCHsym
idx_last_PBCHsym = idx_first_PBCHsym + 432
self.ssb_idx = self.ssb_idx + 1
if len(pbchSymbols) == 0:
return 0
else:
limit = np.max(np.ceil(np.absolute(pbchSymbols)))
ax.set_xlim([-limit, limit])
ax.set_ylim([-limit, limit])
leg = ax.legend(loc='upper left', fancybox=True, shadow=True)
leg.get_frame().set_alpha(0.4)
lines = [line1]
lined = dict()
for legline, origline in zip(leg.get_lines(), lines):
legline.set_picker(True) # 5 pts tolerance
lined[legline] = origline
def pbchDMRS_plot(self, pbchDMRS_results, amount_of_pbchDMRS):
p = plt.figure(figsize=(10,6), facecolor='black')
p.suptitle("PBCH DM-RS correlations (frequency domain)", fontsize = 'large', color='white')
if amount_of_pbchDMRS > 8:
plotting_count = 8
else:
plotting_count = amount_of_pbchDMRS
max_ssb_candidates = 8
corr_result_length = 144
# init
start = 0
end = 144
for j in xrange(1, plotting_count+1):
s = plt.subplot(2, 4, j, facecolor='black')
plt.subplots_adjust(hspace=0.5)
maxVal = [] # Max values of correlation results
for i in xrange(max_ssb_candidates):
dmrsCorr = pbchDMRS_results[start:end]
dmrsMaxIdx = np.argmax(dmrsCorr)
peakVal = dmrsCorr[dmrsMaxIdx]
maxVal.append(peakVal)
s.set_xlabel('SS block index', fontsize=14, color='white')
s.set_ylabel('Amplitude', fontsize=14, color='white')
s.set_ylim(0.0, 0.8)
s.tick_params(axis='x', colors='white')
s.tick_params(axis='y', colors='white')
s.spines['bottom'].set_color('white')
s.spines['top'].set_color('white')
s.spines['right'].set_color('white')
s.spines['left'].set_color('white')
start = end
end = start + corr_result_length
x = [0, 1, 2, 3, 4, 5, 6, 7]
markerline, stemlines, baseline = stem(x, [maxVal[0], maxVal[1], maxVal[2], maxVal[3], maxVal[4], maxVal[5], maxVal[6], maxVal[7]], '-')
setp(markerline, 'markerfacecolor', 'b')
p.show()
######################################################################################
# ----------------------------------- NR PLOTTING (B) -------------------------------#
######################################################################################
######################################################################################
# --------------------------------- LTE PLOTTING (B) --------------------------------#
######################################################################################
class FreqDomainPlots:
def __init__ (self, params, pos):
self.Accum_freqSpectrum_IQ_shifted_main = [0] * params.analysis_frame_len
# Frequency Span vector
Fs = params.sample_rate
N = params.analysis_frame_len
dF = Fs/N
self.Accum_slidingWinMat_freqSpectrum_IQ_shifted_main = np.zeros( (params.analysis_frame_len,params.num_avg_frames) )
self.f_vec = np.arange(-Fs/2,Fs/2,dF)
self.params = params
self.ax_m = plt.subplot(pos)
self.ax_m.set_facecolor('black')
self.ax_m.yaxis.grid(True, linestyle=':', which='major', color='white',alpha=1.0)
self.ax_m.xaxis.grid(True, linestyle=':', which='major', color='white',alpha=1.0)
self.ax_m.spines['bottom'].set_color('white')
self.ax_m.spines['top'].set_color('white')
self.ax_m.spines['right'].set_color('white')
self.ax_m.spines['left'].set_color('white')
self.ax_m.tick_params(axis='x', colors='white')
self.ax_m.tick_params(axis='y', colors='white')
self.ax_m.set_title('Frequency Spectrum',fontsize=14, color='white')
self.ax_m.set_xlabel('Frequency (MHz)',fontsize=11, color='white')
self.ax_m.set_ylabel('Power (dB)',fontsize=11, color='white')
def process(self, IQ_frame_main_norm):
# Compute FFT - Freq. Spectrum
freqSpectrum_IQ_main = (1.0 / self.params.analysis_frame_len) * np.fft.fft(IQ_frame_main_norm)
# Center Freq. Spectrum at 0 Hz
freqSpectrum_IQ_shifted_main = np.fft.fftshift(freqSpectrum_IQ_main)
self.ax_m.cla()
if (self.params.is_averagedFrames): # Reduce variance of a signal
if (self.params.is_avgSlidingWindow):
# MAIN
self.Accum_slidingWinMat_freqSpectrum_IQ_shifted_main[:,1:] = self.Accum_slidingWinMat_freqSpectrum_IQ_shifted_main[:,:-1]
self.Accum_slidingWinMat_freqSpectrum_IQ_shifted_main[:,0] = np.absolute(freqSpectrum_IQ_shifted_main)
self.Accum_slidingWinVec_freqSpectrum_IQ_shifted_main = (1.0 / self.params.num_avg_frames) * self.Accum_slidingWinMat_freqSpectrum_IQ_shifted_main.sum(axis=1)
self.ax_m.plot(self.f_vec, 20.0*np.log10(np.absolute(freqSpectrum_IQ_shifted_main)), 'red',
self.f_vec, 20.0*np.log10(self.Accum_slidingWinVec_freqSpectrum_IQ_shifted_main), 'orange')
legendNames = ['Shifted at center freq', 'Avg sliding window']
else:
# MAIN/DIV
self.Accum_freqSpectrum_IQ_shifted_main = self.Accum_freqSpectrum_IQ_shifted_main + np.absolute(freqSpectrum_IQ_shifted_main)
self.ax_m.plot(self.f_vec, 20.0*np.log10(np.absolute(freqSpectrum_IQ_shifted_main)), 'red',
self.f_vec, 20.0*np.log10(self.Accum_freqSpectrum_IQ_shifted_main/frame_counter), 'orange')
legendNames = ['Main', 'Avg']
else:
self.ax_m.plot(self.f_vec, 20.0*np.log10(np.absolute(freqSpectrum_IQ_shifted_main)), 'y')
legendNames = ['Main']
legend = self.ax_m.legend((legendNames), loc=1, bbox_to_anchor=(0.5, 1.0), borderaxespad=0.)
frame = legend.get_frame()
frame.set_facecolor('black')
frame.set_edgecolor('white')
for text in legend.get_texts():
plt.setp(text, color = 'w')
plt.setp(text, fontsize='small')
self.ax_m.set_ylim([-150, 0])
self.ax_m.set_xlim(self.params.interp_freqSpectrum_lowLimit, self.params.interp_freqSpectrum_upperLimit)
self.ax_m.yaxis.grid(True, linestyle=':', which='major', color='white',alpha=1.0)
self.ax_m.xaxis.grid(True, linestyle=':', which='major', color='white',alpha=1.0)
self.ax_m.set_title('Frequency Spectrum',fontsize=14, color='white')
self.ax_m.set_xlabel('Frequency (Hz)',fontsize=11, color='white')
self.ax_m.set_ylabel('Power (dB)',fontsize=11, color='white')
def reset(self):
self.Accum_freqSpectrum_IQ_shifted_main = [0] * self.params.analysis_frame_len
class TimeDomainPlots:
def __init__ (self, params, pos):
self.time_vec_10subframes = (1/params.sample_rate)*np.arange(10*params.analysis_frame_len)
self.ax_t_i_main = plt.subplot(pos)
self.ax_t_i_main.set_facecolor('black')
self.ax_t_i_main.yaxis.grid(True, linestyle=':', which='major', color='black',alpha=1.0)
self.ax_t_i_main.xaxis.grid(True, linestyle=':', which='major', color='black',alpha=1.0)
self.ax_t_i_main.spines['bottom'].set_color('white')
self.ax_t_i_main.spines['top'].set_color('white')
self.ax_t_i_main.spines['right'].set_color('white')
self.ax_t_i_main.spines['left'].set_color('white')
self.ax_t_i_main.tick_params(axis='x', colors='white')
self.ax_t_i_main.tick_params(axis='y', colors='white')
self.ax_t_i_main.set_title('Time-Domain IQ Plot',fontsize=14, color='white')
self.ax_t_i_main.set_xlabel('Time progression (millisec.)',fontsize=14, color='white')
self.ax_t_i_main.set_ylabel('Amplitude',fontsize=14, color='white')
def process(self, IQ_full_frame_main):
self.ax_t_i_main.cla()
i_frame = np.real(IQ_full_frame_main)
q_frame = np.imag(IQ_full_frame_main)
maxValueIdx = np.argmax(i_frame)
maxValue = i_frame[maxValueIdx]
self.ax_t_i_main.plot(1000*self.time_vec_10subframes, i_frame,'cyan', ms=0.5)
self.ax_t_i_main.plot(1000*self.time_vec_10subframes, q_frame,'purple', ms=0.5)
self.ax_t_i_main.set_xlim([self.time_vec_10subframes[0], self.time_vec_10subframes[-1]])
self.ax_t_i_main.set_ylim([-maxValue, maxValue])
self.ax_t_i_main.set_xticks(np.arange(0, 11))
self.ax_t_i_main.xaxis.grid(True, linestyle=':', which='major', color='white',alpha=0.5)
self.ax_t_i_main.set_title('Time-Domain IQ Plot', fontsize=14, color='white')
self.ax_t_i_main.set_xlabel('Time progression (millisec.)',fontsize=14, color='white')
self.ax_t_i_main.set_ylabel('Amplitude', fontsize=14, color='white')
legend = self.ax_t_i_main.legend(('I-component','Q-component'), loc='upper center', bbox_to_anchor=(0.5, 1.0),ncol='2')
frame = legend.get_frame()
frame.set_facecolor('black')
frame.set_edgecolor('white')
for text in legend.get_texts():
plt.setp(text, color = 'white')
plt.setp(text, fontsize='12')
class PssCorrPlots:
def __init__ (self, params, pos):
self.params = params
self.frame_len = params.analysis_frame_len
self.ax_pss_main = plt.subplot(pos)
self.ax_pss_main.set_facecolor('black')
self.ax_pss_main.yaxis.grid(True, linestyle=':', which='major', color='white',alpha=1.0)
self.ax_pss_main.xaxis.grid(True, linestyle=':', which='major', color='white',alpha=1.0)
self.ax_pss_main.spines['bottom'].set_color('white')
self.ax_pss_main.spines['top'].set_color('white')
self.ax_pss_main.spines['right'].set_color('white')
self.ax_pss_main.spines['left'].set_color('white')
self.ax_pss_main.tick_params(axis='x', colors='white')
self.ax_pss_main.tick_params(axis='y', colors='white')
self.ax_pss_main.set_title('PSS/SSS Correlation Outputs',fontsize=14, color='white')
self.ax_pss_main.set_xlabel('Time progression (millisec.)',fontsize=14, color='white')
self.ax_pss_main.set_ylabel('Amplitude',fontsize=14, color='white')
self.params = params
# LTE
def process(self, pss):
PSS_time_vec_tot = (1/self.params.sample_rate)*np.arange(self.params.analysis_frame_len*10)
PSS_corr_magSQR_output_frame_main = pss.PSS_corr_magSQR_output_frame_main
PSS_peak_detected = pss.PSS_peak_detected
PSS_Subframe_max_idx = pss.PSS_Subframe_max_idx
PSS_Subframe_max_val = pss.PSS_Subframe_max_val
SSS_corr_magSQR_output_frame_main = pss.SSS_corr_magSQR_output_frame_main
SSS_peak_detected = pss.SSS_peak_detected
SSS_Subframe_max_idx = pss.SSS_Subframe_max_idx
SSS_Subframe_max_val = pss.SSS_Subframe_max_val
self.ax_pss_main.cla()
self.ax_pss_main.plot(1000*PSS_time_vec_tot,PSS_corr_magSQR_output_frame_main,'.-', color='green', ms=2.0)
self.ax_pss_main.plot(1000*PSS_time_vec_tot,SSS_corr_magSQR_output_frame_main,'.-', color='lightgreen', ms=2.0)
if (PSS_peak_detected == 1):
peak_idx = (1/self.params.sample_rate)*(9*self.params.analysis_frame_len+PSS_Subframe_max_idx)
self.ax_pss_main.plot(1000*peak_idx,PSS_Subframe_max_val,marker="o", color='red', ms=10.0)
if (SSS_peak_detected == 1):
peak_idx = (1/self.params.sample_rate)*(9*self.params.analysis_frame_len+SSS_Subframe_max_idx)
self.ax_pss_main.plot(1000*peak_idx,SSS_Subframe_max_val,marker="o", color='pink', ms=10.0)
self.ax_pss_main.set_xlim([PSS_time_vec_tot[0], PSS_time_vec_tot[-1]])
self.ax_pss_main.set_yticklabels(fontsize=20)
self.ax_pss_main.set_ylim([0.0,0.5])
self.ax_pss_main.set_xticks([0.0,0.0010666,0.0021332,0.0031998,0.00426641,0.00533301,0.00639961,0.00746621,0.00853281,0.00959941,0.01066602])
self.ax_pss_main.xaxis.grid(True, linestyle=':', which='major', color='white',alpha=0.5)
self.ax_pss_main.set_title('PSS/SSS Correlation Outputs',fontsize=14, color='white')
self.ax_pss_main.set_xlabel('Time progression (millisec.)',fontsize=20, color='white')
self.ax_pss_main.set_ylabel('Amplitude',fontsize=20, color='white')
class ResourceGrid:
def __init__ (self, params, pos):
sizeRB = 12
Y = np.arange(0, sizeRB*params.numRB)
X = np.arange(0, params.symAmount*5)
X, Y = np.meshgrid(X, Y)
self.symAmount = params.symAmount
self.symAmount_5ms = 5*self.symAmount
self.ax_5msFD_grid_main = plt.subplot(pos)
self.ax_5msFD_grid_main.set_facecolor('black')
self.ax_5msFD_grid_main.spines['bottom'].set_color('white')
self.ax_5msFD_grid_main.spines['top'].set_color('white')
self.ax_5msFD_grid_main.spines['right'].set_color('white')
self.ax_5msFD_grid_main.spines['left'].set_color('white')
self.ax_5msFD_grid_main.tick_params(axis='x', colors='white')
self.ax_5msFD_grid_main.tick_params(axis='y', colors='white')
self.colorbar_divider = make_axes_locatable(self.ax_5msFD_grid_main)
self.cb_axes = self.colorbar_divider.append_axes("right", size="5%", pad=1.0)
self.ax_5msFD_grid_main.set_title('Five Subframes Resource Grid (Amplitude)',fontsize=14, color='white')
self.ax_5msFD_grid_main.set_xlabel('OFDM symbol index',fontsize=12, color='white')
self.ax_5msFD_grid_main.set_ylabel('Subcarrier index',fontsize=12, color='white')
self.startSym = 0
def process(self, half_frame2D_FD_occupiedRB):
self.ax_5msFD_grid_main.cla()
Z = np.absolute(half_frame2D_FD_occupiedRB)
im = self.ax_5msFD_grid_main.imshow(Z,
interpolation='nearest',
cmap="nipy_spectral",
aspect='auto',
origin="lower",
vmin=0.0, vmax=20.0)
self.startSym = 0
major_ticks = np.arange(-0.5, self.symAmount_5ms+1, self.symAmount)
minor_ticks = np.arange(-0.5, self.symAmount_5ms+1, 1)
self.ax_5msFD_grid_main.set_xticks(major_ticks)
self.ax_5msFD_grid_main.set_xticks(minor_ticks, minor=True)
self.ax_5msFD_grid_main.set_xticklabels(np.arange(self.startSym, self.symAmount_5ms+self.startSym+1, self.symAmount), fontsize=12)
self.ax_5msFD_grid_main.xaxis.grid(b=True, linestyle='-', which='major', color='black',alpha=1.0)
self.ax_5msFD_grid_main.xaxis.grid(b=True, linestyle=':', which='minor', color='black',alpha=0.5)
self.ax_5msFD_grid_main.set_xlim([-0.5, self.symAmount_5ms-0.5])
self.ax_5msFD_grid_main.set_ylim([-0.5, 240-0.5])
self.ax_5msFD_grid_main.set_title('Five Subframes Resource Grid (Amplitude)',fontsize=14, color='white')
self.ax_5msFD_grid_main.set_xlabel('OFDM symbol index', fontsize=12, color='white')
self.ax_5msFD_grid_main.set_ylabel('Subcarrier index', fontsize=12, color='white')
self.grid_colorbar = plt.colorbar(im, cax=self.cb_axes, ticks=MultipleLocator(1.0), format="%.1f")
self.grid_colorbar_obj = plt.getp(self.grid_colorbar.ax.axes, 'yticklabels')
plt.setp(self.grid_colorbar_obj, color='white')
class PilotsPlots:
def __init__ (self, params, pos, idx):
self.idx = idx
self.ax_pilots_sf0_main = plt.subplot(pos)
self.ax_pilots_sf0_main.set_facecolor('black')
self.ax_pilots_sf0_main.spines['bottom'].set_color('white')
self.ax_pilots_sf0_main.spines['top'].set_color('white')
self.ax_pilots_sf0_main.spines['right'].set_color('white')
self.ax_pilots_sf0_main.spines['left'].set_color('white')
self.ax_pilots_sf0_main.tick_params(axis='x', colors='white')
self.ax_pilots_sf0_main.tick_params(axis='y', colors='white')
self.ax_pilots_sf0_main.set_title('IQ Raw Pilots (S'+ str(self.idx) + ')',fontsize=12, color='white')
self.ax_pilots_sf0_main.set_xlabel('In-phase',fontsize=10, color='white')
self.ax_pilots_sf0_main.set_ylabel('Quadrature',fontsize=10, color='white')
def process(self,Pilots_5subFrames_RAW):
lim_vec = [-10.0,10.0]
colors_ = ['blue','green','red','cyan','yellow']
add_idx = self.idx * 4
self.ax_pilots_sf0_main.cla()
for kk in xrange(4):
self.ax_pilots_sf0_main.scatter(np.real(Pilots_5subFrames_RAW[:,add_idx+kk]),np.imag(Pilots_5subFrames_RAW[:,add_idx+kk]),color=colors_[kk], s=1.0)
self.ax_pilots_sf0_main.set_aspect('equal')
self.ax_pilots_sf0_main.set_xlim(lim_vec)
self.ax_pilots_sf0_main.set_ylim(lim_vec)
self.ax_pilots_sf0_main.set_title('IQ Raw Pilots (S'+ str(self.idx) + ')',fontsize=12, color='white')
self.ax_pilots_sf0_main.set_xlabel('In-phase',fontsize=10, color='white')
self.ax_pilots_sf0_main.set_ylabel('Quadrature',fontsize=10, color='white')
class PilotsPhasePlots:
def __init__ (self, params, pos, idx):
self.idx = idx
self.ax_pilots_phase_sf0_main = plt.subplot(pos)
self.ax_pilots_phase_sf0_main.set_facecolor('black')
self.ax_pilots_phase_sf0_main.spines['bottom'].set_color('white')
self.ax_pilots_phase_sf0_main.spines['top'].set_color('white')
self.ax_pilots_phase_sf0_main.spines['right'].set_color('white')
self.ax_pilots_phase_sf0_main.spines['left'].set_color('white')
self.ax_pilots_phase_sf0_main.tick_params(axis='x', colors='white')
self.ax_pilots_phase_sf0_main.tick_params(axis='y', colors='white')
self.ax_pilots_phase_sf0_main.set_title('Mag/Phase Pilots (S'+ str(self.idx) + ')',fontsize=12, color='white')
self.ax_pilots_phase_sf0_main.set_xlabel('In-phase',fontsize=10, color='white')
self.ax_pilots_phase_sf0_main.set_ylabel('Quadrature',fontsize=10, color='white')
def process(self,CSRS_ChannelEst_RAW):
lim_vec = [-10.0,10.0]
colors_ = ['blue','green','red','cyan','yellow']
add_idx = self.idx * 4
self.ax_pilots_phase_sf0_main.cla()
for kk in xrange(0,4):
self.ax_pilots_phase_sf0_main.scatter(np.real(CSRS_ChannelEst_RAW[:,add_idx+kk]),np.imag(CSRS_ChannelEst_RAW[:,add_idx+kk]),color=colors_[kk], s=1.0)
self.ax_pilots_phase_sf0_main.set_aspect('equal')
self.ax_pilots_phase_sf0_main.set_xlim(lim_vec)
self.ax_pilots_phase_sf0_main.set_ylim(lim_vec)
self.ax_pilots_phase_sf0_main.set_title('Mag/Phase Pilots (S'+ str(self.idx) + ')',fontsize=12, color='white')
self.ax_pilots_phase_sf0_main.set_xlabel('In-phase',fontsize=10, color='white')
self.ax_pilots_phase_sf0_main.set_ylabel('Quadrature',fontsize=10, color='white')
class CompensatedDataPlots:
def __init__ (self, params, pos, idx):
self.idx = idx
self.ax_data_sf0 = plt.subplot(pos)
self.ax_data_sf0.set_facecolor('black')
self.ax_data_sf0.spines['bottom'].set_color('white')
self.ax_data_sf0.spines['top'].set_color('white')
self.ax_data_sf0.spines['right'].set_color('white')
self.ax_data_sf0.spines['left'].set_color('white')
self.ax_data_sf0.tick_params(axis='x', colors='white')
self.ax_data_sf0.tick_params(axis='y', colors='white')
if self.idx == 0:
self.ax_data_sf0.set_title('IQ Scatter (Subframe 0)',fontsize=14, color='white')
self.legend = self.ax_data_sf0.legend(('Slot 0','Slot 1'),loc='upper left', bbox_to_anchor=(1.0, 1.0))
self.frame = self.legend.get_frame()
self.frame.set_facecolor('black')
self.frame.set_edgecolor('white')
for text in self.legend.get_texts():
plt.setp(text, color = 'w')
else:
self.ax_data_sf0.set_title('IQ Scatter (Subframe ' + str(idx) +')',fontsize=14, color='white')
self.ax_data_sf0.set_xlabel('In-phase',fontsize=11, color='white')
self.ax_data_sf0.set_ylabel('Quadrature',fontsize=11, color='white')
def process (self, full_phaseComp_mat):
ofdm_sym = [1,2,3,5,6]
lim_vec = [-2.0,2.0]
self.ax_data_sf0.cla()
self.ax_data_sf0.cla()
self.ax_data_sf0.cla()
for kk in xrange(5):
_offset_ = self.idx * 14
self.ax_data_sf0.scatter(np.real(full_phaseComp_mat[:,ofdm_sym[kk]+_offset_]),np.imag(full_phaseComp_mat[:,ofdm_sym[kk]+_offset_]),color='magenta', s=1.0)
_offset_ = _offset_ + 7
self.ax_data_sf0.scatter(np.real(full_phaseComp_mat[:,ofdm_sym[kk]+_offset_]),np.imag(full_phaseComp_mat[:,ofdm_sym[kk]+_offset_]),color='yellow', s=1.0)
self.ax_data_sf0.set_aspect('equal')
self.ax_data_sf0.set_xlim(lim_vec)
self.ax_data_sf0.set_ylim(lim_vec)
self.ax_data_sf0.set_xlabel('In-phase',fontsize=11, color='white')
self.ax_data_sf0.set_ylabel('Quadrature',fontsize=11, color='white')
if self.idx == 0:
self.ax_data_sf0.set_title('IQ Scatter (Subframe 0)',fontsize=14, color='white')
self.legend = self.ax_data_sf0.legend(('Slot 0','Slot 1'),loc='upper left', bbox_to_anchor=(1.0, 1.0))
self.frame = self.legend.get_frame()
self.frame.set_facecolor('black')
self.frame.set_edgecolor('white')
for text in self.legend.get_texts():
plt.setp(text, color = 'w')
else:
self.ax_data_sf0.set_title('Subframe ' + str(self.idx) ,fontsize=14, color='white')
######################################################################################
# ---------------------------------- LTE PLOTTING (E) -------------------------------#
######################################################################################