def plot_all_retx(): """ :return: """ for folder in ['../tdma/', '../shared/']: files = [f for f in os.listdir(folder) if isfile(join(folder, f))] files = sorted(files) for filename in files: p = BasicProcessor(filename=folder + filename) p.plot_retx() plt.show()
def plot_all_retx(): """ :return: """ for folder in ['../tdma/', '../shared/']: files = [f for f in os.listdir(folder) if isfile(join(folder, f))] files = sorted(files) for filename in files: p = BasicProcessor(filename=folder+filename) p.plot_retx() plt.show()
def plot_delay_cdf(): plt.figure(figsize=(7.5, 3.5)) steps = [0.5, 1, 2, 5, 10] for idx, logfile in enumerate(get_all_files('../../data/raw/')): bp = BasicProcessor(filename=logfile) # delay_df.set_value(idx, 'set', logfile) delay_ser = pd.Series(bp.get_all_delays()) # print(delay_ser) counts = [] for step in steps: count = (delay_ser < step).sum() / len(delay_ser) counts.append(count) plt.plot([i + 1 for i, _ in enumerate(steps)], counts, gl_line_color_map[idx], label=gl_legend_map[idx]) plt.hlines(0.95, xmin=0, xmax=len(steps) + 1, linestyles='--', linewidth=2, label='0.95') x_axis = [0.5] + list(range(1, len(steps) + 1)) + [len(steps) + 0.5] labels = [''] + [str(step) for step in steps] + [''] plt.xticks(x_axis, labels) plt.ylim(0.4, 1.1) plt.legend(loc=0, ncol=3) plt.grid(True) plt.xlabel('Deadline, s') plt.ylabel('Packet ratio') plt.show()
def plot_all_reliabilities(): """ Plot packet delivery ratio for all data sets :return: """ rel = [] avg = [] for filename in get_all_files(gl_dump_path): p = BasicProcessor(filename=filename) # compensate for the rest p.correct_timeline(clean_all=False) # plot the timeline # p.plot_timeline(writer=None) r, w = p.plot_motes_reliability(return_result=True) rel.append(r) avg.append(w) plt.figure(figsize=(7.5, 3.5)) bp = plt.boxplot(rel, flierprops={'linewidth': 1.5}, showmeans=True) plt.hlines(0.95, xmin=0, xmax=9, linestyles='--', linewidth=1, label='0.95') x_axis = list(range(9)) labels = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII'] plt.xticks(x_axis, labels) plt.grid(True) plt.ylim((0.35, 1.1)) plt.legend(loc=4) plt.ylabel('PDR') set_box_plot(bp) plt.show()
def plot_all_reliabilities(): """ Plot packet delivery ratio for all data sets :return: """ rel = [] avg = [] for filename in get_all_files(gl_dump_path): p = BasicProcessor(filename=filename) # compensate for the rest p.correct_timeline(clean_all=False) # plot the timeline # p.plot_timeline(writer=None) r, w = p.plot_motes_reliability(return_result=True) rel.append(r) avg.append(w) plt.figure(figsize=(7.5, 3.5)) bp = plt.boxplot(rel, flierprops={'linewidth':1.5}, showmeans=True) plt.hlines(0.95, xmin=0, xmax=9, linestyles='--', linewidth=1, label='0.95') x_axis = list(range(9)) labels = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII'] plt.xticks(x_axis, labels) plt.grid(True) plt.ylim((0.35, 1.1)) plt.legend(loc=4) plt.ylabel('PDR') set_box_plot(bp) plt.show()
def plot_delay_cdf(): plt.figure(figsize=(7.5, 3.5)) steps = [0.5, 1, 2, 5, 10] for idx, logfile in enumerate(get_all_files('../../data/raw/')): bp = BasicProcessor(filename=logfile) # delay_df.set_value(idx, 'set', logfile) delay_ser = pd.Series(bp.get_all_delays()) # print(delay_ser) counts = [] for step in steps: count = (delay_ser < step).sum() / len(delay_ser) counts.append(count) plt.plot([i+1 for i, _ in enumerate(steps)], counts, gl_line_color_map[idx], label=gl_legend_map[idx]) plt.hlines(0.95, xmin=0, xmax=len(steps)+1, linestyles='--', linewidth=2, label='0.95') x_axis = [0.5] + list(range(1, len(steps)+1)) + [len(steps)+0.5] labels = [''] + [str(step) for step in steps] + [''] plt.xticks(x_axis, labels) plt.ylim(0.4, 1.1) plt.legend(loc=0, ncol=3) plt.grid(True) plt.xlabel('Deadline, s') plt.ylabel('Packet ratio') plt.show()
def plot_normalized_delay_per_application(): """ Plot delay for scenario / application: normalized per hop :return: """ # --- folder one --- # folder = os.getcwd() + '/../../data/raw/' + 'tdma/' files = [f for f in os.listdir(folder) if isfile(join(folder, f))] files = sorted(files) d_tdma = [] for filename in files: p = BasicProcessor(filename=folder + filename) # Periodic application d_tdma.append( p.get_all_delays(motes=[2, 3, 4, 5, 6, 7, 8], normalized=True)) # Bursty application d_tdma.append(p.get_all_delays(motes=[9, 10, 11], normalized=True)) # --- folder two --- # folder = os.getcwd() + '/../../data/raw/' + 'shared/' files = [f for f in os.listdir(folder) if isfile(join(folder, f))] files = sorted(files) d_shared = [] for filename in files: p = BasicProcessor(filename=folder + filename) # Periodic application d_shared.append( p.get_all_delays(motes=[2, 3, 4, 5, 6, 7, 8], normalized=True)) # Bursty application d_shared.append(p.get_all_delays(motes=[9, 10, 11], normalized=True)) # --- folder two --- # fig = plt.figure(figsize=(7.5, 5.7)) gs = gridspec.GridSpec(2, 1, height_ratios=[1, 1]) ax0 = fig.add_subplot(gs[0]) bp_tdma = ax0.boxplot(d_tdma, showmeans=True, showfliers=False) x_axis = list(range(9)) labels = [ '', 'I(P)', 'I(B)', 'II(P)', 'II(B)', 'III(P)', 'III(B)', 'IV(P)', 'IV(B)' ] plt.xticks(x_axis, labels) # ylim((0, 4)) plt.grid(True) # plt.xlabel('Data set') plt.ylabel('Delay, s') set_box_plot(bp_tdma) ax1 = fig.add_subplot(gs[1]) bp_shared = ax1.boxplot(d_shared, showmeans=True, showfliers=False) plt.grid(True) # plt.xlabel('Data set') labels = [ '', 'V(P)', 'V(B)', 'VI(P)', 'VI(B)', 'VII(P)', 'VII(B)', 'VIII(P)', 'VIII(B)' ] plt.xticks(x_axis, labels) plt.ylabel('Delay, s') set_box_plot(bp_shared) plt.show()
def plot_all_delays(cdf=False): """ Plot delay for all packets, on the scenario basis :return: """ # --- folder one --- # folder = '../../data/raw/' + 'tdma/' files = [f for f in os.listdir(folder) if isfile(join(folder, f))] files = sorted(files) d = [] for filename in files: p = BasicProcessor(filename=folder + filename) d.append(p.get_all_delays()) # --- folder two --- # folder = '../../data/raw/' + 'shared/' files = [f for f in os.listdir(folder) if isfile(join(folder, f))] files = sorted(files) for filename in files: p = BasicProcessor(filename=folder + filename) d.append(p.get_all_delays()) # --- folder two --- # if not cdf: plt.figure(figsize=(7.5, 4)) bp = plt.boxplot(d, showmeans=True, showfliers=False) plt.ylim((0, 2.5)) plt.grid(True) x_axis = list(range(9)) labels = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII'] plt.xticks(x_axis, labels) plt.xlabel('Data set') plt.ylabel('End-to-end delay, s') set_box_plot(bp) plt.show() else: plt.figure(figsize=(7.5, 4)) for data_set in d: ecdf = sm.distributions.ECDF(data_set) x = np.linspace(min(data_set), max(data_set)) y = ecdf(x) plt.step(x, y) plt.xlim((0, 2.5)) plt.show()
def plot_normalized_delay_per_application(): """ Plot delay for scenario / application: normalized per hop :return: """ # --- folder one --- # folder = os.getcwd() + '/../../data/raw/' + 'tdma/' files = [f for f in os.listdir(folder) if isfile(join(folder, f))] files = sorted(files) d_tdma = [] for filename in files: p = BasicProcessor(filename=folder+filename) # Periodic application d_tdma.append(p.get_all_delays(motes=[2, 3, 4, 5, 6, 7, 8], normalized=True)) # Bursty application d_tdma.append(p.get_all_delays(motes=[9, 10, 11], normalized=True)) # --- folder two --- # folder = os.getcwd() + '/../../data/raw/' + 'shared/' files = [f for f in os.listdir(folder) if isfile(join(folder, f))] files = sorted(files) d_shared = [] for filename in files: p = BasicProcessor(filename=folder+filename) # Periodic application d_shared.append(p.get_all_delays(motes=[2, 3, 4, 5, 6, 7, 8], normalized=True)) # Bursty application d_shared.append(p.get_all_delays(motes=[9, 10, 11], normalized=True)) # --- folder two --- # fig = plt.figure(figsize=(7.5, 5.7)) gs = gridspec.GridSpec(2, 1, height_ratios=[1, 1]) ax0 = fig.add_subplot(gs[0]) bp_tdma = ax0.boxplot(d_tdma, showmeans=True, showfliers=False) x_axis = list(range(9)) labels = ['', 'I(P)', 'I(B)', 'II(P)', 'II(B)', 'III(P)', 'III(B)', 'IV(P)', 'IV(B)'] plt.xticks(x_axis, labels) # ylim((0, 4)) plt.grid(True) # plt.xlabel('Data set') plt.ylabel('Delay, s') set_box_plot(bp_tdma) ax1 = fig.add_subplot(gs[1]) bp_shared = ax1.boxplot(d_shared, showmeans=True, showfliers=False) plt.grid(True) # plt.xlabel('Data set') labels = ['', 'V(P)', 'V(B)', 'VI(P)', 'VI(B)', 'VII(P)', 'VII(B)', 'VIII(P)', 'VIII(B)'] plt.xticks(x_axis, labels) plt.ylabel('Delay, s') set_box_plot(bp_shared) plt.show()
def plot_all_delays(cdf=False): """ Plot delay for all packets, on the scenario basis :return: """ # --- folder one --- # folder = '../../data/raw/' + 'tdma/' files = [f for f in os.listdir(folder) if isfile(join(folder, f))] files = sorted(files) d = [] for filename in files: p = BasicProcessor(filename=folder+filename) d.append(p.get_all_delays()) # --- folder two --- # folder = '../../data/raw/' + 'shared/' files = [f for f in os.listdir(folder) if isfile(join(folder, f))] files = sorted(files) for filename in files: p = BasicProcessor(filename=folder+filename) d.append(p.get_all_delays()) # --- folder two --- # if not cdf: plt.figure(figsize=(7.5, 4)) bp = plt.boxplot(d, showmeans=True, showfliers=False) plt.ylim((0, 2.5)) plt.grid(True) x_axis = list(range(9)) labels = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII'] plt.xticks(x_axis, labels) plt.xlabel('Data set') plt.ylabel('End-to-end delay, s') set_box_plot(bp) plt.show() else: plt.figure(figsize=(7.5, 4)) for data_set in d: ecdf = sm.distributions.ECDF(data_set) x = np.linspace(min(data_set), max(data_set)) y = ecdf(x) plt.step(x, y) plt.xlim((0, 2.5)) plt.show()