Advertisement
dan-masek

Untitled

Oct 29th, 2019
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. def process_data(MSD_list, TRACE_COUNT):
  2.     trace_data = [{} for x in range(TRACE_COUNT)]
  3.     for distance, delta_t, trace_id in MSD_list:
  4.         if delta_t in trace_data[trace_id]:
  5.             trace_entry = trace_data[trace_id][delta_t]
  6.             trace_entry[0] += distance
  7.             trace_entry[1] += 1
  8.         else:
  9.             trace_data[trace_id][delta_t] = [distance, 1]
  10.            
  11.     MSD_traces = [[] for x in range(TRACE_COUNT)]
  12.    
  13.     for trace_id in range(TRACE_COUNT):
  14.         for delta_t,v in sorted(trace_data[trace_id].items()):
  15.             mean = v[0] / v[1]
  16.             MSD_traces[trace_id].append((mean, delta_t))
  17.    
  18.     return MSD_traces
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement