示例#1
0
                    num_modules) + "_d10_Q" + str(Q) + "T_" + str(
                        T) + "_iter" + str(filecount) + ".txt"
                f2 = (zf.open(file2))
                lines = f2.readlines()
                x = 0
                recovered_list = {}
                for line in lines:
                    data = re.split(',', line)[1:]
                    data[0] = data[0][2:]
                    data[-1] = data[-1][:-2]
                    recovered_list[x] = [int(num) for num in data]
                    x += 1

            #############################################
                for x in xrange(500):
                    if ec.is_epidemic(infected_list[x]) == True:
                        local1, global1 = ec.calculate_local_vs_global_burden(
                            num_modules, infected_list[x], recovered_list[x],
                            G[filecount])
                        local_burden.append(local1)
                        global_burden.append(global1)

            if len(local_burden) == 0: local_burden = [0]
            if len(global_burden) == 0: global_burden = [0]
            if not l_epidict[graph].has_key(Q): l_epidict[graph][Q] = {}
            if not l_error[graph].has_key(Q): l_error[graph][Q] = {}
            if not l_se[graph].has_key(Q): l_se[graph][Q] = {}
            if not g_epidict[graph].has_key(Q): g_epidict[graph][Q] = {}
            if not g_error[graph].has_key(Q): g_error[graph][Q] = {}
            if not g_se[graph].has_key(Q): g_se[graph][Q] = {}
				    data[-1]=data[-1][:-2]
				    infected_list[x]=[int(num) for num in data]
				    x+=1
		    	with zf.open(file2,'r') as f2:
				lines=f2.readlines()
				x=0
				recovered_list={}
				for line in lines:
				    data=re.split(',', line)[1:]
				    data[0]=data[0][2:]
				    data[-1]=data[-1][:-2]
				    recovered_list[x]=[int(num) for num in data]
				    x+=1
		        ###################################################################################
		        
		   	epi_duration.append([max(recovered_list[x]) for x in xrange(500) if ec.is_epidemic(infected_list[x])==True])
		
		duration_list=[x for sublist in epi_duration for x in sublist]
		if len(duration_list)==0:duration_list=[0] 
		if not durdict[graph].has_key(Q): durdict[graph][Q]={}
		if not error[graph].has_key(Q): error[graph][Q]={}
		if not se[graph].has_key(Q): se[graph][Q]={}
		durdict[graph][Q][num_modules] = np.mean(duration_list) #mean of all the epidemic size above the epidemic criteria
		error[graph][Q][num_modules] = np.std(duration_list)
		se[graph][Q][num_modules] = (1.*np.std(duration_list))/ np.sqrt(len(duration_list))
		print graph, num_modules, Q, T, np.mean(duration_list)

	#################################   
	#################################   
	
	    for Q, num_modules in zip(Qrange, num_modules_list):