def organizar(archivo, folder, destino):
	try:
		#BLOQUE PARA LA LINEA DE PROGRESO
		p = subprocess.Popen(['wc', '-l', archivo], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
		result, err = p.communicate()
		total_lineas=int(result.strip().split()[0])
		number=0

		file=open(archivo, 'r')
		for linea in file:
			#DE LA LINEA OBTIENE LOS TRES PRIMEROS CARACTERES: M16-1578 -> M16
			subfolder=linea[:3].lower()
				
			#LINEA DE PROGRESO SE LLAMA EN CADA CICLO
			progress.printProgress(number, total_lineas-1, prefix = 'Progress:', suffix = 'Complete', barLength = 50)
			number+=1

			#SE UNE FODLER DESTINO CON SUBFOLDER. EJEMPLO: PATOLOGIAS/M15
			rutaunion=destino+"/"+subfolder
			#CONDICION Si NO EXISTE FOLDER EJ: PATOLOG/M16 ENTONCES LO CREA
			if not existefolder(rutaunion):
				crearfolder(rutaunion)
			
			#VA A COPIAR EJ: (linea)m16-002.txt.html ubicado en (folder)/home/fox copiar hacia (destino)/home/fox/organizado
			copiar(linea, folder, rutaunion)
		file.close()
		print ("\n")
	except Exception, e:
		print "Ha fallado en organizar",str(e)
		sys.exit(1)
 def resetProgress(self, printStatus=False):
     self.iterationCounter = 0
     if printStatus:
         printProgress(0, self.maxIterations)
timestep_coords = np.zeros((n_part, 3))
part_id = 0
timestep = 0

print "Read in coordinates..."

for idx, line in enumerate(datafile_numpy):
    #skip headerlines plus first timestep line
    if idx < n_headerlines + 1:
        continue

    #search for timestep string
    if line == "timestep ordered\n" or line == "t\n":
        if timestep % 1000 == 0:
            #print "Read in timestep", timestep
            printProgress(timestep, n_timesteps)

        coords[timestep] = timestep_coords
        timestep_coords = np.zeros((n_part, 3))

        part_id = 0
        timestep += 1
        continue

    #with correct format this should not happen
    if line == "\n":
        continue

    current_line = line.rstrip()
    split_line = current_line.split()
		else:
			outp=open('../listas_de_vacios/Estan_en_Master_Y_No_VACIOS.txt', 'a')
			outp.write(nombre)
			outp.write("\n")
			outp.close()
		out.close()
	except Exception, e:
		print "Ha fallado",str(e),nombre
		sys.exit(1)



if __name__ == '__main__':
	p = subprocess.Popen(['wc', '-l', '../listas_de_vacios/NO_estan_en_master.txt'], stdout=subprocess.PIPE, 
                                          stderr=subprocess.PIPE)
	result, err = p.communicate()
	total_lineas=int(result.strip().split()[0])
	number=0	
	lista_vacios=open('../listas_de_vacios/NO_estan_en_master.txt', 'r')
	for linea in lista_vacios:
		# nombre=str(linea)
		# buscarenliliana(linea.strip())
		if buscarenliliana(linea.strip()):
			None
		else:
			buscarenerlinda(linea.strip())
		progress.printProgress(number, total_lineas-1, prefix = 'Progress:', suffix = 'Complete', barLength = 50)
		number+=1

	# buscar_en_liliana("m03-6688.txt")
n_frames = coords.shape[0]
n_part = coords.shape[1]
box_l = (n_part * np.pi / (6. * eta))**(1. / 3.)

#indices/ids for different particle types
indices_ptype = {}
vel_distributions = {}
avg_counters = {}  #avg_counter[type] = numpy array with length n_bins
for t in list_ptypes:
    indices_ptype[t] = np.where(ptypes == t)[0]
    vel_distributions[t] = np.zeros(n_bins)
    avg_counters[t] = np.zeros(n_bins)

print "Calculate velocity distribution along z axis..."

printProgress(0, n_frames)

for current_frame in xrange(n_frames):
    if current_frame == max_frames:
        break

    for t in list_ptypes:
        #z coordinates of interest: np.take(coords[current_frame,:,2], indices_ptype[t])
        #velocities of interest (field is applied in x direction): np.take(vels[current_frame,:,0], indices_ptype[t])
        current_coords = np.take(coords[current_frame, :, 2], indices_ptype[t])
        current_vels = np.take(vels[current_frame, :, 0], indices_ptype[t])

        for i in xrange(len(current_vels)):
            #bin index is calculates from z coordinate
            #bin_idx = int(np.floor(current_coords[i]*n_bins/box_l))
            bin_idx = int(np.floor(current_coords[i] % box_l * n_bins / box_l))
counter_particles = 0

#particle_id_deviation = 0 #deviations will be evaluated only for this given particle
particle_id_deviation = n_part - 1  #the last particle is a counterion
coord_part_last_frame = np.array([0., 0., 0.])
dx = np.zeros(n_frames)

for idx, line in enumerate(datafile_countframes):
    if idx < n_headerlines:
        continue

    #starts with first "timestep ordered" or "t" line

    if line == "timestep ordered\n" or line == "t\n":
        if not counter_frames % 100:
            printProgress(counter_frames, n_frames)
        if counter_particles != n_part and counter_frames:
            validity_buffer += "Frame {0} corrupt: found only {1}/{2} particles.\n".format(
                counter_frames, counter_particles, n_part)

        counter_particles = 0
        counter_frames += 1

    elif line == "\n":
        continue

    else:
        #should find only coordinates
        current_line = line.rstrip()
        split_line = current_line.split()
        try:
Beispiel #7
0
coords = np.zeros((n_timesteps, n_part, 3))
timestep_coords = np.zeros((n_part, 3))
part_id = 0
timestep = 0

for idx, line in enumerate(datafile_numpy):
    #skip headerlines plus first timestep line
    if idx < n_headerlines+1:
        continue
    
    #search for timestep string
    if line == "timestep ordered\n" or line =="t\n":
        if timestep%100==0:
            #print "Read in timestep", timestep
            printProgress(timestep, n_timesteps)
        
        coords[timestep] = timestep_coords
        timestep_coords = np.zeros((n_part, 3))
        
        part_id = 0
        timestep += 1
        continue
    
    #with correct format this should not happen
    if line == "\n":
        continue
    
    current_line = line.rstrip()
    split_line = current_line.split()