Advertisement
dan-masek

Untitled

Oct 29th, 2019
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 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_data[trace_id][delta_t][0] += distance
  6.             trace_data[trace_id][delta_t][1] += 1
  7.         else:
  8.             trace_data[trace_id][delta_t] = [distance, 1]
  9.            
  10.     MSD_traces = [[] for x in range(TRACE_COUNT)]
  11.    
  12.     for trace_id in range(TRACE_COUNT):
  13.         for delta_t,v in sorted(trace_data[trace_id].items()):
  14.             mean = v[0] / float(v[1])
  15.             MSD_traces[trace_id].append((mean, delta_t))
  16.    
  17.     return MSD_traces
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement