def write_dcd(self,filename): ''' This method writes data in the Charmm/Xplor data format. by calling a pre-compiled C module (dcdio). ''' outfile=dcdio.open_dcd_write(filename) nset = self._coor[:,0,0].shape[0] natoms = self._coor[0,:,0].shape[0] istart = 0 ; nsavc = 1 ; delta = 1.0 headerresult=dcdio.write_dcdheader(outfile,filename,natoms,nset,istart,nsavc,delta) for frame in xrange(nset): print ".", sys.stdout.flush() tx=self._coor[frame,:,0].astype(numpy.float32) ty=self._coor[frame,:,1].astype(numpy.float32) tz=self._coor[frame,:,2].astype(numpy.float32) stepresult=dcdio.write_dcdstep(outfile,tx,ty,tz,frame+1) result = dcdio.close_dcd_write(outfile) return
def write_dcd_frames(self, filename, start, end): ''' This method writes a single step or multiple frames in the Charmm/Xplor data format. by calling a pre-compiled C module (dcdio). ''' outfile = dcdio.open_dcd_write(filename) nset = end - start natoms = self._coor[0, :, 0].shape[0] istart = 0 nsavc = 1 delta = 1.0 headerresult = dcdio.write_dcdheader(outfile, filename, natoms, nset, istart, nsavc, delta) i = 0 for frame in xrange(start, end): print ".", sys.stdout.flush() tx = self._coor[frame, :, 0].astype(numpy.float32) ty = self._coor[frame, :, 1].astype(numpy.float32) tz = self._coor[frame, :, 2].astype(numpy.float32) stepresult = dcdio.write_dcdstep(outfile, tx, ty, tz, i + 1) i += 1 result = dcdio.close_dcd_write(outfile) return
def write_dcd_step(self,filepointer,frame,step): ''' This method writes a single step in the Charmm/Xplor data format. by calling a pre-compiled C module (dcdio). ''' tx=self._coor[frame,:,0].astype(numpy.float32) ty=self._coor[frame,:,1].astype(numpy.float32) tz=self._coor[frame,:,2].astype(numpy.float32) stepresult=dcdio.write_dcdstep(filepointer,tx,ty,tz,step) return
delta = 1.0 headerresult = dcdio.write_dcdheader(fp, filename, natoms, nset, istart, nsavc, delta) print 'writing ' + str(nset) + ' to disk' start_time = time.time() for blah in range(nset): print ".", sys.stdout.flush() x = x + 5.0 y = y + 5.0 z = z + 5.0 stepresult = dcdio.write_dcdstep(fp, x, y, z, blah) end_time = time.time() dt = end_time - start_time print '\ntotal time = ', dt, ' time per structure = ', dt / nset dcdio.close_dcd_write(fp) filename = '200c.dcd' filename = 'c7.dcd' ifp = dcdio.open_dcd_read(filename) nnatoms = 0
nset=200; istart=1 ; nsavc=1 ; delta=1.0 headerresult=dcdio.write_dcdheader(fp,filename,natoms,nset,istart,nsavc,delta) print 'writing '+str(nset)+' to disk' start_time=time.time() for blah in range(nset): print ".", sys.stdout.flush() x=x+5.0 y=y+5.0 z=z+5.0 stepresult=dcdio.write_dcdstep(fp,x,y,z,blah) end_time=time.time() dt=end_time-start_time print '\ntotal time = ',dt,' time per structure = ',dt/nset dcdio.close_dcd_write(fp) filename='200c.dcd' filename='c7.dcd' ifp=dcdio.open_dcd_read(filename)