def plot_data_gen(locs, cats, dens, pms): infix = "experiment/plot/sameseed/" outfix = "experiment/plot/sameseed/figures/" for num_cxg in cxgs: cxg_folder = "cxg_" + str(num_cxg) + "/" outfile = "cxg_" + str(num_cxg) for cat in cats: labels = ["Density=" + str(den) for den in dens] x = np.arange(len(labels)) # the label locations width = 0.17 # the width of the bars fig, ax = plt.subplots() rects = [] pos = -width * 1.5 for pm in pms: pm_txt = "ITM" if pm == "itm" else "Hybrid" for loc in locs: loc_txt = "Virginia Beach" if loc == "vb" else "San Diego" data = [] for den in dens: infile = loc + "_" + str(den) + "_" + cat + "_" + pm # Inter-CxG Interference app3_ixic = eval.load_content(infix + cxg_folder + infile + ".ixcovval") data.append( app3_ixic.get("signal_coverage").get(target_cxg) / 100.0) rects.append( ax.bar(x + pos, data, width, label=loc_txt + " - " + pm_txt, color=colors[locs.index(loc)], edgecolor='white', hatch=hatches[pms.index(pm)])) pos += width ax.set_ylabel("CRC of " + str(target_cxg) + " (%)") ax.set_xticks(x) ax.set_xticklabels(labels) ax.legend(loc="lower right") plt.ylim((0, 110)) fig.tight_layout() # plt.show() plt.savefig(outfix + "coverage/" + outfile + "_coverage.png") print outfile, "ready!"
def plot_data(filename): cxgs = ["cxg_4/"] for cxg_select in cxgs: infix = "sameseed/repeat/plot/app3/" + cxg_select outfix = infix # infix = "simpseed/plot/" + cxg_select infile = filename + "_app3.noise" content = eval.load_content(infix + infile) cxgs = content.get("coverage").keys() coverage = content.get("coverage") noises = content.get("noise") grids = content.get("grid") cov = {x for val in coverage.values() for x in val} # print "Coverage all CBSDS:", len(cov) ix_value_by_et = {} ix_coverage_by_et = {} signal_coverage = {target_cxg : len(coverage.get(target_cxg)) for target_cxg in cxgs} for et in ets: ix_value_by_cxg = {} ix_coverage_by_cxg = {} for target_cxg in cxgs: target_cxg_coverage = len(coverage.get(target_cxg)) target_cxg_noises_map = {key: val.get(str(et)).get("all") for key, val in noises.get(target_cxg).items() if noises.get(target_cxg).get(key).get(str(et)) is not None} interfered_grids = len(target_cxg_noises_map) if target_cxg_noises_map is not None else 0 avg_noise_level = eval.get_per_unit_dbm(target_cxg_noises_map.values(), interfered_grids * 1.0) ix_coverage_by_cxg[target_cxg] = interfered_grids * 100.0 / target_cxg_coverage ix_value_by_cxg[target_cxg] = avg_noise_level ix_coverage_by_et[str(et)] = ix_coverage_by_cxg ix_value_by_et[str(et)] = ix_value_by_cxg eval.save_content( {"signal_coverage": signal_coverage, "ix_coverage": ix_coverage_by_et, "noise": ix_value_by_et}, outfix + filename + ".ixcovval")
outfile = loc + "_" + str(den) + "_" + cat + "_" + pm text_cdf_ix_worst = {"title": "Channel with Worst Interference", "xlabel": "AIPA (dBm)", "ylabel": "Probability", "xlim": (-140, 0), "ylim": (0, 110), } legends = [] data_ix_cdf_worst = [] styles = [] for i in range(50): infile = loc + "_" + str(den) + "_" + cat + "_" + pm + "_" + str(i) legends.append("data:" + str(i)) styles.append((lines[i % 4], (i / 4)%10)) data_bw = eval.load_content(prefix + infile + ".bwcdf") data_ix = eval.load_content(prefix + infile + ".ixcdf") # data_bw_cdf.append(data_bw.get("cdf_bw_actual")) data_ix_cdf_worst.append(data_ix.get("max_noises")) # data_ix_cdf_best.append(data_ix.get("min_noises")) # eval.plot_cdf(data_bw_cdf, legends_info, text=text_cdf_bw, outfile=outfix + outfile + "_bwcdf.png") eval.plot_cdf(data_ix_cdf_worst, legends, styles, text=text_cdf_ix_worst, outfile=outfix + outfile + "_ixcdf_w.png")
def plot_data(filename): cxgs = ["cxg_4/"] for cxg_select in cxgs: infix = "experiment/plot/sameseed/" + cxg_select infile = filename + "_app3.noise" start = time.time() content = eval.load_content(infix + infile) mysas = SAS() mysas.import_states(infix + filename) cxgs = content.get("coverage").keys() coverage = content.get("coverage") noises = content.get("noise") grids = content.get("grid") cov = {x for val in coverage.values() for x in val} # print "Coverage all CBSDS:", len(cov) # # ix_value_by_et = {} # ix_coverage_by_et = {} # signal_coverage = {target_cxg : len(coverage.get(target_cxg)) for target_cxg in cxgs} for et in ets: # print "ET=", et, ":" ix_value_by_cxg = {} ix_coverage_by_cxg = {} # for target_cxg in cxgs: target_cxg_coverage = len(coverage.get(target_cxg)) # target_cxg_noises_map = {key: val.get(str(et)).get("all") # for key, val in noises.get(target_cxg).items() # if noises.get(target_cxg).get(key).get(str(et)) is not None} in_cbsds_id = {cbsd.id for cbsd in mysas.CBSDs if cbsd.CxG == 0} effew = { key: val for key, val in mysas.ew_table.items() if len(in_cbsds_id.intersection(key)) == 1 and et - 0.1 < val <= et } target_pairs = { key: len(val.get(str(et))) - 1 for key, val in noises.get(target_cxg).items() if noises.get(target_cxg).get(key).get(str(et)) is not None } # print "\tGrids: ", len(target_pairs.keys()) # print "\tCBSD-Grid Ix: ", sum(target_pairs.values()) # print "\tCBSDs/Grid", sum(target_pairs.values())*1.0/len(target_pairs.keys()) print "\t", len(effew) # # interfered_grids = len(target_cxg_noises_map) if target_cxg_noises_map is not None else 0 # avg_noise_level = eval.get_per_unit_dbm(target_cxg_noises_map.values(), interfered_grids * 1.0) # # ix_coverage_by_cxg[target_cxg] = interfered_grids * 100.0 / target_cxg_coverage # ix_value_by_cxg[target_cxg] = avg_noise_level # # ix_coverage_by_et[str(et)] = ix_coverage_by_cxg # ix_value_by_et[str(et)] = ix_value_by_cxg # eval.save_content( # {"signal_coverage": signal_coverage, "ix_coverage": ix_coverage_by_et, "noise": ix_value_by_et}, # outfix + filename + ".ixcovval") stop = time.time() print infile, cxg_select, "ready! in", "{0:.4f}".format( stop - start), "seconds"
def plot_data_gen(locs, cats, dens, pms): infix = "experiment/plot/sameseed/" outfix = "experiment/plot/sameseed/figures/" cxgs = [3, 4] for num_cxg in cxgs: cxg_folder = "cxg_" + str(num_cxg) + "/" outfile = "cxg_" + str(num_cxg) for cat in cats: bwset = [] ixset = [] for pm in pms: pm_txt = "ITM" if pm == "itm" else "Hybrid" bwrow = [] ixrow = [] for loc in locs: loc_txt = "Virginia Beach" if loc == "vb" else "San Diego" bwcdf_data = [] bwcdf_legend = [] bwcdf_style = [] ixiccdf_data = [] ixiccdf_legend = [] ixiccdf_style = [] for den in dens: infile = loc + "_" + str(den) + "_" + cat + "_" + pm color = colors[dens.index(den)] ets = [0.1, 0.5, 0.9] for et in ets: ls = ets.index(et) app3_bw = eval.load_content(infix + cxg_folder + infile + "_app3_" + str(et) + ".bw") # keys for .get() # "et": et, # "cdf_bw_max": cdf for Max_BW # "avg_bw_max": one value for Avg. Max_BW per CBSD bw_percentages = {} bw_raw = [ str("{:.1f}".format(x)) for x in app3_bw.get("cdf_bw_max") ] for bw_val in stacks: bw_percentages[bw_val] = bw_raw.count( bw_val) * 1.0 / len(bw_raw) print bw_percentages bwcdf_data.append(bw_percentages) bwcdf_legend.append("Density=" + str(den) + ", ET=" + str(app3_bw.get("et"))) bwcdf_style.append((ls, color)) app3_ixic = eval.load_content(infix + cxg_folder + infile + "_app3_" + str(et) + ".ixic") # keys for .get() # "et": et, # "cdf_ix": cdf for inter-CxG ix # "avg_ix_max": one value for Avg. inter-CxG ix per CBSD ixiccdf_data.append(app3_ixic.get("cdf_ix")) ixiccdf_legend.append("Density=" + str(den) + ", ET=" + str(app3_bw.get("et"))) ixiccdf_style.append((lines[ls], color)) bwrow.append((bwcdf_data, bwcdf_legend, bwcdf_style, loc_txt + ", " + pm_txt)) ixrow.append((ixiccdf_data, ixiccdf_legend, ixiccdf_style, loc_txt + ", " + pm_txt)) bwset.append(bwrow) ixset.append(ixrow) text_bar_bw = { "xlabel": "Configurations", "ylabel": "Percentage of CBSDs (in %)" } text_cdf_ix = { "title": "CDF of Potential Interference", "xlabel": "dbm", "ylabel": "Probability (in %)", "xlim": (-150, -20), "ylim": (0, 110), } eval.plot_group_histo( bwset, stacks, text_bar_bw, outfix + "bandwidth_34/" + outfile + "_compare_bw.png") eval.plot_group_cdf( ixset, text_cdf_ix, outfix + "interference_34/" + outfile + "_compare_ix.png") print outfile, "ready!"
text_bar_bw = { "xlabel": "Configurations", "ylabel": "Percentage of CBSDs (in %)" } legends_info = [] data_bw_bars = [] data_bw_histos = [] for den in densities: for cxg in cxgs: cxg_txt = "w/ CxG" if cxgs.index( cxg) == 0 else "w/o CxG" infile = loc + "_" + str(den) + "_" + cat + "_" + pm legends_info.append("Density-" + str(den) + " " + cxg_txt) data_bw = eval.load_content(prefix + cxg + "/" + infile + ".bwcdf") data_bw_bars.append(data_bw.get("bw_cbsd_actual")) # data_bw_histos.append(data_bw.get("cdf_bw_actual")) # eval.plot_bar(data_bw_bars, legends_info, stacks=stacks, text=text_bar_bw, outfile=outfix + outfile + "_bwcdf_bar.png") eval.plot_histo(data_bw_bars, legends_info, stacks=stacks, text=text_bar_bw, outfile=outfix + outfile + "_bwcdf_hist.png")
def plot_data(locs, cats, dens, pms): infix = "experiment/plot/sameseed/" outfix = "experiment/plot/sameseed/figures/" for cat in cats: for pm in pms: for loc in locs: start = time.time() bwcdf_data = [] bwcdf_legend = [] bwcdf_style = [] ixiccdf_data = [] ixiccdf_legend = [] ixiccdf_style = [] bwix_data = [] bwix_legend = [] bwix_style = [] for den in dens: infile = loc + "_" + str(den) + "_" + cat + "_" + pm color = colors[dens.index(den)] cxgs = [3, 4] for num_cxg in cxgs: cxg_folder = "cxg_" + str(num_cxg) + "/" ls = lines[cxgs.index(num_cxg)] app3_bwix_data = [] for et in [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]: app3_bw = eval.load_content(infix + cxg_folder + infile + "_app3_"+str(et)+".bw") # keys for .get() # "et": et, # "cdf_bw_max": cdf for Max_BW # "avg_bw_max": one value for Avg. Max_BW per CBSD # bwcdf_data.append(app3_bw.get("cdf_bw_max")) # bwcdf_legend.append("Approach_3: ET="+str(app3_bw.get("et"))) # bwcdf_style.append(("dashed", int(et*10-1))) app3_ixic = eval.load_content(infix + cxg_folder + infile + "_app3_"+str(et)+".ixic") # keys for .get() # "et": et, # "cdf_ix": cdf for inter-CxG ix # "avg_ix_max": one value for Avg. inter-CxG ix per CBSD # ixiccdf_data.append(app3_ixic.get("cdf_ix")) # ixiccdf_legend.append("Approach_3: ET=" + str(app3_ixic.get("et"))) # ixiccdf_style.append(("dashed", int(et*10-1))) app3_bwix_data.append((app3_ixic.get("avg_ix_max"), app3_bw.get("avg_bw_max"), "ET="+str(app3_bw.get("et")) )) bwix_data.append(app3_bwix_data) bwix_legend.append(str(num_cxg) + " CxGs, Density " + str(den)) bwix_style.append((ls, color)) # text_cdf_bw = {"title": "CDF of Max Bandwidth", # "xlabel": "Bandwidth (MHz)", # "ylabel": "Probability (in %)", # "xlim": (0, 90), # "ylim": (0, 110), # } # # text_cdf_ix = {"title": "CDF of Potential Interference", # "xlabel": "dbm", # "ylabel": "Probability (in %)", # "xlim": (-150, 0), # "ylim": (0, 110), # } text_bw_interference = {"xlabel": "Average Inter-CxG Interference per CBSD (dbm per channel)", "ylabel": "Average Bandwidth per CBSD (MHz)", "xlim": (-140, 0), "ylim": (0, 90), } # eval.plot_cdf(bwcdf_data, bwcdf_legend, bwcdf_style, text_cdf_bw, # outfix + "bandwidth/" + outfile + "_compare_bw.png") # # eval.plot_cdf(ixiccdf_data, ixiccdf_legend, ixiccdf_style, text_cdf_ix, # outfix + "interference/" + outfile + "_compare_ix.png") outfile_bwix = loc + "_" + pm eval.plot_bw_interfernce(bwix_data, bwix_legend, bwix_style, text_bw_interference, outfix + "quality_34/" + outfile_bwix + "_compare_bwix.png") stop = time.time() print outfile_bwix, "ready! in", "{0:.4f}".format(stop-start), "seconds"
def plot_data_gen(locs, cats, dens, pms): infix = "experiment/plot/sameseed/" outfix = "experiment/plot/sameseed/figures/" for num_cxg in cxgs: cxg_folder = "cxg_" + str(num_cxg) + "/" outfile = "cxg_" + str(num_cxg) for cat in cats: bwset = [] ix_value_set = [] ix_coverage_set = [] quality_value_set = [] quality_coverage_set = [] for pm in pms: pm_txt = "ITM" if pm == "itm" else "Hybrid" bwrow = [] ix_value_row = [] ix_coverage_row = [] quality_value_row = [] quality_coverage_row = [] for den in dens: bw_data = [] bw_legend = [] bw_style = [] ix_value_data = [] ix_coverage_data = [] ix_legend = [] ix_style = [] quality_value_data = [] quality_coverage_data = [] for loc in locs: loc_txt = "Virginia Beach" if loc == "vb" else "San Diego" infile = loc + "_" + str(den) + "_" + cat + "_" + pm color = colors[locs.index(loc)] ls = locs.index(loc) # Bandwidth app3_bw = eval.load_content(infix + cxg_folder + infile + "_app3.cxgbw") bw_data.append([(et, app3_bw.get(str(et)).get(target_cxg)) for et in ets]) bw_legend.append(loc_txt) bw_style.append((lines[ls % len(lines)], color)) # Inter-CxG Interference app3_ixic = eval.load_content(infix + cxg_folder + infile + ".ixcovval") ix_coverage = app3_ixic.get("ix_coverage") noises = app3_ixic.get("noise") ix_coverage_data.append([ (et, ix_coverage.get(str(et)).get(target_cxg)) for et in ets[1:] ]) ix_value_data.append([ (et, noises.get(str(et)).get(target_cxg)) for et in ets[1:] ]) ix_legend.append(loc_txt) ix_style.append((lines[ls % len(lines)], color)) # Quality quality_coverage_data.append([ (app3_bw.get(str(et)).get(target_cxg), ix_coverage.get(str(et)).get(target_cxg)) for et in ets[1:] ]) quality_value_data.append([ (app3_bw.get(str(et)).get(target_cxg), noises.get(str(et)).get(target_cxg)) for et in ets[1:] ]) bwrow.append((bw_data, bw_legend, bw_style, "Density=" + str(den) + ", " + pm_txt)) ix_coverage_row.append( (ix_coverage_data, ix_legend, ix_style, "Density=" + str(den) + ", " + pm_txt)) ix_value_row.append( (ix_value_data, ix_legend, ix_style, "Density=" + str(den) + ", " + pm_txt)) quality_coverage_row.append( (quality_coverage_data, ix_legend, ix_style, "Density=" + str(den) + ", " + pm_txt)) quality_value_row.append( (quality_value_data, ix_legend, ix_style, "Density=" + str(den) + ", " + pm_txt)) bwset.append(bwrow) ix_coverage_set.append(ix_coverage_row) ix_value_set.append(ix_value_row) quality_coverage_set.append(quality_coverage_row) quality_value_set.append(quality_value_row) text_bar_bw = { "xlabel": "Edge Threshold", "ylabel": "AMABCC in " + target_cxg + " (MHz)", "xlim": (0.0, 1.0), "ylim": (0, 80), "figsize": (6, 8) } text_ix_coverage = { "xlabel": "Edge Threshold", "ylabel": "RCIAC of " + target_cxg + " (%)", "xlim": (0.0, 1.0), "ylim": (0, 110), "figsize": (6, 8) } text_ix_value = { "xlabel": "Edge Threshold", "ylabel": "AAICIGC of " + target_cxg + " (dbm)", "xlim": (0.0, 1.0), "ylim": (-100, -30), "figsize": (6, 8) } text_quality_coverage = { "xlabel": "Average Maxium Bandwidth Assigned", "ylabel": "Percentage of " + target_cxg + " Covered Area Interfered by other CxGs (%)", "xlim": (0.0, 80), "ylim": (0, 110), "figsize": (6, 8) } text_quality_value = { "xlabel": "Average Maxium Bandwidth Assigned", "ylabel": "Average Noise (dbm/10 MHz) from other CxGs of the Interfered Area in " + target_cxg, "xlim": (0.0, 80), "ylim": (-100, -30), "figsize": (6, 8) } eval.plot_group(bwset, text_bar_bw, outfix + "bandwidth/" + outfile + "_bw.png") eval.plot_group(ix_coverage_set, text_ix_coverage, outfix + "ix_coverage/" + outfile + "_ixcov.png") eval.plot_group(ix_value_set, text_ix_value, outfix + "ix_value/" + outfile + "_ixval.png") # eval.plot_group(quality_coverage_set, text_quality_coverage, outfix + "quality/" + outfile + "_qtcov.png") # eval.plot_group(quality_value_set, text_quality_value, outfix + "quality/" + outfile + "_qtval.png") print outfile, "ready!"
def plot_data_gen(loc, den, cat, pm): infile = loc + "_" + str(den) + "_" + cat + "_" + pm # infix = "experiment/plot/raw/compare/" # outfix = "experiment/plot/raw/compare/figures/" infix = "experiment/plot/test/compare/" outfix = "experiment/plot/test/compare/figures/" outfile = infile start = time.time() bwcdf_data = [] bwcdf_legend = [] bwcdf_style = [] ixiccdf_data = [] ixiccdf_legend = [] ixiccdf_style = [] bwix_data = [] bwix_legend = [] bwix_style = [] app1_bw = eval.load_content(infix + infile + "_app1.bw") # keys for .get() # "avg_bw_actual": one value for Avg. Bandwidth per CBSD # "cdf_bw_actual": cdf for Avg. BW bwcdf_data.append(app1_bw.get("cdf_bw_actual")) bwcdf_legend.append("Approach_1") bwcdf_style.append(("solid", 0)) app1_ixic = eval.load_content(infix + infile + "_app1.ixic") # keys for .get() # "dbm_per_ch": cdf for Avg. inter-CxG ix # "avg_ix_per_ch_per_cbsd": one value for Avg. inter-CxG ix per CBSD # "max_noises": cdf for Max. inter-CxG ix # "min_noises": cdf for Min. inter-CxG ix ixiccdf_data.append(app1_ixic.get("dbm_per_ch")) ixiccdf_legend.append("Approach_1: Avg") ixiccdf_style.append(("solid", 0)) ixiccdf_data.append(app1_ixic.get("max_noises")) ixiccdf_legend.append("Approach_1: Max") ixiccdf_style.append(("solid", 1)) ixiccdf_data.append(app1_ixic.get("min_noises")) ixiccdf_legend.append("Approach_1: Min") ixiccdf_style.append(("solid", 2)) bwix_data.append([(app1_ixic.get("avg_ix_per_ch_per_cbsd"), app1_bw.get("avg_bw_actual"), "ETWF")]) bwix_legend.append("Approach_1") bwix_style.append(("solid", 0)) app3_bwix_data = [] for et in [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]: app3_bw = eval.load_content(infix + infile + "_app3_" + str(et) + ".bw") # keys for .get() # "et": et, # "cdf_bw_max": cdf for Max_BW # "avg_bw_max": one value for Avg. Max_BW per CBSD bwcdf_data.append(app3_bw.get("cdf_bw_max")) bwcdf_legend.append("Approach_3: ET=" + str(app3_bw.get("et"))) bwcdf_style.append(("dashed", int(et * 10 - 1))) app3_ixic = eval.load_content(infix + infile + "_app3_" + str(et) + ".ixic") # keys for .get() # "et": et, # "cdf_ix": cdf for inter-CxG ix # "avg_ix_max": one value for Avg. inter-CxG ix per CBSD ixiccdf_data.append(app3_ixic.get("cdf_ix")) ixiccdf_legend.append("Approach_3: ET=" + str(app3_ixic.get("et"))) ixiccdf_style.append(("dashed", int(et * 10 - 1))) app3_bwix_data.append( (app3_ixic.get("avg_ix_max"), app3_bw.get("avg_bw_max"), "ET=" + str(app3_bw.get("et")))) bwix_data.append(app3_bwix_data) bwix_legend.append("Approach_3") bwix_style.append(("dashed", 0)) text_cdf_bw = { "title": "CDF of Max Bandwidth", "xlabel": "Bandwidth (MHz)", "ylabel": "Probability (in %)", "xlim": (0, 90), "ylim": (0, 110), } text_cdf_ix = { "title": "CDF of Potential Interference", "xlabel": "dbm", "ylabel": "Probability (in %)", "xlim": (-150, 0), "ylim": (0, 110), } text_bw_interference = { "xlabel": "Average Inter-CxG Interference per CBSD (dbm per channel)", "ylabel": "Average Bandwidth per CBSD (MHz)", "xlim": (-140, 0), "ylim": (0, 90), } eval.plot_cdf(bwcdf_data, bwcdf_legend, bwcdf_style, text_cdf_bw, outfix + "bandwidth/" + outfile + "_compare_bw.png") eval.plot_cdf(ixiccdf_data, ixiccdf_legend, ixiccdf_style, text_cdf_ix, outfix + "interference/" + outfile + "_compare_ix.png") eval.plot_bw_interfernce( bwix_data, bwix_legend, bwix_style, text_bw_interference, outfix + "quality/" + outfile + "_compare_bwix.png") stop = time.time() print infile, "ready! in", "{0:.4f}".format(stop - start), "seconds"