#given a pos file name, return the particle vertices array in all frames import numpy as np def getShapeVerticesFromPos(filename): #particle shape vertices allVerts = [] with open(filename,'r') as f: #With syntax for using the open command deletes it when scope ends for line in f: #line with 'poly3d' has shape vertices information if 'poly3d' in line: temp = line.replace('"',''); temp = temp.split() #number of vertices N_vertices = int(temp[3]); #one shape vertices verts = np.zeros(N_vertices*3, dtype=float); for i in range(N_vertices*3): verts[i] = float(temp[i+4]); #append the shape to result allVerts.append(verts) allVerts = np.array(allVerts, float) return allVerts #filename = "diamond_seed1_k0.00_phi0.60_N128_V32.pos" #allVerts = getShapeVerticesFromPos(filename)