def plot_data_gen(filename): cxgs = ["cxg_4/", "cxg_3/"] for cxg_select in cxgs: ewfix = "sameseed/ew/" + cxg_select outfix = "sameseed/plot/app3/" + cxg_select outfile = infile = filename start = time.time() mysas = SAS() mysas.import_states(ewfix + infile) # mysas.import_cs(gcfix + infile) # mysas.assign_channels() # # app1_bw = eval.get_plotdata_bandwidth(mysas) # app1_ix_ic = eval.get_plotdata_inter_cxg_ix_per_ch(mysas) # # eval.save_content(app1_bw, outfix + outfile + "_app1.bw") # # keys for .get() # # "avg_bw_actual": one value for Avg. Bandwidth per CBSD # # "cdf_bw_actual": cdf for Avg. BW # # eval.save_content(app1_ix_ic, outfix + outfile + "_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 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.get_bw_app3(mysas, et) app3_ix_ic = eval.get_ix_app3(mysas, et) eval.save_content(app3_bw, outfix + outfile + "_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 eval.save_content(app3_ix_ic, outfix + outfile + "_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 stop = time.time() print infile, cxg_select, "ready! in", "{0:.4f}".format( stop - start), "seconds"
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")
def plot_data_gen(filename): cxgs = ["cxg_4/", "cxg_3/"] for cxg_select in cxgs: ewfix = "sameseed/ew/" + cxg_select outfix = "sameseed/plot/app3/" + cxg_select outfile = infile = filename start = time.time() mysas = SAS() mysas.import_states(ewfix + infile) # Total Bandwidth Total_BandWidth = len(mysas.channels) * 10.0 # Total CxG cxg_nums = {cbsd.CxG for cbsd in mysas.CBSDs} bw_content = {} for et in ets: # Max Bandwidth Assigned to each CBSD assignment = mysas.get_approach_3(et) bw_max_per_cbsd = { key: Total_BandWidth / val[0] for key, val in assignment.items() } tmp = { "CxG_" + str(cxg_num): np.mean([ val for key, val in bw_max_per_cbsd.items() if key in {cbsd.id for cbsd in mysas.CBSDs if cbsd.CxG == cxg_num} ]) for cxg_num in cxg_nums } bw_content[str(et)] = tmp # print bw_content eval.save_content(bw_content, outfix + outfile + "_app3.cxgbw") stop = time.time() print infile, cxg_select, "ready! in", "{0:.4f}".format( stop - start), "seconds"
def plot_data_gen(filename): ewfix = gcfix = "experiment/multi/gc/" outfix = "experiment/multi/plotdata/" outfile = infile = filename start = time.time() mysas = SAS() mysas.import_states(ewfix + infile) mysas.import_cs(gcfix + infile) mysas.assign_channels() data_bw = eval.get_plotdata_bandwidth(mysas) data_ix = eval.get_plotdata_interference(mysas) eval.save_content(data_bw, outfix + outfile + ".bwcdf") eval.save_content(data_ix, outfix + outfile + ".ixcdf") stop = time.time() print infile, "ready! in", "{0:.4f}".format(stop-start), "seconds"
def plot_data_gen(filename): cxgs = ["cxg_4/", "cxg_3/"] for cxg_select in cxgs: ewfix = "sameseed/ew/" + cxg_select outfix = "sameseed/plot/app3/" + cxg_select outfile = infile = filename start = time.time() mysas = SAS() mysas.import_states(ewfix + infile) potential_pairs_list = {et: mysas.get_approach_3(et) for et in ets} cxg_nums = {cbsd.CxG for cbsd in mysas.CBSDs} coverage = {} noises = {} for cxg_num in cxg_nums: noises_cxg = {} # find the coverage of all CBSDs in the CxG grids_covered = { key for cbsd in mysas.CBSDs if cbsd.CxG == cxg_num for key, val in cbsd.coverage.items() if val >= min_rx } coverage["CxG_" + str(cxg_num)] = list(grids_covered) # for each grid, find the CBSDs cover and interfere it for grid_id in grids_covered: noises_grid = {} cbsds_in_cxg = { cbsd for cbsd in mysas.CBSDs if cbsd.CxG == cxg_num and cbsd.coverage.get(grid_id) >= min_rx } cbsds_out_cxg = { cbsd for cbsd in mysas.CBSDs if cbsd.CxG != cxg_num and cbsd.coverage.get(grid_id) >= min_rx } # under each edge threshold for et in ets: noise_et = {} potential_pairs = potential_pairs_list[ et] # {cbsd: (cluster_size, neighbors)} for cbsd_out in cbsds_out_cxg: # mark cbsd_out if has potential edges with any of the CBSD in the CxG if any([ cbsd_out.id in potential_pairs.get(cbsd_in.id)[1] for cbsd_in in cbsds_in_cxg ]): noise_et[cbsd_out.id] = cbsd_out.coverage.get( grid_id) if len(noise_et) > 0: noise_et["all"] = eval.get_per_unit_dbm( noise_et.values()) # Aggregated noises_grid[str(et)] = noise_et if len(noises_grid) > 0: noises_cxg[str(grid_id)] = noises_grid noises["CxG_" + str(cxg_num)] = noises_cxg if len(noises_cxg) > 0 else None eval.save_content( { "noise": noises, "coverage": coverage, "grid": mysas.grids }, outfix + outfile + "_app3.noise") stop = time.time() print infile, cxg_select, "ready! in", "{0:.4f}".format( stop - start), "seconds"
def plot_data_gen(filename): cxgs = ["cxg_4/"] for cxg_select in cxgs: ewfix = "sameseed/repeat/ew/" + cxg_select outfix = "sameseed/repeat/plot/app3/" + cxg_select outfile = infile = filename mysas = SAS() mysas.import_states(ewfix + infile) # Total Bandwidth Total_BandWidth = len(mysas.channels) * 10.0 # Total CxG cxg_nums = {cbsd.CxG for cbsd in mysas.CBSDs} bw_content = {} for et in ets: # Max Bandwidth Assigned to each CBSD assignment = mysas.get_approach_3(et) bw_max_per_cbsd = {key: Total_BandWidth / val[0] for key, val in assignment.items()} tmp = {"CxG_" + str(cxg_num): np.mean([val for key, val in bw_max_per_cbsd.items() if key in {cbsd.id for cbsd in mysas.CBSDs if cbsd.CxG == cxg_num}]) for cxg_num in cxg_nums} bw_content[str(et)] = tmp # print bw_content eval.save_content(bw_content, outfix + outfile + "_app3.cxgbw") print "bandwidth ready" potential_pairs_list = {et: mysas.get_approach_3(et) for et in ets} cxg_nums = {cbsd.CxG for cbsd in mysas.CBSDs} coverage = {} noises = {} for cxg_num in cxg_nums: noises_cxg = {} # find the coverage of all CBSDs in the CxG grids_covered = {key for cbsd in mysas.CBSDs if cbsd.CxG == cxg_num for key, val in cbsd.coverage.items() if val >= min_rx} coverage["CxG_"+str(cxg_num)] = list(grids_covered) # for each grid, find the CBSDs cover and interfere it for grid_id in grids_covered: noises_grid = {} cbsds_in_cxg = {cbsd for cbsd in mysas.CBSDs if cbsd.CxG == cxg_num and cbsd.coverage.get(grid_id) >= min_rx} cbsds_out_cxg = {cbsd for cbsd in mysas.CBSDs if cbsd.CxG != cxg_num and cbsd.coverage.get(grid_id) >= min_rx} # under each edge threshold for et in ets: noise_et = {} potential_pairs = potential_pairs_list[et] # {cbsd: (cluster_size, neighbors)} for cbsd_out in cbsds_out_cxg: # mark cbsd_out if has potential edges with any of the CBSD in the CxG if any([cbsd_out.id in potential_pairs.get(cbsd_in.id)[1] for cbsd_in in cbsds_in_cxg]): noise_et[cbsd_out.id] = cbsd_out.coverage.get(grid_id) if len(noise_et) > 0: noise_et["all"] = eval.get_per_unit_dbm(noise_et.values()) # Aggregated noises_grid[str(et)] = noise_et if len(noises_grid) > 0: noises_cxg[str(grid_id)] = noises_grid noises["CxG_"+str(cxg_num)] = noises_cxg if len(noises_cxg) > 0 else None eval.save_content({"noise": noises, "coverage": coverage, "grid": mysas.grids}, outfix + outfile + "_app3.noise") print "noise ready"