Exemplo n.º 1
0
def plotEachLantencyCDF(uedata, saveFolderName=""):
    global figureCount
    for data in uedata:
        fig = plt.figure(figureCount)
        figureCount = figureCount + 1
        fig.set_size_inches(9.375, 7.3)
        #fig.subplots_adjust(top=0.83)
        fig.set_size_inches(9.375, 7.3)
        ax = plt.subplot(1, 1, 1)

        plt.xlabel("Latency (ms)", fontsize=label_font_size)
        plt.ylabel("CDF", fontsize=label_font_size)
        #plt.suptitle("UE Latency CDF", fontsize=title_font_size, fontweight="bold")
        latency = data['latency']
        prachIndex = data['prachIndex']
        simulationTime = data['simulationTime']
        arrivalMode = data['arrivalMode']
        arrival = data['arrival']
        subTitle = "RA Subframe Period: {0}ms, ".format(getSubframePeriod(prachIndex)) \
                + "Simulation Time: {0}s\n".format(str(int(simulationTime))) \
                + "Arrival Mode: {0}, ".format(arrivalMode)
        if arrivalMode == "uniform":
            subTitle = subTitle + "Arrival Rate: {0}".format(arrival)
        else:
            subTitle = subTitle + "Totle UE: {0}".format(arrival)
        filenameFig = "CDF_prach-{0}_simu-{1}_{2}_arrival-{3}".format(prachIndex,
                simulationTime,
                arrivalMode,
                arrival)
        #ax.set_title(subTitle, fontsize=title_font_size)

        latency.insert(0, 0)
        X = np.linspace(min(latency), max(latency), max(latency) - min(latency))
        hist, bin_edges = np.histogram(latency, bins=max(latency) - min(latency), density=True)
        hist = np.cumsum(hist)

        for label in (ax.get_xticklabels() + ax.get_yticklabels()):
            label.set_fontsize(16)

        plt.plot(X, hist, 'b-', linewidth=line_width)
        plt.axis([0, max(latency), 0, 1.1])
        plt.grid(True)
        if saveFolderName:
            plt.savefig(saveFolderName + filenameFig)
            plt.close()
    del X
    del hist
    del bin_edges
Exemplo n.º 2
0
def plotCellMsg1FDM(celldatas, folderName=""):
    global figureCount
    fig = plt.figure(figureCount)
    fig.set_size_inches(9.375, 7.3)
    #fig.subplots_adjust(top=0.83)
    simulationTime = celldatas[0]['simulationTime']
    arrivalMode = celldatas[0]['arrivalMode']
    arrival = celldatas[0]['arrival']
    maxTiming = max([max(t['timing']) for t in celldatas])
    ax = plt.subplot(1, 1, 1)
    figureCount = figureCount + 1
    attr = ['b-o', 'm-D', 'c-s', 'r-^', 'g-*']
    i = 0
    for data in celldatas:
        preambleBW = [fdm*data['preambleLength']*float(data['preambleSCS'])/1000 for fdm in data['msg1FDM']]
        if i == 0:
            ax.plot(data['timing'], preambleBW, attr[i], label='RA Subframe Period='+str(getSubframePeriod(int(data['prachIndex'])))+"ms", linewidth=line_width, markersize=marker_size)
        elif i == 1:
            ax.plot(data['timing'], preambleBW, attr[i], label='RA Subframe Period='+str(getSubframePeriod(int(data['prachIndex'])))+"ms", linewidth=line_width, markersize=marker_size + 10, fillstyle="none", markeredgewidth=3.0)
        elif i == 2:
            ax.plot(data['timing'], preambleBW, attr[i], label='RA Subframe Period='+str(getSubframePeriod(int(data['prachIndex'])))+"ms", linewidth=line_width, markersize=marker_size + 5)
        elif i == 4:
            ax.plot(data['timing'], preambleBW, attr[i], label='RA Subframe Period='+str(getSubframePeriod(int(data['prachIndex'])))+"ms", linewidth=line_width, markersize=marker_size + 5)
        else:
            ax.plot(data['timing'], preambleBW, attr[i], label='RA Subframe Period='+str(getSubframePeriod(int(data['prachIndex'])))+"ms", linewidth=line_width, markersize=marker_size)
        i = i + 1

    newYTick = [fdm*celldatas[0]['preambleLength']*float(celldatas[0]['preambleSCS'])/1000 for fdm in [1, 2, 4, 8]]

    xtick = math.ceil(maxTiming / 160)
    xtick = [(x * 160) for x in range(xtick + 1)]

    #plt.xticks(xtick)
    plt.yticks(newYTick)
    ax.legend(loc='upper left', fontsize=legend_font_size)
    ax.set_xlim(0, maxTiming)
    ax.set_ylim(0, math.ceil(max(newYTick) / 10) * 2 * 10)
    for label in (ax.get_xticklabels() + ax.get_yticklabels()):
        label.set_fontsize(16)
    ax.grid(True)
    plt.xlabel("Subframe Index", fontsize=label_font_size)
    plt.ylabel("Preamble Occupied Bandwidth (MHz)",fontsize=label_font_size)
    #plt.suptitle("RA Used Bandwidth", fontsize=title_font_size, fontweight="bold")
    title = "Simulation Time: {0}s\nArrival Mode:{1}".format(simulationTime, arrivalMode)
    if arrivalMode == "uniform":
        title = title + ", Arrival Rate:{0}".format(arrival)
    else:
        title = title + ", Total UE:{0}".format(arrival)
    filename = "msg1FDM_simu-{0}_{1}_arrival-{2}.png".format(simulationTime,
            arrivalMode,
            arrival)
    #plt.title(title, fontsize=title_font_size)
    plt.savefig(folderName + filename)
    plt.close()
Exemplo n.º 3
0
     filename = resultSourceFolder + folderName[maxIndex] + "/" + ueFile
     latency = [x['latency'] for x in collectDataUE(filename).values()]
     ue_data = {'latency':latency, 'prachIndex':prachIndex[maxIndex], 'simulationTime':simulationTime[maxIndex], 'arrivalMode':arrivalMode[maxIndex], 'arrival':arrival[maxIndex]}
     #### get ue data ####
     #### get cell data ####
     filename = resultSourceFolder + folderName[maxIndex] + "/" + cellFile
     if plot_optimized:
         preambleSCS, timing, msg1FDM, msg1FDMOp = collectCellMsg1FDM(filename)
     else:
         preambleSCS, timing, msg1FDM = collectCellMsg1FDM(filename)
     cell_data = {'prachIndex':prachIndex[maxIndex], 'preambleSCS':preambleSCS, 'preambleLength':getPreambleLength(float(preambleSCS)), 'timing':timing, 'msg1FDM':msg1FDM, 'simulationTime':simulationTime[maxIndex], 'arrivalMode': arrivalMode[maxIndex], 'arrival':arrival[maxIndex]}
     if plot_optimized:
         cell_data['msg1FDMOp'] = msg1FDMOp
     #### get cell data ####
     if arrivalMode[maxIndex] == "uniform":
         avgs_uniform[getSubframePeriod(int(prachIndex[maxIndex]))] = np.mean(latency)
         cell_uniform.append(cell_data)
         ue_uniform.append(ue_data)
     else:
         avgs_beta[getSubframePeriod(int(prachIndex[maxIndex]))] = np.mean(latency)
         cell_beta.append(cell_data)
         ue_beta.append(ue_data)
 
 #    plotLantencyCDF(latency, prachIndex[maxIndex], simulationTime[maxIndex], arrivalMode[maxIndex], arrival[maxIndex], resultSourceFolder)
     del prachIndex[maxIndex]
     del simulationTime[maxIndex]
     del arrivalMode[maxIndex]
     del arrival[maxIndex]
     del folderName[maxIndex]
 
 print(avgs_uniform)
Exemplo n.º 4
0
def plotLantencyCDF(uedatas, saveFolderName=""):
    print("Plotting Latency CDF...")
    global figureCount
    for arrivalMode in ['uniform', 'beta']:
        for prach in [16, 19, 22, 25, 27]:
            for simulation in [1]:
                fig = plt.figure(figureCount)
                figureCount = figureCount + 1
                fig.set_size_inches(9.375, 7.3)
                #fig.subplots_adjust(top=0.83)
                ax = plt.subplot(1, 1, 1)

                plt.xlabel("Latency (ms)", fontsize=label_font_size)
                plt.ylabel("CDF",fontsize=label_font_size)
                #plt.suptitle("UE Latency CDF", fontsize=title_font_size, fontweight="bold")
                for tau in [10, 20, 40, 80, 160]:
                    candidateIndex = findCandidate(tau, str(prach), arrivalMode, str(simulation), uedatas)
                    data = uedatas[candidateIndex]
                    latency = data['latency']
                    arrival = data['arrival']
                    subTitle = "RA Subframe Period: {0}ms Simulation Time: {1}s\n".format(str(getSubframePeriod(prach)), str(simulation)) \
                            + "Arrival Mode: {0}, ".format(arrivalMode)
                    if arrivalMode == "uniform":
                        subTitle = subTitle + "Arrival Rate: {0}".format(arrival)
                    else:
                        subTitle = subTitle + "Total UE: {0}".format(arrival)
                    #ax.set_title(subTitle, fontsize=title_font_size)
                    
                    latency.insert(0, 0)
                    X = np.linspace(min(latency), max(latency), max(latency) - min(latency))
                    hist, bin_edges = np.histogram(latency, bins=max(latency) - min(latency), density=True)
                    hist = np.cumsum(hist)

                    plt.plot(X, hist, label=r"$\tau\ Threshold$="+str(tau), linewidth=line_width)
                    ax.legend(loc="lower right", fontsize=legend_font_size)
                    for label in (ax.get_xticklabels() + ax.get_yticklabels()):
                        label.set_fontsize(16)
                filenameFig = "latency_CDF_prach-{0}_simu-{1}_{2}_arrival-{3}".format(prach,
                        simulation,
                        arrivalMode,
                        arrival)
                plt.axis([0, max(latency), 0, 1.1])
                plt.grid(True)
                if saveFolderName:
                    plt.savefig(saveFolderName + arrivalMode + "/"  + filenameFig)
                    plt.close()
                del X
                del hist
                del bin_edges
Exemplo n.º 5
0
def plotCellTau(celldatas, saveFolderName=""):
    print("Plotting Tau...")
    global figureCount
    for arrivalMode in ['uniform', 'beta']:
        for prach in [16, 19, 22, 25, 27]:
            for simulation in [1]:
                fig = plt.figure(figureCount)
                figureCount = figureCount + 1
                fig.set_size_inches(9.375, 7.3)
                #fig.subplots_adjust(top=0.83)
                ax = plt.subplot(1, 1, 1)

                plt.xlabel("Subframe Index", fontsize=label_font_size)
                plt.ylabel(r"RA Attempt Period $\tau$", fontsize=label_font_size)
                #plt.suptitle(r"RA Attempt Period $\tau$ For Each $\tau$ Threshold", fontsize=title_font_size, fontweight="bold")
                i = 0
                attr = ['b-s', 'r-o', 'm-D', 'c-^', 'g-v']
                maxTiming = 0
                maxTau = 0
                for tau in [10, 20, 40, 80, 160]:
                    candidateIndex = findCandidate(tau, str(prach), arrivalMode, str(simulation), celldatas)
                    data = celldatas[candidateIndex]
                    arrival = data['arrival']
                    subTitle = "RA Subframe Period: {0}".format(str(getSubframePeriod(prach))) \
                            + " Simulation Time: {0}\n".format(str(simulation)) \
                            + "Arrival Mode: {0}, ".format(arrivalMode)
                    if arrivalMode == "uniform":
                        subTitle = subTitle + "Arrival Rate: {0}".format(arrival)
                    else:
                        subTitle = subTitle + "Total UE: {0}".format(arrival)
                    #ax.set_title(subTitle, fontsize=title_font_size)
                    
                    maxTiming = max([maxTiming, max(data['timing'])])
                    maxTau = max([maxTau, max(data['RA attempt period'])])
                    if i == 0:
                        ax.plot(data['timing'], data['RA attempt period'], attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size + 7)
                    elif i == 2:
                        ax.plot(data['timing'], data['RA attempt period'], attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size + 7, fillstyle="none", markeredgewidth=3.0)
                    elif i == 1:
                        ax.plot(data['timing'], data['RA attempt period'], attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size + 5)
                    elif i == 3:
                        ax.plot(data['timing'], data['RA attempt period'], attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size + 3)
                    else:
                        ax.plot(data['timing'], data['RA attempt period'], attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size)
                    i = i + 1
                    for label in (ax.get_xticklabels() + ax.get_yticklabels()):
                        label.set_fontsize(16)
                filenameFig = "RA_attempt_periodprach-{0}_simu-{1}_{2}_arrival-{3}".format(prach,
                        simulation,
                        arrivalMode,
                        arrival)
                xtick = math.ceil(maxTiming / 160)
                xtick = [(x * 160) for x in range(xtick + 1)]
                ax.legend(loc="upper left", fontsize=legend_font_size, ncol=2)
                ax.set_xlim(0, maxTiming)
                ax.set_ylim(0, 220)
                #exponential = math.floor(log(maxTau, 10))
                #coef = maxTau / pow(10, exponential)
                #maxTau = (coef + 1) * pow(10, exponential)
                #ax.set_ylim(0, maxTau)
                plt.grid(True)
                if saveFolderName:
                    plt.savefig(saveFolderName + arrivalMode + "/"  + filenameFig)
                    plt.close()
Exemplo n.º 6
0
def plotCellSSBPerRAO(celldatas, saveFolderName=""):
    print("Plotting SSB per RAO...")
    global figureCount
    newYTick = [0.125, 0.25, 0.5, 1, 2, 4, 8, 16]
    for arrivalMode in ['uniform', 'beta']:
        for prach in [16, 19, 22, 25, 27]:
            for simulation in [1]:
                fig = plt.figure(figureCount)
                figureCount = figureCount + 1
                fig.set_size_inches(9.375, 7.3)
                #fig.subplots_adjust(top=0.83)
                ax = plt.subplot(1, 1, 1)

                plt.xlabel("Subframe Index", fontsize=label_font_size)
                plt.ylabel(r"SSB Per RAO $S_{RAO}$", fontsize=label_font_size)
                #plt.suptitle(r"Number of SSB Per RAO $S_{RAO}$ For Each $\tau$ Threshold", fontsize=title_font_size, fontweight="bold")
                plt.yticks(newYTick)
                i = 0
                attr = ['b-^', 'r-o', 'm-D', 'c-s', 'g-v']
                maxTiming = 0
                for tau in [10, 20, 40, 80, 160]:
                    candidateIndex = findCandidate(tau, str(prach), arrivalMode, str(simulation), celldatas)
                    data = celldatas[candidateIndex]
                    arrival = data['arrival']
                    subTitle = "RA SubframePeriod: {0}ms".format(str(getSubframePeriod(prach))) \
                            + " Simulation Time: {0}s\n".format(str(simulation)) \
                            + "Arrival Mode: {0}, ".format(arrivalMode)
                    if arrivalMode == "uniform":
                        subTitle = subTitle + "Arrival Rate: {0}".format(arrival)
                    else:
                        subTitle = subTitle + "Total UE: {0}".format(arrival)
                    #ax.set_title(subTitle, fontsize=title_font_size)
                    
                    maxTiming = max([maxTiming, max(data['timing'])])
                    if i == 4:
                        ax.plot(data['timing'], data['ssbPerRAO'], attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size + 9, fillstyle="none", markeredgewidth=3.0)
                    elif i == 2:
                        ax.plot(data['timing'], data['ssbPerRAO'], attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size + 3, fillstyle="none", markeredgewidth=3.0)
                    elif i == 1:
                        ax.plot(data['timing'], data['ssbPerRAO'], attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size + 5)
                    elif i == 0:
                        ax.plot(data['timing'], data['ssbPerRAO'], attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size + 7)
                    else:
                        ax.plot(data['timing'], data['ssbPerRAO'], attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size)
                    i = i + 1
                    for label in (ax.get_xticklabels() + ax.get_yticklabels()):
                        label.set_fontsize(16)
                filenameFig = "S_RAO_prach-{0}_simu-{1}_{2}_arrival-{3}".format(prach,
                        simulation,
                        arrivalMode,
                        arrival)
                xtick = math.ceil(maxTiming / 160)
                xtick = [(x * 160) for x in range(xtick + 1)]
                ax.legend(loc="upper left", fontsize=legend_font_size)
                ax.set_xlim(0, maxTiming)
                ax.set_ylim(newYTick[0], newYTick[-1])
                ax.set_yscale('log', basey=2)
                plt.xticks(xtick)
                plt.grid(True)
                if saveFolderName:
                    plt.savefig(saveFolderName + arrivalMode + "/"  + filenameFig)
                    plt.close()
Exemplo n.º 7
0
def plotCellMsg1FDM(celldatas, saveFolderName=""):
    print("Plotting Msg1FDM...")
    global figureCount
    newYTick = [fdm*celldatas[0]['preambleLength']*float(celldatas[0]['preambleSCS'])/1000 for fdm in [1, 2, 4, 8]]
    for arrivalMode in ['uniform', 'beta']:
        for prach in [16, 19, 22, 25, 27]:
            for simulation in [1]:
                fig = plt.figure(figureCount)
                figureCount = figureCount + 1
                fig.set_size_inches(9.375, 7.3)
                #fig.subplots_adjust(top=0.83)
                ax = plt.subplot(1, 1, 1)

                plt.xlabel("Subframe Index", fontsize=label_font_size)
                plt.ylabel("Preamble Occupied Bandwidth (MHz)", fontsize=label_font_size)
                #plt.suptitle(r"RA Used Bandwidth For Each $\tau$ Threshold", fontsize=title_font_size, fontweight="bold")
                plt.yticks(newYTick)
                i = 0
                attr = ['b-^', 'r-o', 'm-D', 'c-s', 'g-p']
                maxTiming = 0
                for tau in [10, 20, 40, 80, 160]:
                    candidateIndex = findCandidate(tau, str(prach), arrivalMode, str(simulation), celldatas)
                    data = celldatas[candidateIndex]
                    arrival = data['arrival']
                    subTitle = "RA Subframe Period: {0}ms".format(str(getSubframePeriod(prach))) \
                            + " Simulation Time: {0}s\n".format(str(simulation)) \
                            + "Arrival Mode: {0}, ".format(arrivalMode)
                    if arrivalMode == "uniform":
                        subTitle = subTitle + "Arrival Rate: {0}".format(arrival)
                    else:
                        subTitle = subTitle + "Total UE: {0}".format(arrival)
                    #ax.set_title(subTitle, fontsize=title_font_size)
                    
                    preambleBW = [fdm*data['preambleLength']*float(data['preambleSCS'])/1000 for fdm in data['msg1FDM']]
                    maxTiming = max([maxTiming, max(data['timing'])])
                    if i == 3:
                        ax.plot(data['timing'], preambleBW, attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size + 3, fillstyle="none", markeredgewidth=3.0)
                    elif i == 2:
                        ax.plot(data['timing'], preambleBW, attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size + 2, fillstyle="none", markeredgewidth=4.0)
                    elif i == 1:
                        ax.plot(data['timing'], preambleBW, attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size + 2)
                    elif i == 0:
                        ax.plot(data['timing'], preambleBW, attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size + 9)
                    else:
                        ax.plot(data['timing'], preambleBW, attr[i], label=r'$\tau\ Threshold$='+str(tau), linewidth=line_width, markersize=marker_size)
                    i = i + 1
                    for label in (ax.get_xticklabels() + ax.get_yticklabels()):
                        label.set_fontsize(16)
                filenameFig = "RA_Used_BW_prach-{0}_simu-{1}_{2}_arrival-{3}".format(prach,
                        simulation,
                        arrivalMode,
                        arrival)
                xtick = math.ceil(maxTiming / 160)
                xtick = [(x * 160) for x in range(xtick + 1)]
                ax.legend(loc="upper left", fontsize=legend_font_size, ncol=2)
                ax.set_xlim(0, maxTiming)
                ax.set_ylim(0, math.ceil((max(newYTick) * 2) / 10) * 10)
                plt.xticks(xtick)
                plt.grid(True)
                if saveFolderName:
                    plt.savefig(saveFolderName + arrivalMode + "/"  + filenameFig)
                    plt.close()