Revision c39a768e py_logs_correlated_visualizer.py

View differences:

py_logs_correlated_visualizer.py
10 10
import networkx as nx
11 11
import pygraphviz  as pgz
12 12
import numpy as np
13
import collections
13 14

  
14 15
sys.path.insert(0,'lib')
15 16
import process_manager as pmgr
......
72 73
	values = {}
73 74
	tag2num = {}
74 75
	couples = zip(x,y)
75
	print couples
76
	#print couples
76 77
	available_colors = ['#002EB8','#FFFF99','r','g','o','p']
77 78
	colors = []
78 79
	width = 0.35
......
245 246
	simple_bar_graph(groups,accuracy,ylabel='receiving ratio')#,title='Chunks received ratio')
246 247
	save_figure(folder,'overall_loss')
247 248

  
249
def corr_neigh_fairness(folder,groups):
250
  fig = plt.figure()
251
  res_mat = {}
252
  for g in groups:
253
    filename = folder+'/'+g+'/network_fairness.exp'
254
    res_mat[g] = {}
255
    
256
    if os.path.exists(filename):
257
      data = read_csv(filename)
258
      for session in set(data['session_id']): 
259
        sdata = data[data['session_id'] == session]
260
        base_fairness = sdata['complete_overlay_fairness'][sdata.first_valid_index()]
261
	ind = sdata.last_valid_index()
262
	stable_fairness = sdata.ix[ind]['fairness']
263
        
264
        res_mat[g][base_fairness] = stable_fairness
265

  
266
  for g in res_mat.keys():
267
    x = res_mat[g].keys()
268
    y = res_mat[g].values()
269
    perm = sorted(range(len(x)), key=lambda k: x[k])
270
    x = [x[i] for i in perm]
271
    y = [y[i] for i in perm]
272
    plt.plot(x,y,label=g,linestyle="dashed",marker='o')
273
    #plotOrderedErrorBar(res_mat[g].keys(),res_mat[g].values(),label=g,on_x=True)
274
  plt.legend(loc='best')
275
  set_plot_labels(fig,'neighbourhood_fairness','base fairness','fairness')
276
  save_figure(folder,'neighbourhood_fairness')
277

  
278
def corr_convergence_time(folder,groups):
279
  fig = plt.figure()
280
  times = {}
281
  for g in groups:
282
    filename = folder+'/'+g+'/network_impact.exp'
283
    if os.path.exists(filename):
284
      data = read_csv(filename)
285
      min_times = []
286
      for session in set(data['session_id']):
287
        ses_data = data[(data['session_id'] == session)]
288
	ind = ses_data.last_valid_index()
289
	#min_imp = ses_data[ind]['netimpact']
290
	min_imp = ses_data.ix[ind]['netimpact']
291
	min_time = ses_data[ses_data['netimpact'] == min_imp]['time'].min()
292
	min_times.append(min_time)
293
      times[g] = min_times
294
  #s = {x:times[x] for x in sorted(times)}
295
  s = collections.OrderedDict(sorted(times.items()))
296
  plotDictAsBox(fig,s)
297
  set_plot_labels(fig,'','','Convergence time (s)')
298
  save_figure(folder,'neighbourhood_convergence')
299

  
248 300
def corr_neigh_impact_evolution(folder,groups):
249 301
  fig = plt.figure()
250 302
  for g in groups:
......
268 320
      if groupkey not in plot_data.keys():
269 321
        plot_data[groupkey] = {}
270 322

  
271
      filename = folder+'/'+g+'/network_impact.exp'
323
      filename = folder+'/'+g+'/network_fairness.exp'
272 324
      if os.path.exists(filename):
273
        data = read_csv(filename).drop(['info_type','session_id'],1)
325
        data = read_csv(filename) #.drop(['info_type','session_id'],1)
274 326
        tag = int(''.join([c for c in list(tag) if c.isdigit()]))
275
        plot_data[groupkey][tag] = data['netimpact'].mean()
276
  
327
        
328
        values = []
329
	for sess in set(data['session_id']):
330
          sdata = data[data['session_id'] == sess]
331
          ind = sdata.last_valid_index()
332
          values.append(sdata.ix[ind]['fairness'])
333

  
334
        plot_data[groupkey][tag] = np.mean(values)
335
          
277 336
  if len(plot_data) > 0:
278 337
    for g in plot_data.keys():
279 338
      s = Series(plot_data[g])
280 339
      plt.plot(s.index,s,label=g)
281 340
    
282 341
    plt.legend(loc='best')
283
    set_plot_labels(fig,'','tag','network impact')
284
    save_figure(folder,'corr_netimpact')
342
    set_plot_labels(fig,'','','fairness')
343
    save_figure(folder,'corr_fairness')
285 344

  
286 345
def corr_visual_loss_active_peers(folder,groups):
287 346
	files = []
......
307 366
	print "groups are: "+str(groups)
308 367
	
309 368
	mpl.rcParams.update({'font.size': 16})
310
	corr_visual_loss(folder,groups)
311
	corr_visual_loss_active_peers(folder,groups)
369
	#corr_visual_loss(folder,groups)
370
	#corr_visual_loss_active_peers(folder,groups)
312 371
	corr_neigh_impact_evolution(folder,groups)
313 372
	corr_neigh_impact_over_tag(folder,groups)
373
	corr_convergence_time(folder,groups)
374
	corr_neigh_fairness(folder,groups)
314 375
	#corr_visual_hops(folder,groups)
315 376
	#corr_visual_delay(folder,groups)
316 377
	#delayVisualize2(folder,groups)

Also available in: Unified diff