def summary_statistics(): ble_mex = dict() terms = [ 'latency', 'std', 'm_e', 'low', 'up', 'S', 'R', 'L', 'E', 'pdr', 'goodput' ] terms_2 = [ 'mean', 'std', 'm_e', 'low', 'up', 'S', 'R', 'L', 'E', 'pdr', 'goodput' ] for k, run in my_dictionary.items(): if k == '_command': continue if k == '1': for t in terms: ble_mex[t] = [] i = 0 for t in terms: if i < 5: value = run['statistic_']['latency'][terms_2[i]] elif 5 <= i <= 8: value = run['mex_'][terms_2[i]] else: value = run['statistic_'][terms_2[i]] ble_mex[t].append(value) i += 1 ble = dict() for t in terms: ble[t] = np.mean(ble_mex[t]) my_dictionary['summary'] = { 'mex_': { 'S': ble['S'], 'R': ble['R'], 'L': ble['L'], 'E': ble['E'] }, 'statistic_': { 'pdr': ble['pdr'], 'goodput': ble['goodput'], 'latency': { 'mean': ble['latency'], 'std': ble['std'], 'm_e': ble['m_e'], 'low': ble['low'], 'up': ble['up'] } } } # Saving path_json = outcome_path + "delay_" + str(delay[index_delay]) + ".json" my.save_json_data_2(path=path_json, data=my_dictionary)
def change_ttl_from_7_to_3(path): print("- {}".format(change_ttl_from_7_to_3.__name__)) data = my.open_file_and_return_data(code=0, path=path) mex = data['messages'] i = 0 saving = False ttl = 7 - data['_command']['relay'] re_ttl = str("P,[0-9]{1,5}," + str(ttl)) replace_ttl = 3 - data['_command']['relay'] for k in mex: if re.match(re_ttl, k['message_id']): saving = True s = k['message_id'].split(',') new_s = str(s[0] + "," + s[1] + "," + str(replace_ttl)) data['messages'][i]['message_id'] = new_s i += 1 if saving: my.save_json_data_2(path=path, data=data)
def save_data(my_dictionary): path_json = outcome_path + "delay_x_" + str(delay[index_delay]) + ".json" my.save_json_data_2(path=path_json, data=my_dictionary)
def save_statistics_data(): path_json = outcome_path + "delay_XXX_" + str(delay[index_delay]) + ".json" my.save_json_data_2(path=path_json, data=my_dictionary)